bbejeck commented on code in PR #22318:
URL: https://github.com/apache/kafka/pull/22318#discussion_r3335953622
##########
streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredWindowStore.java:
##########
@@ -380,6 +332,70 @@ public KeyValueIterator<Windowed<K>, V> backwardAll() {
);
}
+ private final class ReadOnlyView implements ReadOnlyWindowStore<K, V> {
+
+ private final ReadOnlyWindowStore<Bytes, byte[]> underlying;
+
+ ReadOnlyView(final ReadOnlyWindowStore<Bytes, byte[]> underlying) {
+ this.underlying = underlying;
+ }
+
+ @Override
+ public V fetch(final K key, final long windowStartTimestamp) {
+ Objects.requireNonNull(key, "key cannot be null");
+ return maybeMeasureLatency(
+ () -> {
+ final byte[] result = underlying.fetch(serializeKey(key),
windowStartTimestamp);
+ return result == null ? null : deserializeValue(result);
+ },
+ time,
+ fetchSensor
+ );
+ }
+
+ @Override
+ public WindowStoreIterator<V> fetch(final K key, final Instant
timeFrom, final Instant timeTo) {
Review Comment:
nit: parameter per line
##########
streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredWindowStore.java:
##########
@@ -380,6 +332,70 @@ public KeyValueIterator<Windowed<K>, V> backwardAll() {
);
}
+ private final class ReadOnlyView implements ReadOnlyWindowStore<K, V> {
+
+ private final ReadOnlyWindowStore<Bytes, byte[]> underlying;
+
+ ReadOnlyView(final ReadOnlyWindowStore<Bytes, byte[]> underlying) {
+ this.underlying = underlying;
+ }
+
+ @Override
+ public V fetch(final K key, final long windowStartTimestamp) {
+ Objects.requireNonNull(key, "key cannot be null");
+ return maybeMeasureLatency(
+ () -> {
+ final byte[] result = underlying.fetch(serializeKey(key),
windowStartTimestamp);
+ return result == null ? null : deserializeValue(result);
+ },
+ time,
+ fetchSensor
+ );
+ }
+
+ @Override
+ public WindowStoreIterator<V> fetch(final K key, final Instant
timeFrom, final Instant timeTo) {
+ Objects.requireNonNull(key, "key cannot be null");
+ return
meteredTimeRangeIterator(underlying.fetch(serializeKey(key), timeFrom, timeTo));
+ }
+
+ @Override
+ public WindowStoreIterator<V> backwardFetch(final K key, final Instant
timeFrom, final Instant timeTo) {
+ Objects.requireNonNull(key, "key cannot be null");
+ return
meteredTimeRangeIterator(underlying.backwardFetch(serializeKey(key), timeFrom,
timeTo));
+ }
+
+ @Override
+ public KeyValueIterator<Windowed<K>, V> fetch(final K keyFrom, final K
keyTo, final Instant timeFrom, final Instant timeTo) {
+ return
meteredWindowedIterator(underlying.fetch(serializeKey(keyFrom),
serializeKey(keyTo), timeFrom, timeTo));
+ }
+
+ @Override
+ public KeyValueIterator<Windowed<K>, V> backwardFetch(final K keyFrom,
final K keyTo, final Instant timeFrom, final Instant timeTo) {
Review Comment:
same here too and below
##########
streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredWindowStore.java:
##########
@@ -380,6 +332,70 @@ public KeyValueIterator<Windowed<K>, V> backwardAll() {
);
}
+ private final class ReadOnlyView implements ReadOnlyWindowStore<K, V> {
+
+ private final ReadOnlyWindowStore<Bytes, byte[]> underlying;
+
+ ReadOnlyView(final ReadOnlyWindowStore<Bytes, byte[]> underlying) {
+ this.underlying = underlying;
+ }
+
+ @Override
+ public V fetch(final K key, final long windowStartTimestamp) {
+ Objects.requireNonNull(key, "key cannot be null");
+ return maybeMeasureLatency(
+ () -> {
+ final byte[] result = underlying.fetch(serializeKey(key),
windowStartTimestamp);
+ return result == null ? null : deserializeValue(result);
+ },
+ time,
+ fetchSensor
+ );
+ }
+
+ @Override
+ public WindowStoreIterator<V> fetch(final K key, final Instant
timeFrom, final Instant timeTo) {
+ Objects.requireNonNull(key, "key cannot be null");
+ return
meteredTimeRangeIterator(underlying.fetch(serializeKey(key), timeFrom, timeTo));
+ }
+
+ @Override
+ public WindowStoreIterator<V> backwardFetch(final K key, final Instant
timeFrom, final Instant timeTo) {
Review Comment:
same
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]