protected override void ProcessLeftBatch(StreamMessage <TKey, TLeft> batch, out bool leftBatchDone, out bool leftBatchFree) { leftBatchDone = true; leftBatchFree = true; batch.iter = 0; PooledElasticCircularBuffer <LEntry> queue = null; TPartitionKey previous = default; bool first = true; for (var i = 0; i < batch.Count; i++) { if ((batch.bitvector.col[i >> 6] & (1L << (i & 0x3f))) != 0 && (batch.vother.col[i] >= 0)) { continue; } if (batch.vother.col[i] == PartitionedStreamEvent.LowWatermarkOtherTime) { bool timeAdvanced = this.lastLeftCTI != batch.vsync.col[i]; if (timeAdvanced && this.lastLeftCTI < this.lastRightCTI) { this.emitCTI = true; } this.lastLeftCTI = batch.vsync.col[i]; foreach (var p in this.seenKeys) { this.processQueue.Add(p); } continue; } var partitionKey = this.getPartitionKey(batch.key.col[i]); if (first || !partitionKey.Equals(previous)) { if (this.seenKeys.Add(partitionKey)) { NewPartition(partitionKey); } this.leftQueue.Lookup(partitionKey, out int index); queue = this.leftQueue.entries[index].value; this.processQueue.Add(partitionKey); } var e = new LEntry { Key = batch.key.col[i], Sync = batch.vsync.col[i], Other = batch.vother.col[i], Payload = batch.payload.col[i], Hash = batch.hash.col[i], }; queue.Enqueue(ref e); first = false; previous = partitionKey; } ProcessPendingEntries(); }
private static PooledElasticCircularBuffer <PartitionedStreamEvent <TKey, TPayload> > Merge( PooledElasticCircularBuffer <PartitionedStreamEvent <TKey, TPayload> > left, PooledElasticCircularBuffer <PartitionedStreamEvent <TKey, TPayload> > right, PooledElasticCircularBuffer <PartitionedStreamEvent <TKey, TPayload> > result, long timestamp) { while (true) { if ((left.Count == 0) || (left.PeekFirst().SyncTime > timestamp)) { while ((right.Count > 0) && (right.PeekFirst().SyncTime <= timestamp)) { var tmp = right.Dequeue(); result.Enqueue(ref tmp); } return(result); } if ((right.Count == 0) || (right.PeekFirst().SyncTime > timestamp)) { while ((left.Count > 0) && (left.PeekFirst().SyncTime <= timestamp)) { var tmp = left.Dequeue(); result.Enqueue(ref tmp); } return(result); } if (left.PeekFirst().SyncTime < right.PeekFirst().SyncTime) { var tmp = left.Dequeue(); result.Enqueue(ref tmp); } else { var tmp = right.Dequeue(); result.Enqueue(ref tmp); } } }