KAFKA-20155: Implement lazy header deserialization for state stores#21996
KAFKA-20155: Implement lazy header deserialization for state stores#21996Shekharrajak wants to merge 4 commits intoapache:trunkfrom
Conversation
UladzislauBlok
left a comment
There was a problem hiding this comment.
Sorry to said that (correct me if I'm wrong), but that looks like absolute vibe code
I think this ticket was blocked by https://issues.apache.org/jira/browse/KAFKA-20179 . It doesn't make sense to just create this class without taking into account how this will be used
streams/src/main/java/org/apache/kafka/streams/state/internals/LazyHeaders.java
Show resolved
Hide resolved
streams/src/main/java/org/apache/kafka/streams/state/internals/LazyHeaders.java
Outdated
Show resolved
Hide resolved
streams/src/main/java/org/apache/kafka/streams/state/internals/LazyHeaders.java
Outdated
Show resolved
Hide resolved
streams/src/main/java/org/apache/kafka/streams/state/internals/LazyHeaders.java
Outdated
Show resolved
Hide resolved
| private static boolean headersEqual(final Headers a, final Headers b) { | ||
| if (a == b) return true; | ||
| if (a == null || b == null) return false; | ||
| return Arrays.equals(a.toArray(), b.toArray()); |
There was a problem hiding this comment.
RecordHeaders.equals have getClass() != o.getClass() because of that tests were failing for RecordHeaders.equals(LazyHeaders) so we need to handle that.
|
@UladzislauBlok The Lazy Header idea is discussed in the ticket. The logic behind this design is - do not parse ( |
The problem with producer is still here. You just moved deserialization to later steps |
Eliminating the producer-side parse entirely would require changing the producer API to accept raw header bytes instead of Header[], which is: Out of scope for KIP-1271 and Would require a KIP of its own. |
|
@muralibasani feel free to cherry pick commits or commit to this branch, since you already working around KAFKA-20179 - which I missed seeing in ticket. |
Ref https://issues.apache.org/jira/browse/KAFKA-20155
When reading from header-aware state stores (KIP-1271), header bytes embedded in store values are eagerly deserialized into RecordHeaders even when the downstream value deserializer does not use them. This PR introduces LazyHeaders -- a lazy Headers implementation that defers parsing until first read access, avoiding unnecessary work in header-agnostic deserialization paths.
Changes:
ValueTimestampHeadersDeserializer.deserialize() -- calls HeadersDeserializer.deserialize(rawHeaders) and passes the result to the value deserializer
Utils.readHeaders() -- called by AggregationWithHeadersDeserializer for session store reads