Example #1
0
        //---------------------------------------------------------------------------------------
        // Creates a new repartitioning enumerator.
        //
        // Arguments:
        //     source            - the data stream from which to pull elements
        //     useOrdinalOrderPreservation - whether order preservation is required
        //     partitionCount    - total number of partitions
        //     partitionIndex    - this operator's unique partition index
        //     repartitionStream - the stream object to use for partition selection
        //     barrier           - a latch used to signal task completion
        //     buffers           - a set of buffers for inter-task communication
        //

        internal HashRepartitionEnumerator(
            QueryOperatorEnumerator <TInputOutput, TIgnoreKey> source, int partitionCount, int partitionIndex,
            Func <TInputOutput, THashKey>?keySelector, HashRepartitionStream <TInputOutput, THashKey, int> repartitionStream,
            CountdownEvent barrier, ListChunk <Pair <TInputOutput, THashKey> >[][] valueExchangeMatrix, CancellationToken cancellationToken)
        {
            Debug.Assert(source != null);
            Debug.Assert(keySelector != null || typeof(THashKey) == typeof(NoKeyMemoizationRequired));
            Debug.Assert(repartitionStream != null);
            Debug.Assert(barrier != null);
            Debug.Assert(valueExchangeMatrix != null);
            Debug.Assert(valueExchangeMatrix.GetLength(0) == partitionCount, "expected square matrix of buffers (NxN)");
            Debug.Assert(partitionCount > 0 && valueExchangeMatrix[0].Length == partitionCount, "expected square matrix of buffers (NxN)");
            Debug.Assert(0 <= partitionIndex && partitionIndex < partitionCount);

            _source              = source;
            _partitionCount      = partitionCount;
            _partitionIndex      = partitionIndex;
            _keySelector         = keySelector;
            _repartitionStream   = repartitionStream;
            _barrier             = barrier;
            _valueExchangeMatrix = valueExchangeMatrix;
            _cancellationToken   = cancellationToken;

            if (ParallelEnumerable.SinglePartitionMode)
            {
                Debug.Assert(partitionCount == 1);
            }
        }
Example #2
0
 internal HashRepartitionEnumerator(QueryOperatorEnumerator <TInputOutput, TIgnoreKey> source, int partitionCount, int partitionIndex, Func <TInputOutput, THashKey> keySelector, HashRepartitionStream <TInputOutput, THashKey, int> repartitionStream, CountdownEvent barrier, ListChunk <Pair <TInputOutput, THashKey> >[,] valueExchangeMatrix, CancellationToken cancellationToken)
 {
     this.m_source              = source;
     this.m_partitionCount      = partitionCount;
     this.m_partitionIndex      = partitionIndex;
     this.m_keySelector         = keySelector;
     this.m_repartitionStream   = repartitionStream;
     this.m_barrier             = barrier;
     this.m_valueExchangeMatrix = valueExchangeMatrix;
     this.m_cancellationToken   = cancellationToken;
 }
        //---------------------------------------------------------------------------------------
        // Creates a new repartitioning enumerator.
        //
        // Arguments:
        //     source            - the data stream from which to pull elements
        //     useOrdinalOrderPreservation - whether order preservation is required
        //     partitionCount    - total number of partitions
        //     partitionIndex    - this operator's unique partition index
        //     repartitionStream - the stream object to use for partition selection
        //     barrier           - a latch used to signal task completion
        //     buffers           - a set of buffers for inter-task communication
        //

        internal HashRepartitionEnumerator(
            QueryOperatorEnumerator <TInputOutput, TIgnoreKey> source, int partitionCount, int partitionIndex,
            Func <TInputOutput, THashKey> keySelector, HashRepartitionStream <TInputOutput, THashKey, int> repartitionStream,
            CountdownEvent barrier, ListChunk <Pair <TInputOutput, THashKey> >[,] valueExchangeMatrix, CancellationToken cancellationToken)
        {
            Contract.Assert(source != null);
            Contract.Assert(keySelector != null || typeof(THashKey) == typeof(NoKeyMemoizationRequired));
            Contract.Assert(repartitionStream != null);
            Contract.Assert(barrier != null);
            Contract.Assert(valueExchangeMatrix != null);
            Contract.Assert(valueExchangeMatrix.GetLength(0) == partitionCount, "expected square matrix of buffers (NxN)");
            Contract.Assert(valueExchangeMatrix.GetLength(1) == partitionCount, "expected square matrix of buffers (NxN)");
            Contract.Assert(0 <= partitionIndex && partitionIndex < partitionCount);

            m_source              = source;
            m_partitionCount      = partitionCount;
            m_partitionIndex      = partitionIndex;
            m_keySelector         = keySelector;
            m_repartitionStream   = repartitionStream;
            m_barrier             = barrier;
            m_valueExchangeMatrix = valueExchangeMatrix;
            m_cancellationToken   = cancellationToken;
        }
        //---------------------------------------------------------------------------------------
        // Creates a new repartitioning enumerator.
        //
        // Arguments:
        //     source            - the data stream from which to pull elements
        //     useOrdinalOrderPreservation - whether order preservation is required
        //     partitionCount    - total number of partitions
        //     partitionIndex    - this operator's unique partition index
        //     repartitionStream - the stream object to use for partition selection
        //     barrier           - a latch used to signal task completion
        //     buffers           - a set of buffers for inter-task communication
        //

        internal OrderedHashRepartitionEnumerator(
            QueryOperatorEnumerator <TInputOutput, TOrderKey> source, int partitionCount, int partitionIndex,
            Func <TInputOutput, THashKey> keySelector, OrderedHashRepartitionStream <TInputOutput, THashKey, TOrderKey> repartitionStream, CountdownEvent barrier,
            ListChunk <Pair>[][] valueExchangeMatrix, ListChunk <TOrderKey>[][] keyExchangeMatrix, CancellationToken cancellationToken)
        {
            Contract.Assert(source != null);
            Contract.Assert(keySelector != null || typeof(THashKey) == typeof(NoKeyMemoizationRequired));
            Contract.Assert(repartitionStream != null);
            Contract.Assert(barrier != null);
            Contract.Assert(valueExchangeMatrix != null);
            Contract.Assert(valueExchangeMatrix.GetLength(0) == partitionCount, "expected square matrix of buffers (NxN)");
            Contract.Assert(partitionCount > 0 && valueExchangeMatrix[0].Length == partitionCount, "expected square matrix of buffers (NxN)");
            Contract.Assert(0 <= partitionIndex && partitionIndex < partitionCount);

            _source              = source;
            _partitionCount      = partitionCount;
            _partitionIndex      = partitionIndex;
            _keySelector         = keySelector;
            _repartitionStream   = repartitionStream;
            _barrier             = barrier;
            _valueExchangeMatrix = valueExchangeMatrix;
            _keyExchangeMatrix   = keyExchangeMatrix;
            _cancellationToken   = cancellationToken;
        }