public override void WrapPartitionedStream <TLeftKey, TRightKey>(PartitionedStream <TSource, TLeftKey> leftStream, PartitionedStream <TSource, TRightKey> rightStream, IPartitionedStreamRecipient <TSource> outputRecipient, bool preferStriping, QuerySettings settings)
        {
            PartitionedStream <TSource, int> stream;
            PartitionedStream <TSource, int> stream2;
            OrdinalIndexState ordinalIndexState = leftStream.OrdinalIndexState;
            int partitionCount = leftStream.PartitionCount;

            if (this.m_prematureMergeLeft)
            {
                stream = QueryOperator <TSource> .ExecuteAndCollectResults <TLeftKey>(leftStream, partitionCount, base.LeftChild.OutputOrdered, preferStriping, settings).GetPartitionedStream();
            }
            else
            {
                stream = (PartitionedStream <TSource, int>)leftStream;
            }
            if (this.m_prematureMergeRight)
            {
                stream2 = QueryOperator <TSource> .ExecuteAndCollectResults <TRightKey>(rightStream, partitionCount, base.LeftChild.OutputOrdered, preferStriping, settings).GetPartitionedStream();
            }
            else
            {
                stream2 = (PartitionedStream <TSource, int>)rightStream;
            }
            IComparer <ConcatKey <int, int> > keyComparer = ConcatKey <int, int> .MakeComparer(stream.KeyComparer, stream2.KeyComparer);

            PartitionedStream <TSource, ConcatKey <int, int> > partitionedStream = new PartitionedStream <TSource, ConcatKey <int, int> >(partitionCount, keyComparer, this.OrdinalIndexState);

            for (int i = 0; i < partitionCount; i++)
            {
                partitionedStream[i] = new ConcatQueryOperatorEnumerator <TSource, int, int>(stream[i], stream2[i]);
            }
            outputRecipient.Receive <ConcatKey <int, int> >(partitionedStream);
        }
Exemplo n.º 2
0
        public override void WrapPartitionedStream <TLeftKey, TRightKey>(
            PartitionedStream <TSource, TLeftKey> leftStream, PartitionedStream <TSource, TRightKey> rightStream,
            IPartitionedStreamRecipient <TSource> outputRecipient, bool preferStriping, QuerySettings settings)
        {
            OrdinalIndexState leftChildIndexState = leftStream.OrdinalIndexState;
            int partitionCount = leftStream.PartitionCount;

            PartitionedStream <TSource, int> leftStreamInc;
            PartitionedStream <TSource, int> rightStreamInc;

            // Prematurely merge the left results, if necessary
            if (m_prematureMergeLeft)
            {
                ListQueryResults <TSource> leftStreamResults =
                    ExecuteAndCollectResults(leftStream, partitionCount, LeftChild.OutputOrdered, preferStriping, settings);
                leftStreamInc = leftStreamResults.GetPartitionedStream();
            }
            else
            {
                Contract.Assert(!ExchangeUtilities.IsWorseThan(leftStream.OrdinalIndexState, OrdinalIndexState.Increasing));
                leftStreamInc = (PartitionedStream <TSource, int>)(object) leftStream;
            }

            // Prematurely merge the right results, if necessary
            if (m_prematureMergeRight)
            {
                ListQueryResults <TSource> rightStreamResults =
                    ExecuteAndCollectResults(rightStream, partitionCount, LeftChild.OutputOrdered, preferStriping, settings);
                rightStreamInc = rightStreamResults.GetPartitionedStream();
            }
            else
            {
                Contract.Assert(!ExchangeUtilities.IsWorseThan(rightStream.OrdinalIndexState, OrdinalIndexState.Increasing));
                rightStreamInc = (PartitionedStream <TSource, int>)(object) rightStream;
            }

            // Generate the shared data.
            IComparer <ConcatKey <int, int> > comparer = ConcatKey <int, int> .MakeComparer(
                leftStreamInc.KeyComparer, rightStreamInc.KeyComparer);

            var outputStream = new PartitionedStream <TSource, ConcatKey <int, int> >(partitionCount, comparer, OrdinalIndexState);

            for (int i = 0; i < partitionCount; i++)
            {
                outputStream[i] = new ConcatQueryOperatorEnumerator <int, int>(leftStreamInc[i], rightStreamInc[i]);
            }

            outputRecipient.Receive(outputStream);
        }
Exemplo n.º 3
0
        private void WrapHelper2 <TLeftKey, TRightKey>(
            PartitionedStream <TSource, TLeftKey> leftStreamInc, PartitionedStream <TSource, TRightKey> rightStreamInc,
            IPartitionedStreamRecipient <TSource> outputRecipient)
        {
            int partitionCount = leftStreamInc.PartitionCount;

            // Generate the shared data.
            IComparer <ConcatKey> comparer = ConcatKey.MakeComparer(
                leftStreamInc.KeyComparer, rightStreamInc.KeyComparer);
            var outputStream = new PartitionedStream <TSource, ConcatKey>(partitionCount, comparer, OrdinalIndexState);

            for (int i = 0; i < partitionCount; i++)
            {
                outputStream[i] = new ConcatQueryOperatorEnumerator <TLeftKey, TRightKey>(leftStreamInc[i], rightStreamInc[i]);
            }

            outputRecipient.Receive(outputStream);
        }
        private void WrapPartitionedStreamFixedBothTypes <TLeftKey, TRightKey>(PartitionedStream <Pair <TInputOutput, NoKeyMemoizationRequired>, TLeftKey> leftHashStream, PartitionedStream <Pair <TInputOutput, NoKeyMemoizationRequired>, TRightKey> rightHashStream, IPartitionedStreamRecipient <TInputOutput> outputRecipient, int partitionCount, CancellationToken cancellationToken)
        {
            if (base.LeftChild.OutputOrdered || base.RightChild.OutputOrdered)
            {
                IComparer <ConcatKey <TLeftKey, TRightKey> > keyComparer = ConcatKey <TLeftKey, TRightKey> .MakeComparer(leftHashStream.KeyComparer, rightHashStream.KeyComparer);

                PartitionedStream <TInputOutput, ConcatKey <TLeftKey, TRightKey> > partitionedStream = new PartitionedStream <TInputOutput, ConcatKey <TLeftKey, TRightKey> >(partitionCount, keyComparer, OrdinalIndexState.Shuffled);
                for (int i = 0; i < partitionCount; i++)
                {
                    partitionedStream[i] = new OrderedUnionQueryOperatorEnumerator <TInputOutput, TLeftKey, TRightKey>(leftHashStream[i], rightHashStream[i], base.LeftChild.OutputOrdered, base.RightChild.OutputOrdered, this.m_comparer, keyComparer, cancellationToken);
                }
                outputRecipient.Receive <ConcatKey <TLeftKey, TRightKey> >(partitionedStream);
            }
            else
            {
                PartitionedStream <TInputOutput, int> stream2 = new PartitionedStream <TInputOutput, int>(partitionCount, Util.GetDefaultComparer <int>(), OrdinalIndexState.Shuffled);
                for (int j = 0; j < partitionCount; j++)
                {
                    stream2[j] = new UnionQueryOperatorEnumerator <TInputOutput, TLeftKey, TRightKey>(leftHashStream[j], rightHashStream[j], j, this.m_comparer, cancellationToken);
                }
                outputRecipient.Receive <int>(stream2);
            }
        }
Exemplo n.º 5
0
        //---------------------------------------------------------------------------------------
        // A helper method that allows WrapPartitionedStreamHelper to fix the TRightKey type parameter.
        //

        private void WrapPartitionedStreamFixedBothTypes <TLeftKey, TRightKey>(
            PartitionedStream <Pair, TLeftKey> leftHashStream,
            PartitionedStream <Pair, TRightKey> rightHashStream,
            IPartitionedStreamRecipient <TInputOutput> outputRecipient, int partitionCount,
            CancellationToken cancellationToken)
        {
            if (LeftChild.OutputOrdered || RightChild.OutputOrdered)
            {
                IComparer <ConcatKey> compoundKeyComparer =
                    ConcatKey.MakeComparer(leftHashStream.KeyComparer, rightHashStream.KeyComparer);

                PartitionedStream <TInputOutput, ConcatKey> outputStream =
                    new PartitionedStream <TInputOutput, ConcatKey>(partitionCount, compoundKeyComparer, OrdinalIndexState.Shuffled);

                for (int i = 0; i < partitionCount; i++)
                {
                    outputStream[i] = new OrderedUnionQueryOperatorEnumerator <TLeftKey, TRightKey>(
                        leftHashStream[i], rightHashStream[i], LeftChild.OutputOrdered, RightChild.OutputOrdered,
                        _comparer, compoundKeyComparer, cancellationToken);
                }

                outputRecipient.Receive(outputStream);
            }
            else
            {
                PartitionedStream <TInputOutput, int> outputStream =
                    new PartitionedStream <TInputOutput, int>(partitionCount, Util.GetDefaultComparer <int>(), OrdinalIndexState.Shuffled);

                for (int i = 0; i < partitionCount; i++)
                {
                    outputStream[i] = new UnionQueryOperatorEnumerator <TLeftKey, TRightKey>(
                        leftHashStream[i], rightHashStream[i], i, _comparer, cancellationToken);
                }

                outputRecipient.Receive(outputStream);
            }
        }