nicktelford commented on code in PR #22681:
URL: https://github.com/apache/kafka/pull/22681#discussion_r3499742617


##########
streams/src/main/java/org/apache/kafka/streams/state/internals/InMemoryKeyValueStore.java:
##########
@@ -267,6 +270,104 @@ public long approximateNumEntries() {
         return map.size();
     }
 
+    @Override
+    public ReadOnlyKeyValueStore<Bytes, byte[]> readOnly(final IsolationLevel 
isolationLevel) {
+        Objects.requireNonNull(isolationLevel, "isolationLevel cannot be 
null");
+        final boolean consultBuffer = isolationLevel == 
IsolationLevel.READ_UNCOMMITTED;
+        return new ReadOnlyView(consultBuffer);
+    }
+
+    /**
+     * Read-only view of this store bound to an isolation level. When {@code 
consultBuffer}
+     * is true, reads go through the transaction buffer if present 
(READ_UNCOMMITTED);
+     * otherwise they read the base {@code map} directly (READ_COMMITTED, or 
any level when
+     * the store is non-transactional).
+     */
+    private final class ReadOnlyView implements ReadOnlyKeyValueStore<Bytes, 
byte[]> {
+
+        private final boolean consultBuffer;
+
+        ReadOnlyView(final boolean consultBuffer) {
+            this.consultBuffer = consultBuffer;
+        }
+
+        @Override
+        public byte[] get(final Bytes key) {
+            Objects.requireNonNull(key, "key cannot be null");
+            synchronized (InMemoryKeyValueStore.this) {

Review Comment:
   This actually touched on a pretty major drift from the previous branches, 
which had been heavily modified before being merged.
   
   I've addressed this with a partial re-write and amended the commit.



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

Reply via email to