public static TryCatch <IQueryPipelineStage> MonadicCreate(
                DCountInfo info,
                CosmosElement continuationToken,
                CancellationToken cancellationToken,
                MonadicCreatePipelineStage monadicCreatePipelineStage)
            {
                cancellationToken.ThrowIfCancellationRequested();

                DCountContinuationToken dcountContinuationToken;

                if (continuationToken != null)
                {
                    if (!DCountContinuationToken.TryCreateFromCosmosElement(
                            continuationToken,
                            out dcountContinuationToken))
                    {
                        return(TryCatch <IQueryPipelineStage> .FromException(
                                   new MalformedContinuationTokenException(
                                       $"Malfomed {nameof(DCountContinuationToken)}: '{continuationToken}'")));
                    }
                }
                else
                {
                    dcountContinuationToken = new DCountContinuationToken(count: 0, sourceContinuationToken: null);
                }

                TryCatch <IQueryPipelineStage> tryCreateSource;

                if (dcountContinuationToken.SourceContinuationToken is CosmosString stringToken && (stringToken.Value == DoneSourceToken.Value))
                {
                    tryCreateSource = TryCatch <IQueryPipelineStage> .FromResult(EmptyQueryPipelineStage.Singleton);
                }
コード例 #2
0
 public static TryCatch <IQueryPipelineStage> MonadicCreate(
     ExecutionEnvironment executionEnvironment,
     DCountInfo info,
     CosmosElement continuationToken,
     CancellationToken cancellationToken,
     MonadicCreatePipelineStage monadicCreatePipelineStage) => executionEnvironment switch
 {
コード例 #3
0
            public static TryCatch <IQueryPipelineStage> MonadicCreate(
                DCountInfo info,
                CosmosElement continuationToken,
                CancellationToken cancellationToken,
                MonadicCreatePipelineStage monadicCreatePipelineStage)
            {
                if (monadicCreatePipelineStage == null)
                {
                    throw new ArgumentNullException(nameof(monadicCreatePipelineStage));
                }

                TryCatch <IQueryPipelineStage> tryCreateSource = monadicCreatePipelineStage(continuationToken, cancellationToken);

                if (tryCreateSource.Failed)
                {
                    return(tryCreateSource);
                }

                ClientDCountQueryPipelineStage stage = new ClientDCountQueryPipelineStage(
                    source: tryCreateSource.Result,
                    count: 0,
                    info: info,
                    cancellationToken: cancellationToken);

                return(TryCatch <IQueryPipelineStage> .FromResult(stage));
            }
 private ComputeDCountQueryPipelineStage(
     IQueryPipelineStage source,
     long count,
     DCountInfo info,
     CancellationToken cancellationToken)
     : base(source, count, info, cancellationToken)
 {
     // all the work is done in the base constructor.
 }
コード例 #5
0
 /// <summary>
 /// Initializes a new instance of the DCountQueryPipelineStage class.
 /// </summary>
 /// <param name="source">The source component that will supply the local aggregates from multiple continuations and partitions.</param>
 /// <param name="count">The actual dcount that will be reported.</param>
 /// <param name="info">Metadata about the original dcount query that is elided in the rewritten query</param>
 /// <param name="cancellationToken">The cancellation token for cooperative yeilding.</param>
 /// <remarks>This constructor is private since there is some async initialization that needs to happen in CreateAsync().</remarks>
 public DCountQueryPipelineStage(
     IQueryPipelineStage source,
     long count,
     DCountInfo info,
     CancellationToken cancellationToken)
     : base(source, cancellationToken)
 {
     this.count = count;
     this.info  = info;
 }