private void completeWindow(long frameTs) { long frameToEvict = frameTs - winPolicy.windowSize() + winPolicy.frameSize(); Map<K, A> evictedFrame = tsToKeyToAcc.remove(frameToEvict); if (evictedFrame != null) { lazyAdd(totalKeysInFrames, -evictedFrame.size()); lazyAdd(totalFrames, -1); if (!winPolicy.isTumbling() && aggrOp.deductFn() != null) { // deduct trailing-edge frame patchSlidingWindow(aggrOp.deductFn(), evictedFrame); } } assert tsToKeyToAcc.values().stream().mapToInt(Map::size).sum() == totalKeysInFrames.get() : "totalKeysInFrames mismatch, expected=" + tsToKeyToAcc.values().stream().mapToInt(Map::size).sum() + ", actual=" + totalKeysInFrames.get(); }
private Map<K, A> computeWindow(long frameTs) { if (winPolicy.isTumbling()) { return tsToKeyToAcc.getOrDefault(frameTs, emptyMap()); } if (aggrOp.deductFn() == null) { return recomputeWindow(frameTs); } if (slidingWindow == null) { slidingWindow = recomputeWindow(frameTs); } else { // add leading-edge frame patchSlidingWindow(aggrOp.combineFn(), tsToKeyToAcc.get(frameTs)); } return slidingWindow; }
checkTrue(keyFns.size() == aggrOp.arity(), keyFns.size() + " key functions " + "provided for " + aggrOp.arity() + "-arity aggregate operation"); if (!winPolicy.isTumbling()) { requireNonNull(aggrOp.combineFn(), "AggregateOperation.combineFn is required for sliding windows");