You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/11/30 10:22:02 UTC

[GitHub] [kafka] patrickstuedi commented on a change in pull request #11541: chore: keeping track of latest seen position in different state stores

patrickstuedi commented on a change in pull request #11541:
URL: https://github.com/apache/kafka/pull/11541#discussion_r759132217



##########
File path: streams/src/main/java/org/apache/kafka/streams/state/internals/InMemoryWindowStore.java
##########
@@ -131,6 +149,11 @@ public void put(final Bytes key, final byte[] value, final long windowStartTimes
                 });
             }
         }
+
+        if (stateStoreContext != null && stateStoreContext.recordMetadata().isPresent()) {

Review comment:
       Optimistically updating position. Position makes sure we never move back. Or should we move this into the "value != null" case? 

##########
File path: streams/src/test/java/org/apache/kafka/streams/state/internals/InMemorySessionStoreTest.java
##########
@@ -83,4 +88,31 @@ public void shouldNotExpireFromOpenIterator() {
         assertFalse(sessionStore.findSessions("a", "b", 0L, 20L).hasNext());
     }
 
+    @Test
+    public void shouldMatchPositionAfterPut() {
+
+        final List<KeyValue<Windowed<String>, Long>> entries = new ArrayList<>();
+        entries.add(new KeyValue<>(new Windowed<String>("a", new SessionWindow(0, 0)), 1L));
+        entries.add(new KeyValue<>(new Windowed<String>("aa", new SessionWindow(0, 10)), 2L));
+        entries.add(new KeyValue<>(new Windowed<String>("a", new SessionWindow(10, 20)), 3L));
+
+        final MonotonicProcessorRecordContext recordContext = new MonotonicProcessorRecordContext("input", 0);
+        context.setRecordContext(recordContext);
+
+        final Position expected = Position.emptyPosition();
+        long offset = 0;
+        for (final KeyValue<Windowed<String>, Long> k : entries) {
+            sessionStore.put(k.key, k.value);
+            expected.update("input", 0, offset);
+            offset++;
+        }
+
+        final MeteredSessionStore<String, Long> meteredSessionStore = (MeteredSessionStore<String, Long>) sessionStore;

Review comment:
       This is not nice. One way to fix this would be to add getPosition() to the StateStore interface.




-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org