internal override Task <QueryResponseCore> ExecuteItemQueryAsync <RequestOptionType>( Uri resourceUri, ResourceType resourceType, OperationType operationType, RequestOptionType requestOptions, SqlQuerySpec sqlQuerySpec, string continuationToken, PartitionKeyRangeIdentity partitionKeyRange, bool isContinuationExpected, int pageSize, SchedulingStopwatch schedulingStopwatch, CancellationToken cancellationToken) { Assert.IsFalse( this.forceQueryPlanGatewayElseServiceInterop && this.QueryPlanCalls == 0, "Query Plan is force gateway mode, but no ExecuteQueryPlanRequestAsync have been called"); return(base.ExecuteItemQueryAsync( resourceUri: resourceUri, resourceType: resourceType, operationType: operationType, requestOptions: requestOptions, sqlQuerySpec: sqlQuerySpec, continuationToken: continuationToken, partitionKeyRange: partitionKeyRange, isContinuationExpected: isContinuationExpected, pageSize: pageSize, schedulingStopwatch: schedulingStopwatch, cancellationToken: cancellationToken)); }
internal abstract Task <QueryResponseCore> ExecuteQueryAsync( SqlQuerySpec querySpecForInit, string continuationToken, PartitionKeyRangeIdentity partitionKeyRange, bool isContinuationExpected, int pageSize, SchedulingStopwatch schedulingStopwatch, CancellationToken cancellationToken);
internal abstract Task <QueryResponseCore> ExecuteItemQueryAsync <QueryRequestOptionType>( Uri resourceUri, Documents.ResourceType resourceType, Documents.OperationType operationType, QueryRequestOptionType requestOptions, SqlQuerySpec sqlQuerySpec, string continuationToken, Documents.PartitionKeyRangeIdentity partitionKeyRange, bool isContinuationExpected, int pageSize, SchedulingStopwatch schedulingStopwatch, CancellationToken cancellationToken);
public QueryPageDiagnostics( string partitionKeyRangeId, string queryMetricText, string indexUtilizationText, CosmosDiagnosticsContext diagnosticsContext, SchedulingStopwatch schedulingStopwatch) { this.PartitionKeyRangeId = partitionKeyRangeId ?? throw new ArgumentNullException(nameof(partitionKeyRangeId)); this.QueryMetricText = queryMetricText ?? string.Empty; this.IndexUtilizationText = indexUtilizationText ?? string.Empty; this.DiagnosticsContext = diagnosticsContext; this.SchedulingTimeSpan = schedulingStopwatch.Elapsed; }
// Root Query. public DocumentQuery( IDocumentQueryClient client, ResourceType resourceTypeEnum, Type resourceType, string documentsFeedOrDatabaseLink, Expression expression, FeedOptions feedOptions, object partitionKey = null) { if (client == null) { throw new ArgumentNullException("client"); } this.client = client; this.resourceTypeEnum = resourceTypeEnum; this.resourceType = resourceType; this.documentsFeedOrDatabaseLink = documentsFeedOrDatabaseLink; this.feedOptions = feedOptions == null ? new FeedOptions() : new FeedOptions(feedOptions); // Swapping out negative values in feedOptions for int.MaxValue if (this.feedOptions.MaxBufferedItemCount < 0) { this.feedOptions.MaxBufferedItemCount = int.MaxValue; } if (this.feedOptions.MaxDegreeOfParallelism < 0) { this.feedOptions.MaxDegreeOfParallelism = int.MaxValue; } if (this.feedOptions.MaxItemCount < 0) { this.feedOptions.MaxItemCount = int.MaxValue; } this.partitionKey = partitionKey; this.expression = expression ?? Expression.Constant(this); this.queryProvider = new DocumentQueryProvider( client, resourceTypeEnum, resourceType, documentsFeedOrDatabaseLink, feedOptions, partitionKey, this.client.OnExecuteScalarQueryCallback); this.executeNextAysncMetrics = new SchedulingStopwatch(); this.executeNextAysncMetrics.Ready(); this.correlatedActivityId = Guid.NewGuid(); }
/// <summary> /// Initializes a new instance of the ItemProducer class. /// </summary> /// <param name="queryContext">request context</param> /// <param name="querySpecForInit">query spec for initialization</param> /// <param name="partitionKeyRange">The partition key range.</param> /// <param name="produceAsyncCompleteCallback">The callback to call once you are done fetching.</param> /// <param name="equalityComparer">The comparer to use to determine whether the producer has seen a new document.</param> /// <param name="testFlags">Flags used to help faciliate testing.</param> /// <param name="initialPageSize">The initial page size.</param> /// <param name="initialContinuationToken">The initial continuation token.</param> public ItemProducer( CosmosQueryContext queryContext, SqlQuerySpec querySpecForInit, PartitionKeyRange partitionKeyRange, ProduceAsyncCompleteDelegate produceAsyncCompleteCallback, IEqualityComparer <CosmosElement> equalityComparer, TestInjections testFlags, long initialPageSize = 50, string initialContinuationToken = null) { this.bufferedPages = new AsyncCollection <QueryResponseCore>(); // We use a binary semaphore to get the behavior of a mutex, // since fetching documents from the backend using a continuation token is a critical section. this.fetchSemaphore = new SemaphoreSlim(1, 1); this.queryContext = queryContext; this.querySpecForInit = querySpecForInit; this.PartitionKeyRange = partitionKeyRange ?? throw new ArgumentNullException(nameof(partitionKeyRange)); this.produceAsyncCompleteCallback = produceAsyncCompleteCallback ?? throw new ArgumentNullException(nameof(produceAsyncCompleteCallback)); this.equalityComparer = equalityComparer ?? throw new ArgumentNullException(nameof(equalityComparer)); this.pageSize = initialPageSize; this.CurrentContinuationToken = initialContinuationToken; this.BackendContinuationToken = initialContinuationToken; this.PreviousContinuationToken = initialContinuationToken; if (!string.IsNullOrEmpty(initialContinuationToken)) { this.hasStartedFetching = true; this.IsActive = true; } this.fetchSchedulingMetrics = new SchedulingStopwatch(); this.fetchSchedulingMetrics.Ready(); this.testFlags = testFlags; this.HasMoreResults = true; }
public DocumentProducer( ComparableTaskScheduler taskScheduler, Func <string, int, DocumentServiceRequest> createRequestFunc, PartitionKeyRange targetRange, Func <DocumentProducer <T>, int> taskPriorityFunc, Func <DocumentServiceRequest, CancellationToken, Task <FeedResponse <T> > > executeRequestFunc, Func <IDocumentClientRetryPolicy> createRetryPolicyFunc, ProduceAsyncCompleteDelegate produceAsyncCompleteCallback, Guid correlatedActivityId, long initialPageSize = 50, string initialContinuationToken = null) { if (taskScheduler == null) { throw new ArgumentNullException("taskScheduler"); } if (createRequestFunc == null) { throw new ArgumentNullException("documentServiceRequest"); } if (targetRange == null) { throw new ArgumentNullException("targetRange"); } if (taskPriorityFunc == null) { throw new ArgumentNullException("taskPriorityFunc"); } if (executeRequestFunc == null) { throw new ArgumentNullException("executeRequestFunc"); } if (createRetryPolicyFunc == null) { throw new ArgumentNullException("createRetryPolicyFunc"); } if (produceAsyncCompleteCallback == null) { throw new ArgumentNullException("produceAsyncCallback"); } this.taskScheduler = taskScheduler; this.itemBuffer = new AsyncCollection <FetchResult>(); this.createRequestFunc = createRequestFunc; this.targetRange = targetRange; this.taskPriorityFunc = taskPriorityFunc; this.createRetryPolicyFunc = createRetryPolicyFunc; this.executeRequestFunc = executeRequestFunc; this.produceAsyncCompleteCallback = produceAsyncCompleteCallback; this.PageSize = initialPageSize; if ((int)this.PageSize < 0) { throw new ArithmeticException("page size is negative.."); } this.correlatedActivityId = correlatedActivityId; this.CurrentBackendContinuationToken = initialContinuationToken; this.moveNextSchedulingMetrics = new SchedulingStopwatch(); this.moveNextSchedulingMetrics.Ready(); this.fetchSchedulingMetrics = new SchedulingStopwatch(); this.fetchSchedulingMetrics.Ready(); this.fetchExecutionRangeAccumulator = new FetchExecutionRangeAccumulator(this.targetRange.Id); this.fetchStateSemaphore = new SemaphoreSlim(1, 1); }