You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Jess668 (via GitHub)" <gi...@apache.org> on 2026/06/25 16:02:33 UTC
[PR] KAFKA-20741: Add ReadOnlyRecord IQv2 result type (KIP-1356) [kafka]
Jess668 opened a new pull request, #22677:
URL: https://github.com/apache/kafka/pull/22677
Introduce a read-only view of a record (key/value/timestamp/headers); Record implements it. Prerequisite for the KIP-1356 headers-aware IQv2 query types.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20741: Add ReadOnlyRecord IQv2 result type (KIP-1356) [kafka]
Posted by "aliehsaeedii (via GitHub)" <gi...@apache.org>.
aliehsaeedii commented on code in PR #22677:
URL: https://github.com/apache/kafka/pull/22677#discussion_r3490251662
##########
streams/src/main/java/org/apache/kafka/streams/processor/api/ReadOnlyRecord.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.streams.processor.api;
+
+import org.apache.kafka.common.header.Headers;
+
+/**
+ * A read-only view of a record's {@code key}, {@code value}, {@code timestamp}, and {@code headers}.
+ *
+ * <p>This is the shared read surface of a record: the processing-layer {@link Record} extends it with
+ * transform-and-forward builders ({@code withKey}/{@code withValue}/{@code withTimestamp}/{@code withHeaders}),
+ * while an Interactive Query (IQv2) result is exactly this read-only snapshot and exposes nothing more.
+ * It is the result type returned by the headers-aware IQv2 query types (e.g.
+ * {@code TimestampedKeyWithHeadersQuery}), which surface the record headers
+ * persisted by header-aware state stores.
+ *
+ * @param <K> The type of the key
+ * @param <V> The type of the value
+ */
+public interface ReadOnlyRecord<K, V> {
+
+ /**
+ * The key of the record. May be null.
+ */
+ K key();
+
+ /**
+ * The value of the record. May be null.
+ */
+ V value();
+
+ /**
+ * The timestamp of the record. Will never be negative.
+ */
+ long timestamp();
+
+ /**
+ * The headers of the record. Never null.
+ */
+ Headers headers();
Review Comment:
`headers()` is typed as `Headers`, which is mutable (`add`/`remove`). `Record.headers()` returns the live internal `RecordHeaders` reference, so for the IQv2 use case a caller could do `readOnlyRecord.headers().add(...)` and mutate whatever the store handed back — the "read-only" guarantee doesn't extend to the returned headers. `Record`'s class Javadoc already carries the caveat *"This class is immutable, though the objects referenced in the attributes of this class may themselves be mutable."* , we must return an unmodifiable view, so the read-only contract isn't oversold.
##########
streams/src/main/java/org/apache/kafka/streams/processor/api/ReadOnlyRecord.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.streams.processor.api;
+
+import org.apache.kafka.common.header.Headers;
+
+/**
+ * A read-only view of a record's {@code key}, {@code value}, {@code timestamp}, and {@code headers}.
+ *
+ * <p>This is the shared read surface of a record: the processing-layer {@link Record} extends it with
+ * transform-and-forward builders ({@code withKey}/{@code withValue}/{@code withTimestamp}/{@code withHeaders}),
+ * while an Interactive Query (IQv2) result is exactly this read-only snapshot and exposes nothing more.
+ * It is the result type returned by the headers-aware IQv2 query types (e.g.
+ * {@code TimestampedKeyWithHeadersQuery}), which surface the record headers
Review Comment:
This Javadoc names `TimestampedKeyWithHeadersQuery` as the result-type example, but that query type doesn't exist yet (it lands in a later KIP-1356 PR). Consider softening to "the headers-aware IQv2 query types without committing to a concrete class name until it exists. BTW, not a blocking comment as we know we will introduce these q types soon!
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20741: Add ReadOnlyRecord IQv2 result type (KIP-1356) [kafka]
Posted by "Jess668 (via GitHub)" <gi...@apache.org>.
Jess668 commented on code in PR #22677:
URL: https://github.com/apache/kafka/pull/22677#discussion_r3494367162
##########
streams/src/main/java/org/apache/kafka/streams/processor/api/ReadOnlyRecord.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.streams.processor.api;
+
+import org.apache.kafka.common.header.Headers;
+
+/**
+ * A read-only view of a record's {@code key}, {@code value}, {@code timestamp}, and {@code headers}.
+ *
+ * <p>This is the shared read surface of a record: the processing-layer {@link Record} extends it with
+ * transform-and-forward builders ({@code withKey}/{@code withValue}/{@code withTimestamp}/{@code withHeaders}),
+ * while an Interactive Query (IQv2) result is exactly this read-only snapshot and exposes nothing more.
+ * It is the result type returned by the headers-aware IQv2 query types (e.g.
+ * {@code TimestampedKeyWithHeadersQuery}), which surface the record headers
+ * persisted by header-aware state stores.
+ *
+ * @param <K> The type of the key
+ * @param <V> The type of the value
+ */
+public interface ReadOnlyRecord<K, V> {
+
+ /**
+ * The key of the record. May be null.
+ */
+ K key();
+
+ /**
+ * The value of the record. May be null.
+ */
+ V value();
+
+ /**
+ * The timestamp of the record. Will never be negative.
+ */
+ long timestamp();
+
+ /**
+ * The headers of the record. Never null.
+ */
+ Headers headers();
Review Comment:
A future increment could introduce `org.apache.kafka.common.header.ReadOnlyHeaders` and make `Headers extends ReadOnlyHeaders`. `ReadOnlyRecord.headers()` could then return `ReadOnlyHeaders`, giving compile-time read-only semantics, while `Record.headers()` keeps returning `Headers` via a covariant override (so PAPI is unaffected).
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20741: Add ReadOnlyRecord IQv2 result type (KIP-1356) [kafka]
Posted by "aliehsaeedii (via GitHub)" <gi...@apache.org>.
aliehsaeedii commented on code in PR #22677:
URL: https://github.com/apache/kafka/pull/22677#discussion_r3494310721
##########
streams/src/main/java/org/apache/kafka/streams/processor/api/ReadOnlyRecord.java:
##########
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.streams.processor.api;
+
+import org.apache.kafka.common.annotation.InterfaceStability.Evolving;
+import org.apache.kafka.common.header.Headers;
+
+/**
+ * A read-only view of a record's {@code key}, {@code value}, {@code timestamp}, and {@code headers}.
+ *
+ * <p>This is the shared read surface of a record: the processing-layer {@link Record} extends it with
+ * transform-and-forward builders ({@code withKey}/{@code withValue}/{@code withTimestamp}/{@code withHeaders}),
+ * while an Interactive Query (IQv2) result is exactly this read-only snapshot and exposes nothing more.
+ * It is the result type returned by the headers-aware IQv2 query types, which surface the record headers
+ * persisted by header-aware state stores.
+ *
+ * @param <K> The type of the key
+ * @param <V> The type of the value
+ */
+@Evolving
+public interface ReadOnlyRecord<K, V> {
+
+ /**
+ * The key of the record. May be null.
+ */
+ K key();
+
+ /**
+ * The value of the record. May be null.
+ */
+ V value();
+
+ /**
+ * The timestamp of the record. Will never be negative.
+ */
+ long timestamp();
+
+ /**
+ * The headers of the record. Never null.
+ *
+ * <p>The returned {@link Headers} is part of a read-only view and must not be mutated by
+ * callers.
+ *
+ * <p>TODO (KIP-1356 follow-up): once the IQv2 query types land, records served as IQv2
Review Comment:
could we remove this `todo` comment form the java doc and keep it as internal comment. Thanks.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20741: Add ReadOnlyRecord IQv2 result type (KIP-1356) [kafka]
Posted by "frankvicky (via GitHub)" <gi...@apache.org>.
frankvicky merged PR #22677:
URL: https://github.com/apache/kafka/pull/22677
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20741: Add ReadOnlyRecord IQv2 result type (KIP-1356) [kafka]
Posted by "Jess668 (via GitHub)" <gi...@apache.org>.
Jess668 commented on code in PR #22677:
URL: https://github.com/apache/kafka/pull/22677#discussion_r3492111849
##########
streams/src/main/java/org/apache/kafka/streams/processor/api/ReadOnlyRecord.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.streams.processor.api;
+
+import org.apache.kafka.common.header.Headers;
+
+/**
+ * A read-only view of a record's {@code key}, {@code value}, {@code timestamp}, and {@code headers}.
+ *
+ * <p>This is the shared read surface of a record: the processing-layer {@link Record} extends it with
+ * transform-and-forward builders ({@code withKey}/{@code withValue}/{@code withTimestamp}/{@code withHeaders}),
+ * while an Interactive Query (IQv2) result is exactly this read-only snapshot and exposes nothing more.
+ * It is the result type returned by the headers-aware IQv2 query types (e.g.
+ * {@code TimestampedKeyWithHeadersQuery}), which surface the record headers
+ * persisted by header-aware state stores.
+ *
+ * @param <K> The type of the key
+ * @param <V> The type of the value
+ */
+public interface ReadOnlyRecord<K, V> {
+
+ /**
+ * The key of the record. May be null.
+ */
+ K key();
+
+ /**
+ * The value of the record. May be null.
+ */
+ V value();
+
+ /**
+ * The timestamp of the record. Will never be negative.
+ */
+ long timestamp();
+
+ /**
+ * The headers of the record. Never null.
+ */
+ Headers headers();
Review Comment:
Agreed. For now I've tightened the `ReadOnlyRecord.headers()` javadoc to state the read-only contract. The actual "mutate whatever the store handed back" risk lives in the IQv2 producer path, which isn't in this PR yet. I'll enforce it there using `RecordHeaders.setReadOnly()` on the returned record's headers.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20741: Add ReadOnlyRecord IQv2 result type (KIP-1356) [kafka]
Posted by "aliehsaeedii (via GitHub)" <gi...@apache.org>.
aliehsaeedii commented on code in PR #22677:
URL: https://github.com/apache/kafka/pull/22677#discussion_r3481124304
##########
streams/src/test/java/org/apache/kafka/streams/processor/api/ReadOnlyRecordTest.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.streams.processor.api;
+
+import org.apache.kafka.common.header.Headers;
+import org.apache.kafka.common.header.internals.RecordHeader;
+import org.apache.kafka.common.header.internals.RecordHeaders;
+
+import org.junit.jupiter.api.Test;
+
+import java.nio.charset.StandardCharsets;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class ReadOnlyRecordTest {
+
+ private static Headers headers() {
+ return new RecordHeaders().add(new RecordHeader("k", "v".getBytes(StandardCharsets.UTF_8)));
+ }
+
+ @Test
+ public void recordShouldBeAssignableToReadOnlyRecordAndExposeSameAccessors() {
+ final Headers headers = headers();
+ final Record<String, String> record = new Record<>("key", "value", 123L, headers);
+
+ // The assignment itself proves Record is a ReadOnlyRecord (source/binary compatible change).
+ final ReadOnlyRecord<String, String> readOnly = record;
+
+ assertEquals(record.key(), readOnly.key());
+ assertEquals(record.value(), readOnly.value());
+ assertEquals(record.timestamp(), readOnly.timestamp());
+ assertEquals(record.headers(), readOnly.headers());
Review Comment:
These four assertions are tautological: `readOnly` is the *same object* as `record` (the assignment on line 41 is a reference, not a copy), so `record.key()` and `readOnly.key()` invoke the same method on the same instance and can never differ. They provide no signal about the read-only view. The meaningful checks are the literal-value assertions just below (lines 48-51), plus the fact that the assignment on line 41 compiles — that compile is what actually proves `Record` is a `ReadOnlyRecord`
##########
streams/src/test/java/org/apache/kafka/streams/processor/api/ReadOnlyRecordTest.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.streams.processor.api;
+
+import org.apache.kafka.common.header.Headers;
+import org.apache.kafka.common.header.internals.RecordHeader;
+import org.apache.kafka.common.header.internals.RecordHeaders;
+
+import org.junit.jupiter.api.Test;
+
+import java.nio.charset.StandardCharsets;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class ReadOnlyRecordTest {
+
+ private static Headers headers() {
+ return new RecordHeaders().add(new RecordHeader("k", "v".getBytes(StandardCharsets.UTF_8)));
+ }
+
+ @Test
+ public void recordShouldBeAssignableToReadOnlyRecordAndExposeSameAccessors() {
+ final Headers headers = headers();
+ final Record<String, String> record = new Record<>("key", "value", 123L, headers);
+
+ // The assignment itself proves Record is a ReadOnlyRecord (source/binary compatible change).
+ final ReadOnlyRecord<String, String> readOnly = record;
+
+ assertEquals(record.key(), readOnly.key());
+ assertEquals(record.value(), readOnly.value());
+ assertEquals(record.timestamp(), readOnly.timestamp());
+ assertEquals(record.headers(), readOnly.headers());
+
+ assertEquals("key", readOnly.key());
+ assertEquals("value", readOnly.value());
+ assertEquals(123L, readOnly.timestamp());
+ assertEquals(headers, readOnly.headers());
+ }
+
+ @Test
+ public void readOnlyHeadersShouldBeNonNullAndEmptyWhenConstructedWithoutHeaders() {
+ final ReadOnlyRecord<String, String> readOnly = new Record<>("key", "value", 123L);
+ assertEquals(new RecordHeaders(), readOnly.headers());
+ }
+
+ @Test
+ public void readOnlyAccessorsShouldTolerateNullKeyAndValue() {
+ final ReadOnlyRecord<String, String> readOnly = new Record<>(null, null, 0L);
+ assertEquals(null, readOnly.key());
+ assertEquals(null, readOnly.value());
Review Comment:
Minor: prefer `assertNull(readOnly.key())` / `assertNull(readOnly.value())` over `assertEquals(null, ...)` — it's the JUnit 5 idiom and reads more clearly.
##########
streams/src/main/java/org/apache/kafka/streams/processor/api/Record.java:
##########
@@ -35,7 +35,7 @@
* @param <K> The type of the key
* @param <V> The type of the value
*/
-public class Record<K, V> {
+public class Record<K, V> implements ReadOnlyRecord<K, V> {
Review Comment:
Now that `Record` implements `ReadOnlyRecord`, consider adding `@Override` to the four accessors (`key()`, `value()`, `timestamp()`, `headers()`). It documents that they satisfy the interface contract and lets the compiler catch any future signature drift between the two. Optional — this PR doesn't otherwise touch those methods.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20741: Add ReadOnlyRecord IQv2 result type (KIP-1356) [kafka]
Posted by "Jess668 (via GitHub)" <gi...@apache.org>.
Jess668 commented on code in PR #22677:
URL: https://github.com/apache/kafka/pull/22677#discussion_r3481777509
##########
streams/src/test/java/org/apache/kafka/streams/processor/api/ReadOnlyRecordTest.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.streams.processor.api;
+
+import org.apache.kafka.common.header.Headers;
+import org.apache.kafka.common.header.internals.RecordHeader;
+import org.apache.kafka.common.header.internals.RecordHeaders;
+
+import org.junit.jupiter.api.Test;
+
+import java.nio.charset.StandardCharsets;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class ReadOnlyRecordTest {
+
+ private static Headers headers() {
+ return new RecordHeaders().add(new RecordHeader("k", "v".getBytes(StandardCharsets.UTF_8)));
+ }
+
+ @Test
+ public void recordShouldBeAssignableToReadOnlyRecordAndExposeSameAccessors() {
+ final Headers headers = headers();
+ final Record<String, String> record = new Record<>("key", "value", 123L, headers);
+
+ // The assignment itself proves Record is a ReadOnlyRecord (source/binary compatible change).
+ final ReadOnlyRecord<String, String> readOnly = record;
+
+ assertEquals(record.key(), readOnly.key());
+ assertEquals(record.value(), readOnly.value());
+ assertEquals(record.timestamp(), readOnly.timestamp());
+ assertEquals(record.headers(), readOnly.headers());
Review Comment:
Removed the redundant block.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20741: Add ReadOnlyRecord IQv2 result type (KIP-1356) [kafka]
Posted by "aliehsaeedii (via GitHub)" <gi...@apache.org>.
aliehsaeedii commented on PR #22677:
URL: https://github.com/apache/kafka/pull/22677#issuecomment-4836600695
LGTM, thanks.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20741: Add ReadOnlyRecord IQv2 result type (KIP-1356) [kafka]
Posted by "aliehsaeedii (via GitHub)" <gi...@apache.org>.
aliehsaeedii commented on code in PR #22677:
URL: https://github.com/apache/kafka/pull/22677#discussion_r3493283733
##########
streams/src/main/java/org/apache/kafka/streams/processor/api/ReadOnlyRecord.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.streams.processor.api;
+
+import org.apache.kafka.common.header.Headers;
+
+/**
+ * A read-only view of a record's {@code key}, {@code value}, {@code timestamp}, and {@code headers}.
+ *
+ * <p>This is the shared read surface of a record: the processing-layer {@link Record} extends it with
+ * transform-and-forward builders ({@code withKey}/{@code withValue}/{@code withTimestamp}/{@code withHeaders}),
+ * while an Interactive Query (IQv2) result is exactly this read-only snapshot and exposes nothing more.
+ * It is the result type returned by the headers-aware IQv2 query types (e.g.
+ * {@code TimestampedKeyWithHeadersQuery}), which surface the record headers
+ * persisted by header-aware state stores.
+ *
+ * @param <K> The type of the key
+ * @param <V> The type of the value
+ */
+public interface ReadOnlyRecord<K, V> {
+
+ /**
+ * The key of the record. May be null.
+ */
+ K key();
+
+ /**
+ * The value of the record. May be null.
+ */
+ V value();
+
+ /**
+ * The timestamp of the record. Will never be negative.
+ */
+ long timestamp();
+
+ /**
+ * The headers of the record. Never null.
+ */
+ Headers headers();
Review Comment:
It likely protects the actual IQ result object from mutation, but it’s not ideal, since the “read-only” guarantee lives in javadoc + runtime behavior, not in the method signature.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20741: Add ReadOnlyRecord IQv2 result type (KIP-1356) [kafka]
Posted by "aliehsaeedii (via GitHub)" <gi...@apache.org>.
aliehsaeedii commented on code in PR #22677:
URL: https://github.com/apache/kafka/pull/22677#discussion_r3498369792
##########
streams/src/main/java/org/apache/kafka/streams/processor/api/ReadOnlyRecord.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.streams.processor.api;
+
+import org.apache.kafka.common.header.Headers;
+
+/**
+ * A read-only view of a record's {@code key}, {@code value}, {@code timestamp}, and {@code headers}.
+ *
+ * <p>This is the shared read surface of a record: the processing-layer {@link Record} extends it with
+ * transform-and-forward builders ({@code withKey}/{@code withValue}/{@code withTimestamp}/{@code withHeaders}),
+ * while an Interactive Query (IQv2) result is exactly this read-only snapshot and exposes nothing more.
+ * It is the result type returned by the headers-aware IQv2 query types (e.g.
+ * {@code TimestampedKeyWithHeadersQuery}), which surface the record headers
+ * persisted by header-aware state stores.
+ *
+ * @param <K> The type of the key
+ * @param <V> The type of the value
+ */
+public interface ReadOnlyRecord<K, V> {
+
+ /**
+ * The key of the record. May be null.
+ */
+ K key();
+
+ /**
+ * The value of the record. May be null.
+ */
+ V value();
+
+ /**
+ * The timestamp of the record. Will never be negative.
+ */
+ long timestamp();
+
+ /**
+ * The headers of the record. Never null.
+ */
+ Headers headers();
Review Comment:
@Jess668 I thought we agreed on `RecordHeaders.setReadOnly()` idea
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20741: Add ReadOnlyRecord IQv2 result type (KIP-1356) [kafka]
Posted by "Jess668 (via GitHub)" <gi...@apache.org>.
Jess668 commented on code in PR #22677:
URL: https://github.com/apache/kafka/pull/22677#discussion_r3498394953
##########
streams/src/main/java/org/apache/kafka/streams/processor/api/ReadOnlyRecord.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.streams.processor.api;
+
+import org.apache.kafka.common.header.Headers;
+
+/**
+ * A read-only view of a record's {@code key}, {@code value}, {@code timestamp}, and {@code headers}.
+ *
+ * <p>This is the shared read surface of a record: the processing-layer {@link Record} extends it with
+ * transform-and-forward builders ({@code withKey}/{@code withValue}/{@code withTimestamp}/{@code withHeaders}),
+ * while an Interactive Query (IQv2) result is exactly this read-only snapshot and exposes nothing more.
+ * It is the result type returned by the headers-aware IQv2 query types (e.g.
+ * {@code TimestampedKeyWithHeadersQuery}), which surface the record headers
+ * persisted by header-aware state stores.
+ *
+ * @param <K> The type of the key
+ * @param <V> The type of the value
+ */
+public interface ReadOnlyRecord<K, V> {
+
+ /**
+ * The key of the record. May be null.
+ */
+ K key();
+
+ /**
+ * The value of the record. May be null.
+ */
+ V value();
+
+ /**
+ * The timestamp of the record. Will never be negative.
+ */
+ long timestamp();
+
+ /**
+ * The headers of the record. Never null.
+ */
+ Headers headers();
Review Comment:
@aliehsaeedii Sorry, I didn’t make that clear. For the scope of KIP-1356, we would use `RecordHeaders.setReadOnly()`. `ReadOnlyHeaders` would be a possible follow-up in a future PR or KIP.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org