private readonly IComparer <TKey> _keyComparer; // Comparer for the order keys //--------------------------------------------------------------------------------------- // Instantiates a new enumerator. // internal LastQueryOperatorEnumerator( QueryOperatorEnumerator <TSource, TKey> source, Func <TSource, bool>?predicate, LastQueryOperatorState <TKey> operatorState, CountdownEvent sharedBarrier, CancellationToken cancelToken, IComparer <TKey> keyComparer, int partitionId) { Debug.Assert(source != null); Debug.Assert(operatorState != null); Debug.Assert(sharedBarrier != null); Debug.Assert(keyComparer != null); _source = source; _predicate = predicate; _operatorState = operatorState; _sharedBarrier = sharedBarrier; _cancellationToken = cancelToken; _keyComparer = keyComparer; _partitionId = partitionId; }
private void WrapHelper <TKey>(PartitionedStream <TSource, TKey> inputStream, IPartitionedStreamRecipient <TSource> recipient, QuerySettings settings) { int partitionCount = inputStream.PartitionCount; // Generate the shared data. LastQueryOperatorState <TKey> operatorState = new LastQueryOperatorState <TKey>(); CountdownEvent sharedBarrier = new CountdownEvent(partitionCount); PartitionedStream <TSource, int> outputStream = new PartitionedStream <TSource, int>(partitionCount, Util.GetDefaultComparer <int>(), OrdinalIndexState.Shuffled); for (int i = 0; i < partitionCount; i++) { outputStream[i] = new LastQueryOperatorEnumerator <TKey>( inputStream[i], _predicate, operatorState, sharedBarrier, settings.CancellationState.MergedCancellationToken, inputStream.KeyComparer, i); } recipient.Receive(outputStream); }