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



##########
File path: 
streams/src/test/java/org/apache/kafka/streams/state/internals/CachingInMemoryKeyValueStoreTest.java
##########
@@ -359,6 +361,31 @@ public void shouldReverseIterateOverRange() {
         ), results);
     }
 
+    @Test
+    public void shouldGetRecordsWithPrefixKey() {
+        final List<KeyValue<Bytes, byte[]>> entries = new ArrayList<>();
+        entries.add(new KeyValue<>(bytesKey("k1"), bytesValue("1")));
+        entries.add(new KeyValue<>(bytesKey("k2"), bytesValue("2")));
+        entries.add(new KeyValue<>(bytesKey("p2"), bytesValue("2")));
+        entries.add(new KeyValue<>(bytesKey("p1"), bytesValue("2")));
+        entries.add(new KeyValue<>(bytesKey("p0"), bytesValue("2")));
+        store.putAll(entries);
+        final KeyValueIterator<Bytes, byte[]> keysWithPrefix = 
store.prefixScan("p", new StringSerializer());
+        final List<String> keys = new ArrayList<>();
+        final List<String> values = new ArrayList<>();
+        int numberOfKeysReturned = 0;
+
+        while (keysWithPrefix.hasNext()) {
+            final KeyValue<Bytes, byte[]> next = keysWithPrefix.next();
+            keys.add(next.key.toString());
+            values.add(new String(next.value));
+            numberOfKeysReturned++;
+        }
+        assertThat(numberOfKeysReturned, is(3));
+        assertThat(keys, is(Arrays.asList("p0", "p1", "p2")));
+        assertThat(values, is(Arrays.asList("2", "2", "2")));
+    }

Review comment:
       Sure Thanks https://issues.apache.org/jira/browse/KAFKA-10788




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