//--------------------------------------------------------------------------------------- // Instantiates a new hash-join enumerator. // internal HashJoinQueryOperatorEnumerator( QueryOperatorEnumerator <Pair <TLeftInput, THashKey>, TLeftKey> leftSource, HashLookupBuilder <TRightInput, TRightKey, THashKey> rightLookupBuilder, Func <TLeftInput, TRightInput, TOutput> resultSelector, HashJoinOutputKeyBuilder <TLeftKey, TRightKey, TOutputKey> outputKeyBuilder, CancellationToken cancellationToken) { Debug.Assert(leftSource != null); Debug.Assert(rightLookupBuilder != null); Debug.Assert(resultSelector != null); Debug.Assert(outputKeyBuilder != null); _leftSource = leftSource; _rightLookupBuilder = rightLookupBuilder; _resultSelector = resultSelector; _outputKeyBuilder = outputKeyBuilder; _cancellationToken = cancellationToken; }
//--------------------------------------------------------------------------------------- // This is a helper method. WrapPartitionedStream decides what type TLeftKey is going // to be, and then call this method with that key as a generic parameter. // private void WrapPartitionedStreamHelper <TLeftKey, TRightKey>( PartitionedStream <Pair <TLeftInput, TKey>, TLeftKey> leftHashStream, PartitionedStream <TRightInput, TRightKey> rightPartitionedStream, IPartitionedStreamRecipient <TOutput> outputRecipient, int partitionCount, CancellationToken cancellationToken) { if (RightChild.OutputOrdered) { PartitionedStream <Pair <TRightInput, TKey>, TRightKey> rePartitionedRightStream = ExchangeUtilities.HashRepartitionOrdered( rightPartitionedStream, _rightKeySelector, _keyComparer, null, cancellationToken); HashLookupBuilder <IEnumerable <TRightInput>, Pair <bool, TRightKey>, TKey>[] rightLookupBuilders = new HashLookupBuilder <IEnumerable <TRightInput>, Pair <bool, TRightKey>, TKey> [partitionCount]; for (int i = 0; i < partitionCount; i++) { rightLookupBuilders[i] = new OrderedGroupJoinHashLookupBuilder <TRightInput, TRightKey, TKey>( rePartitionedRightStream[i], _keyComparer, rePartitionedRightStream.KeyComparer); } WrapPartitionedStreamHelper <TLeftKey, Pair <bool, TRightKey> >(leftHashStream, rightLookupBuilders, CreateComparer(rightPartitionedStream.KeyComparer), outputRecipient, partitionCount, cancellationToken); } else { PartitionedStream <Pair <TRightInput, TKey>, int> rePartitionedRightStream = ExchangeUtilities.HashRepartition( rightPartitionedStream, _rightKeySelector, _keyComparer, null, cancellationToken); HashLookupBuilder <IEnumerable <TRightInput>, int, TKey>[] rightLookupBuilders = new HashLookupBuilder <IEnumerable <TRightInput>, int, TKey> [partitionCount]; for (int i = 0; i < partitionCount; i++) { rightLookupBuilders[i] = new GroupJoinHashLookupBuilder <TRightInput, int, TKey>( rePartitionedRightStream[i], _keyComparer); } WrapPartitionedStreamHelper <TLeftKey, int>(leftHashStream, rightLookupBuilders, null, outputRecipient, partitionCount, cancellationToken); } }