avoid range scans when forwarding values during aggregation
Reviewers: Matthias J Sax <matthias@confluentio>, Bill Bejeck John Roesler Guozhang Wang
@@ -219,13 +219,11 @@ class CachingWindowStore<K, V> extends WrappedStateStore.AbstractStateStore impl
}
private V fetchPrevious(final Bytes key, final long timestamp) {
- try (final WindowStoreIterator<byte[]> iter = underlying.fetch(key, timestamp, timestamp)) {
- if (!iter.hasNext()) {
- return null;
- } else {
- return serdes.valueFrom(iter.next().value);
- }
+ final byte[] value = underlying.fetch(key, timestamp);
+ if (value != null) {
+ return serdes.valueFrom(value);
}
+ return null;
}
@Override
