private ComputeDistinctQueryPipelineStage( DistinctMap distinctMap, IQueryPipelineStage source, CancellationToken cancellationToken) : base(distinctMap, source, cancellationToken) { }
protected DistinctQueryPipelineStage( DistinctMap distinctMap, IQueryPipelineStage source, CancellationToken cancellationToken) : base(source, cancellationToken) { this.distinctMap = distinctMap ?? throw new ArgumentNullException(nameof(distinctMap)); }
private ClientDistinctQueryPipelineStage( DistinctQueryType distinctQueryType, DistinctMap distinctMap, IQueryPipelineStage source, CancellationToken cancellationToken) : base(distinctMap, source, cancellationToken) { if ((distinctQueryType != DistinctQueryType.Unordered) && (distinctQueryType != DistinctQueryType.Ordered)) { throw new ArgumentException($"Unknown {nameof(DistinctQueryType)}: {distinctQueryType}."); } this.distinctQueryType = distinctQueryType; }
public static TryCatch <IQueryPipelineStage> MonadicCreate( CosmosElement requestContinuation, CancellationToken cancellationToken, MonadicCreatePipelineStage monadicCreatePipelineStage, DistinctQueryType distinctQueryType) { if (monadicCreatePipelineStage == null) { throw new ArgumentNullException(nameof(monadicCreatePipelineStage)); } DistinctContinuationToken distinctContinuationToken; if (requestContinuation != null) { if (!DistinctContinuationToken.TryParse(requestContinuation, out distinctContinuationToken)) { return(TryCatch <IQueryPipelineStage> .FromException( new MalformedContinuationTokenException( $"Invalid {nameof(DistinctContinuationToken)}: {requestContinuation}"))); } } else { distinctContinuationToken = new DistinctContinuationToken(sourceToken: null, distinctMapToken: null); } TryCatch <DistinctMap> tryCreateDistinctMap = DistinctMap.TryCreate( distinctQueryType, distinctContinuationToken.DistinctMapToken); if (!tryCreateDistinctMap.Succeeded) { return(TryCatch <IQueryPipelineStage> .FromException(tryCreateDistinctMap.Exception)); } TryCatch <IQueryPipelineStage> tryCreateSource = monadicCreatePipelineStage(distinctContinuationToken.SourceToken, cancellationToken); if (!tryCreateSource.Succeeded) { return(TryCatch <IQueryPipelineStage> .FromException(tryCreateSource.Exception)); } return(TryCatch <IQueryPipelineStage> .FromResult( new ComputeDistinctQueryPipelineStage( tryCreateDistinctMap.Result, tryCreateSource.Result, cancellationToken))); }
public static TryCatch <IQueryPipelineStage> MonadicCreate( CosmosElement requestContinuation, CancellationToken cancellationToken, MonadicCreatePipelineStage monadicCreatePipelineStage, DistinctQueryType distinctQueryType) { if (monadicCreatePipelineStage == null) { throw new ArgumentNullException(nameof(monadicCreatePipelineStage)); } DistinctContinuationToken distinctContinuationToken; if (requestContinuation != null) { if (!DistinctContinuationToken.TryParse(requestContinuation, out distinctContinuationToken)) { return(TryCatch <IQueryPipelineStage> .FromException( new MalformedContinuationTokenException( $"Invalid {nameof(DistinctContinuationToken)}: {requestContinuation}"))); } } else { distinctContinuationToken = new DistinctContinuationToken( sourceToken: null, distinctMapToken: null); } CosmosElement distinctMapToken = distinctContinuationToken.DistinctMapToken != null ? CosmosString.Create(distinctContinuationToken.DistinctMapToken) : null; TryCatch <DistinctMap> tryCreateDistinctMap = DistinctMap.TryCreate( distinctQueryType, distinctMapToken); if (!tryCreateDistinctMap.Succeeded) { return(TryCatch <IQueryPipelineStage> .FromException(tryCreateDistinctMap.Exception)); } CosmosElement sourceToken; if (distinctContinuationToken.SourceToken != null) { TryCatch <CosmosElement> tryParse = CosmosElement.Monadic.Parse(distinctContinuationToken.SourceToken); if (tryParse.Failed) { return(TryCatch <IQueryPipelineStage> .FromException( new MalformedContinuationTokenException( message : $"Invalid Source Token: {distinctContinuationToken.SourceToken}", innerException : tryParse.Exception))); } sourceToken = tryParse.Result; } else { sourceToken = null; } TryCatch <IQueryPipelineStage> tryCreateSource = monadicCreatePipelineStage(sourceToken, cancellationToken); if (!tryCreateSource.Succeeded) { return(TryCatch <IQueryPipelineStage> .FromException(tryCreateSource.Exception)); } return(TryCatch <IQueryPipelineStage> .FromResult( new ClientDistinctQueryPipelineStage( distinctQueryType, tryCreateDistinctMap.Result, tryCreateSource.Result, cancellationToken))); }