bbejeck commented on code in PR #21768:
URL: https://github.com/apache/kafka/pull/21768#discussion_r2943685661


##########
streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedKeyValueStoreWithHeaders.java:
##########
@@ -125,14 +138,42 @@ public ValueTimestampHeaders<V> putIfAbsent(final K key,
         Objects.requireNonNull(key, "key cannot be null");
         final Headers headers = value != null ? value.headers() : new 
RecordHeaders();
         final ValueTimestampHeaders<V> currentValue = maybeMeasureLatency(
-            () -> deserializeValue(wrapped().putIfAbsent(keyBytes(key, 
headers), serdes.rawValue(value, headers))),
+            // `rawOldValue` returned from `wrapped().putIfAbsent(...)` is 
type ValueTimestampHeader
+            // -> no need to pass in Headers into `deserializeValue()`
+            () -> deserializeValue(wrapped().putIfAbsent(serializeKey(key, 
headers), serdes.rawValue(value, headers))),
             time,
             putIfAbsentSensor
         );
         maybeRecordE2ELatency();
         return currentValue;
     }
 
+    @Override
+    public void putAll(final List<KeyValue<K, ValueTimestampHeaders<V>>> 
entries) {
+        entries.forEach(entry -> Objects.requireNonNull(entry.key, "key cannot 
be null"));
+        maybeMeasureLatency(() -> wrapped().putAll(innerEntries(entries)), 
time, putAllSensor);
+    }
+
+    private List<KeyValue<Bytes, byte[]>> innerEntries(final List<KeyValue<K, 
ValueTimestampHeaders<V>>> from) {
+        final List<KeyValue<Bytes, byte[]>> byteEntries = new ArrayList<>();
+        for (final KeyValue<K, ValueTimestampHeaders<V>> entry : from) {
+            final Headers headers = entry.value != null ? 
entry.value.headers() : new RecordHeaders();
+            byteEntries.add(KeyValue.pair(serializeKey(entry.key, headers), 
serializeValue(entry.value)));
+        }
+        return byteEntries;
+    }
+
+    @Override
+    public ValueTimestampHeaders<V> delete(final K key) {
+        Objects.requireNonNull(key, "key cannot be null");
+        try {
+            return maybeMeasureLatency(() -> 
deserializeValue(wrapped().delete(serializeKey(key, new RecordHeaders()))), 
time, deleteSensor);

Review Comment:
   I think we need to update `new RecordHeaders()` to `context.headers()` here 
and below based on comments up to this point.



##########
streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedKeyValueStoreWithHeaders.java:
##########
@@ -125,14 +138,42 @@ public ValueTimestampHeaders<V> putIfAbsent(final K key,
         Objects.requireNonNull(key, "key cannot be null");
         final Headers headers = value != null ? value.headers() : new 
RecordHeaders();
         final ValueTimestampHeaders<V> currentValue = maybeMeasureLatency(
-            () -> deserializeValue(wrapped().putIfAbsent(keyBytes(key, 
headers), serdes.rawValue(value, headers))),
+            // `rawOldValue` returned from `wrapped().putIfAbsent(...)` is 
type ValueTimestampHeader
+            // -> no need to pass in Headers into `deserializeValue()`
+            () -> deserializeValue(wrapped().putIfAbsent(serializeKey(key, 
headers), serdes.rawValue(value, headers))),
             time,
             putIfAbsentSensor
         );
         maybeRecordE2ELatency();
         return currentValue;
     }
 
+    @Override
+    public void putAll(final List<KeyValue<K, ValueTimestampHeaders<V>>> 
entries) {
+        entries.forEach(entry -> Objects.requireNonNull(entry.key, "key cannot 
be null"));
+        maybeMeasureLatency(() -> wrapped().putAll(innerEntries(entries)), 
time, putAllSensor);
+    }
+
+    private List<KeyValue<Bytes, byte[]>> innerEntries(final List<KeyValue<K, 
ValueTimestampHeaders<V>>> from) {
+        final List<KeyValue<Bytes, byte[]>> byteEntries = new ArrayList<>();
+        for (final KeyValue<K, ValueTimestampHeaders<V>> entry : from) {
+            final Headers headers = entry.value != null ? 
entry.value.headers() : new RecordHeaders();
+            byteEntries.add(KeyValue.pair(serializeKey(entry.key, headers), 
serializeValue(entry.value)));

Review Comment:
   This is different from `put` -> `wrapped().put(serializeKey(key, headers), 
serdes.rawValue(value, headers))`
   
   But here it does `serializeValue(entry.value)` shouldn't this use the same 
as put?



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