vamossagar12 commented on a change in pull request #10052:
URL: https://github.com/apache/kafka/pull/10052#discussion_r575374620



##########
File path: 
streams/src/test/java/org/apache/kafka/streams/state/internals/InMemoryKeyValueStoreTest.java
##########
@@ -60,4 +67,22 @@ public void shouldRemoveKeysWithNullValues() {
 
         assertThat(store.get(0), nullValue());
     }
+
+
+    @Test
+    public void shouldReturnKeysWithGivenPrefix(){
+        store = createKeyValueStore(driver.context());
+        final String value = "value";
+        final List<KeyValue<Integer, String>> entries = new ArrayList<>();
+        entries.add(new KeyValue<>(1, value));
+        entries.add(new KeyValue<>(2, value));
+        entries.add(new KeyValue<>(11, value));
+        entries.add(new KeyValue<>(13, value));
+
+        store.putAll(entries);
+        final KeyValueIterator<Integer, String> keysWithPrefix = 
store.prefixScan(1, new IntegerSerializer());

Review comment:
       @cadonna , I was thinking about this today and the question that I have 
is what exactly does a prefix scan mean for numeric keys. For the way we have 
implemented, it will work even for numeric keys if we can retrieve the keys in 
Lexicographical manner. 
   So, if the prefix is `1` and post increment, it becomes `2`, then the range 
in which I need to search becomes (1,2]. If my map has 1,2,11,13 then I should 
be able to fetch 1,11,13 as those come before 2 lexicographically. But when I 
test the underlying map from my test case, it returns 1,2,11,13 and that is why 
the range is failing. 
   
   
   I guess the real problem lies in the fact that in InMemoryKeyValueStoreTest, 
the KeyValueStore defined uses Integer as the key. But if somebody creates a 
store with integer keys and tries to call the prefixScan API, then it might 
fail. WDYT?




----------------------------------------------------------------
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.

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


Reply via email to