Skip to content

KAFKA-20132: Implement TimestampedKeyValueStoreWithHeaders (4/N)#21454

Merged
frankvicky merged 7 commits intoapache:trunkfrom
aliehsaeedii:changelogging
Feb 18, 2026
Merged

KAFKA-20132: Implement TimestampedKeyValueStoreWithHeaders (4/N)#21454
frankvicky merged 7 commits intoapache:trunkfrom
aliehsaeedii:changelogging

Conversation

@aliehsaeedii
Copy link
Contributor

@aliehsaeedii aliehsaeedii commented Feb 11, 2026

This PR implements the changelogging layer of the
TimestampedKeyValueStoreWithHeaders introduced in KIP-1271.

Reviewers: TengYao Chi frankvicky@apache.org, Matthias J. Sax
matthias@confluent.io

Copy link
Contributor

@frankvicky frankvicky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM

assertEquals(hi, collector.collected().get(0).key());
assertArrayEquals(there.value(), (byte[]) collector.collected().get(0).value());
assertEquals(97L, collector.collected().get(0).timestamp());
Headers headers0 = collector.collected().get(0).headers();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final

assertEquals(hi, collector.collected().get(0).key());
assertArrayEquals(there.value(), (byte[]) collector.collected().get(0).value());
assertEquals(97L, collector.collected().get(0).timestamp());
Headers headers0 = collector.collected().get(0).headers();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final

assertEquals(hello, collector.collected().get(1).key());
assertArrayEquals(world.value(), (byte[]) collector.collected().get(1).value());
assertEquals(98L, collector.collected().get(1).timestamp());
Headers headers1 = collector.collected().get(1).headers();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final

assertArrayEquals(there.value(), (byte[]) collector.collected().get(0).value());
assertEquals(97L, collector.collected().get(0).timestamp());

Headers headers = collector.collected().get(0).headers();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final

assertEquals(hi, collector.collected().get(0).key());
assertArrayEquals(there.value(), (byte[]) collector.collected().get(0).value());
assertEquals(97L, collector.collected().get(0).timestamp());
Headers headers0 = collector.collected().get(0).headers();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final

@mjsax mjsax added kip Requires or implements a KIP ci-approved and removed triage PRs from the community labels Feb 12, 2026
/**
* Extract raw value from serialized ValueTimestampHeaders.
*/
static byte[] rawValue(final byte[] rawValueTimestampHeaders) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have static <T> T value(...) above -- given that we need rawValue here, wondering if value(...) from above is actually needed or not at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that method returns the deserialized value while raawValue returns a byte[]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I am not questioning that we add rawValue in this PR, I am asking why did we add value(...) in a previous PR, and when would we use it?

But it's somewhat unrelated to this PR, and it's only internal code here. So we could remove value(...) if unused also at some point in the future. Was just wondering.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove it at some point if not needed: https://issues.apache.org/jira/browse/KAFKA-20193

}
}

void log(final Bytes key, final byte[] value, final long timestamp, final Headers headers) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we just extend InternalProcessorContext.log(...) with a new Headers parameter and not add a new overload, and update all existing code accordingly, I believe we can remove the method and reuse the existing one from ChangeLoggingKeyValueBytesStore

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a very big change. It will chnage many tests.

/**
* Extract raw value from serialized ValueTimestampHeaders.
*/
static byte[] rawValue(final byte[] rawValueTimestampHeaders) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I am not questioning that we add rawValue in this PR, I am asking why did we add value(...) in a previous PR, and when would we use it?

But it's somewhat unrelated to this PR, and it's only internal code here. So we could remove value(...) if unused also at some point in the future. Was just wondering.

@mjsax
Copy link
Member

mjsax commented Feb 15, 2026

Failing unit test. Needs a fix.

valueTimestampHeaders == null
? internalContext.recordContext().timestamp()
: timestamp(valueTimestampHeaders),
headers(valueTimestampHeaders)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think we need to do the same as for ts, and use internalContext.recordContext().headers() if valueTimestampHeaders is null.

Copy link
Contributor

@frankvicky frankvicky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the PR.

@frankvicky frankvicky merged commit 85c6313 into apache:trunk Feb 18, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-approved kip Requires or implements a KIP streams

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants