aliehsaeedii commented on code in PR #22770: URL: https://github.com/apache/kafka/pull/22770#discussion_r3532280347
########## streams/src/main/java/org/apache/kafka/streams/query/TimestampedRangeWithHeadersQuery.java: ########## @@ -0,0 +1,154 @@ +/* + * 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.query; + +import org.apache.kafka.common.annotation.InterfaceStability.Evolving; +import org.apache.kafka.streams.processor.api.ReadOnlyRecord; +import org.apache.kafka.streams.state.ReadOnlyRecordIterator; +import org.apache.kafka.streams.state.TimestampedKeyValueStoreWithHeaders; + +import java.util.Optional; + +/** + * Interactive query for issuing range queries and scans over a + * {@link TimestampedKeyValueStoreWithHeaders}, returning each record together with its headers. + * + * <p>This is the headers-aware parallel of {@link TimestampedRangeQuery}: it returns a + * {@link ReadOnlyRecordIterator} of {@link ReadOnlyRecord} elements, each carrying the key, value, + * timestamp, and headers, whereas {@link TimestampedRangeQuery} returns a + * {@link org.apache.kafka.streams.state.KeyValueIterator} of + * {@link org.apache.kafka.streams.state.ValueAndTimestamp} (value and timestamp only, no headers). + * + * <p>A range query retrieves a set of records, specified using an upper and/or lower bound on the + * keys. A scan query (no bounds) retrieves all records contained in the store. Keys' order is based + * on the serialized {@code byte[]} of the keys, not the 'logical' key order. + * + * <p>Headers are persisted and returned only when the store is backed by a native headers store, + * i.e. built with a KIP-1271 {@code WithHeaders} byte-store supplier (e.g. + * {@code Stores.persistentTimestampedKeyValueStoreWithHeaders}). A {@code WithHeaders} store built + * over a legacy (non-headers) supplier cannot persist headers, so the store-served reads come back + * with empty {@code headers()}. + * + * <p>Against a plain store not built with the {@code WithHeaders} builder at all, this query type is + * unsupported and fails with {@link FailureReason#UNKNOWN_QUERY_TYPE}. + * + * <p>Each element is a {@link ReadOnlyRecord}, whose timestamp is non-negative. If the backing store + * does not persist timestamps -- for example a {@code WithHeaders} store built over a plain + * {@link org.apache.kafka.streams.state.KeyValueStore} supplier, which surfaces every entry with + * {@code NO_TIMESTAMP} ({@code -1}) -- that entry cannot be represented, so advancing the returned + * {@link ReadOnlyRecordIterator} throws {@link org.apache.kafka.streams.errors.StreamsException} at + * that entry. Back the store with {@code Stores.persistentTimestampedKeyValueStoreWithHeaders(...)} to + * persist timestamps and headers, or use {@link TimestampedRangeQuery} if headers are not needed. + * + * @param <K> Type of keys + * @param <V> Type of values + */ +@Evolving +public final class TimestampedRangeWithHeadersQuery<K, V> implements Query<ReadOnlyRecordIterator<K, V>> { Review Comment: This class is annotated only with `@Evolving`, but every sibling IQv2 query type is also marked `@InterfaceAudience.Public` — `TimestampedRangeQuery`, `TimestampedKeyQuery`, `RangeQuery`, `KeyQuery`, and the parallel `TimestampedKeyWithHeadersQuery` added in this stack all carry `@InterfaceAudience.Public` alongside `@Evolving`. This is a public IQv2 query type in the `query` package, so it looks like the `@InterfaceAudience.Public` annotation (and its import) was omitted here by accident. Add it for consistency. -- 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]
