frankvicky commented on code in PR #21408: URL: https://github.com/apache/kafka/pull/21408#discussion_r2786927780
########## streams/src/main/java/org/apache/kafka/streams/state/internals/ValueTimestampHeadersSerializer.java: ########## @@ -0,0 +1,128 @@ +/* + * 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.state.internals; + +import org.apache.kafka.common.errors.SerializationException; +import org.apache.kafka.common.header.Headers; +import org.apache.kafka.common.serialization.LongSerializer; +import org.apache.kafka.common.serialization.Serializer; +import org.apache.kafka.common.utils.ByteUtils; +import org.apache.kafka.streams.kstream.internals.WrappingNullableSerializer; +import org.apache.kafka.streams.processor.internals.SerdeGetter; +import org.apache.kafka.streams.state.ValueTimestampHeaders; + +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Map; +import java.util.Objects; + +import static org.apache.kafka.streams.kstream.internals.WrappingNullableUtils.initNullableSerializer; + +/** + * Serializer for ValueTimestampHeaders. + * + * Serialization format (per KIP-1271): + * [headersSize(varint)][headersBytes][timestamp(8)][value] + * + * Where: + * - headersSize: Size of the headersBytes section in bytes, encoded as varint + * - headersBytes: + * - For null/empty headers: headersSize = 0, headersBytes is omitted (0 bytes) + * - For non-empty headers: headersSize > 0, serialized headers ([count(varint)][header1][header2]...) from HeadersSerializer + * - timestamp: 8-byte long timestamp + * - value: Serialized value using the provided value serializer + * + * This is used by KIP-1271 to serialize values with timestamps and headers for state stores. + */ +public class ValueTimestampHeadersSerializer<V> implements WrappingNullableSerializer<ValueTimestampHeaders<V>, Void, V> { + public final Serializer<V> valueSerializer; + private final Serializer<Long> timestampSerializer; Review Comment: Totally forget we have it 🤣 -- 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]
