public override void Process(K key, V value) { if (key == null) { log.Warn($"Skipping record due to null key.value =[{value}] topic =[{Context.RecordContext.Topic}] partition =[{Context.RecordContext.Partition}] offset =[{Context.RecordContext.Offset }]"); return; } observedStreamTime = Math.Max(observedStreamTime, Context.Timestamp); long closeTime = observedStreamTime - windowOptions.GracePeriodMs; var matchedWindows = windowOptions.WindowsFor(Context.Timestamp); foreach (var entry in matchedWindows) { long windowStart = entry.Key, windowEnd = entry.Value.EndMs; if (windowEnd > closeTime) { var oldAggAndTimestamp = windowStore.Fetch(key, windowStart); Agg oldAgg = oldAggAndTimestamp == null ? default : oldAggAndTimestamp.Value; long newTs; Agg newAgg; if (oldAggAndTimestamp == null) { oldAgg = initializer.Apply(); newTs = Context.Timestamp; } else { newTs = Math.Max(Context.Timestamp, oldAggAndTimestamp.Timestamp); } newAgg = aggregator.Apply(key, value, oldAgg); windowStore.Put(key, ValueAndTimestamp <Agg> .Make(newAgg, newTs), windowStart); tupleForwarder.MaybeForward(new Windowed <K>(key, entry.Value), newAgg, sendOldValues ? oldAgg : default, newTs);
public V Fetch(K key, long time) { var e = innerStore.Fetch(key, time); return(e != null ? e.Value : default);
public ValueAndTimestamp <V> Get(Windowed <K> key) { return(store.Fetch(key.Key, key.Window.StartMs)); }