//---------------------------------------------------------------------------------------
        // Just opens the current operator, including opening the left child and wrapping with a
        // partition if needed. The right child is not opened yet -- this is always done on demand
        // as the outer elements are enumerated.
        //

        internal override QueryResults <TOutput> Open(QuerySettings settings, bool preferStriping)
        {
            QueryResults <TLeftInput> childQueryResults = Child.Open(settings, preferStriping);

            return(new UnaryQueryOperatorResults(childQueryResults, this, settings, preferStriping));
        }
Exemple #2
0
        //---------------------------------------------------------------------------------------
        // Just opens the current operator, including opening the child and wrapping it with
        // partitions as needed.
        //

        internal override QueryResults <TSource> Open(QuerySettings settings, bool preferStriping)
        {
            QueryResults <TSource> childQueryResults = Child.Open(settings, false);

            return(ReverseQueryOperatorResults.NewResults(childQueryResults, this, settings, preferStriping));
        }
Exemple #3
0
        internal override QueryResults <TOutput> Open(QuerySettings settings, bool preferStriping)
        {
            QueryResults <TLeftInput> leftChildQueryResults = base.LeftChild.Open(settings, false);

            return(new BinaryQueryOperator <TLeftInput, TRightInput, TOutput> .BinaryQueryOperatorResults(leftChildQueryResults, base.RightChild.Open(settings, false), this, settings, false));
        }
Exemple #4
0
        //---------------------------------------------------------------------------------------
        // Just opens the current operator, including opening the child and wrapping it with
        // partitions as needed.
        //

        internal override QueryResults <TOutput> Open(QuerySettings settings, bool preferStriping)
        {
            QueryResults <TInput> childQueryResults = Child.Open(settings, preferStriping);

            return(SelectQueryOperatorResults.NewResults(childQueryResults, this, settings, preferStriping));
        }
Exemple #5
0
        //---------------------------------------------------------------------------------------
        // Just opens the current operator, including opening the child and wrapping it with
        // partitions as needed.
        //

        internal override QueryResults <TResult> Open(QuerySettings settings, bool preferStriping)
        {
            QueryResults <TResult> childQueryResults = Child.Open(settings, true);

            return(TakeOrSkipQueryOperatorResults.NewResults(childQueryResults, this, settings, preferStriping));
        }
Exemple #6
0
 private SelectQueryOperatorResults(QueryResults <TInput> childQueryResults, SelectQueryOperator <TInput, TOutput> op, QuerySettings settings, bool preferStriping) : base(childQueryResults, op, settings, preferStriping)
 {
     this.m_selector   = op.m_selector;
     this.m_childCount = base.m_childQueryResults.ElementsCount;
 }
        //---------------------------------------------------------------------------------------
        // Executes the query and returns the results in an array.
        //

        internal TOutput[] ExecuteAndGetResultsAsArray()
        {
            QuerySettings querySettings =
                SpecifiedQuerySettings
                .WithPerExecutionSettings()
                .WithDefaults();

            QueryLifecycle.LogicalQueryExecutionBegin(querySettings.QueryId);
            try
            {
                if (querySettings.ExecutionMode.Value == ParallelExecutionMode.Default && LimitsParallelism)
                {
                    IEnumerable <TOutput> opSequential = AsSequentialQuery(querySettings.CancellationState.ExternalCancellationToken);
                    IEnumerable <TOutput> opSequentialWithCancelChecks = CancellableEnumerable.Wrap(opSequential, querySettings.CancellationState.ExternalCancellationToken);
                    return(ExceptionAggregator.WrapEnumerable(opSequentialWithCancelChecks, querySettings.CancellationState).ToArray());
                }

                QueryResults <TOutput> results = GetQueryResults(querySettings);

                // Top-level preemptive cancellation test.
                // This handles situations where cancellation has occurred before execution commences
                // The handling for in-execution occurs in QueryTaskGroupState.QueryEnd()

                if (querySettings.CancellationState.MergedCancellationToken.IsCancellationRequested)
                {
                    if (querySettings.CancellationState.ExternalCancellationToken.IsCancellationRequested)
                    {
                        throw new OperationCanceledException(querySettings.CancellationState.ExternalCancellationToken);
                    }
                    else
                    {
                        throw new OperationCanceledException();
                    }
                }

                if (results.IsIndexible && OutputOrdered)
                {
                    // The special array-based merge performs better if the output is ordered, because
                    // it does not have to pay for ordering. In the unordered case, we it appears that
                    // the stop-and-go merge performs a little better.
                    ArrayMergeHelper <TOutput> merger = new ArrayMergeHelper <TOutput>(SpecifiedQuerySettings, results);
                    merger.Execute();
                    TOutput[] output = merger.GetResultsAsArray();
                    querySettings.CleanStateAtQueryEnd();
                    return(output);
                }
                else
                {
                    PartitionedStreamMerger <TOutput> merger =
                        new PartitionedStreamMerger <TOutput>(false, ParallelMergeOptions.FullyBuffered, querySettings.TaskScheduler,
                                                              OutputOrdered, querySettings.CancellationState, querySettings.QueryId);
                    results.GivePartitionedStream(merger);
                    TOutput[] output = merger.MergeExecutor.GetResultsAsArray();
                    querySettings.CleanStateAtQueryEnd();
                    return(output);
                }
            }
            finally
            {
                QueryLifecycle.LogicalQueryExecutionEnd(querySettings.QueryId);
            }
        }
Exemple #8
0
        //---------------------------------------------------------------------------------------
        // Opens the current operator. This involves opening the child operator tree, enumerating
        // the results, sorting them, and then returning an enumerator that walks the result.
        //

        internal override QueryResults <TInputOutput> Open(QuerySettings settings, bool preferStriping)
        {
            QueryResults <TInputOutput> childQueryResults = Child.Open(settings, false);

            return(new SortQueryOperatorResults <TInputOutput, TSortKey>(childQueryResults, this, settings));
        }
 private ReverseQueryOperatorResults(QueryResults <TSource> childQueryResults, ReverseQueryOperator <TSource> op, QuerySettings settings, bool preferStriping) : base(childQueryResults, op, settings, preferStriping)
 {
     this.m_count = base.m_childQueryResults.ElementsCount;
 }
Exemple #10
0
 internal BinaryQueryOperatorResults(QueryResults <TLeftInput> leftChildQueryResults, QueryResults <TRightInput> rightChildQueryResults, BinaryQueryOperator <TLeftInput, TRightInput, TOutput> op, QuerySettings settings, bool preferStriping)
 {
     this.m_leftChildQueryResults  = leftChildQueryResults;
     this.m_rightChildQueryResults = rightChildQueryResults;
     this.m_op             = op;
     this.m_settings       = settings;
     this.m_preferStriping = preferStriping;
 }
Exemple #11
0
 private TakeOrSkipQueryOperatorResults(QueryResults <TResult> childQueryResults, TakeOrSkipQueryOperator <TResult> takeOrSkipOp, QuerySettings settings, bool preferStriping) : base(childQueryResults, takeOrSkipOp, settings, preferStriping)
 {
     this.m_takeOrSkipOp = takeOrSkipOp;
     this.m_childCount   = base.m_childQueryResults.ElementsCount;
 }
 public static QueryResults <TSource> NewResults(QueryResults <TSource> leftChildQueryResults, QueryResults <TSource> rightChildQueryResults, ConcatQueryOperator <TSource> op, QuerySettings settings, bool preferStriping)
 {
     if (leftChildQueryResults.IsIndexible && rightChildQueryResults.IsIndexible)
     {
         return(new ConcatQueryOperator <TSource> .ConcatQueryOperatorResults(leftChildQueryResults, rightChildQueryResults, op, settings, preferStriping));
     }
     return(new BinaryQueryOperator <TSource, TSource, TSource> .BinaryQueryOperatorResults(leftChildQueryResults, rightChildQueryResults, op, settings, preferStriping));
 }
 private ConcatQueryOperatorResults(QueryResults <TSource> leftChildQueryResults, QueryResults <TSource> rightChildQueryResults, ConcatQueryOperator <TSource> concatOp, QuerySettings settings, bool preferStriping) : base(leftChildQueryResults, rightChildQueryResults, concatOp, settings, preferStriping)
 {
     this.m_concatOp        = concatOp;
     this.m_leftChildCount  = leftChildQueryResults.ElementsCount;
     this.m_rightChildCount = rightChildQueryResults.ElementsCount;
 }