navina commented on code in PR #9224: URL: https://github.com/apache/pinot/pull/9224#discussion_r971763327
########## pinot-spi/src/main/java/org/apache/pinot/spi/stream/StreamDataDecoderImpl.java: ########## @@ -0,0 +1,65 @@ +/** + * 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.pinot.spi.stream; + +import java.util.Map; +import org.apache.pinot.spi.data.readers.GenericRow; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public class StreamDataDecoderImpl implements StreamDataDecoder { + private static final String KEY = "__key"; + private static final String HEADER_KEY_PREFIX = "header$"; + private static final Logger LOGGER = LoggerFactory.getLogger(StreamDataDecoderImpl.class); + + private final StreamMessageDecoder _valueDecoder; + + // Maybe simplify by allowing only string keys ? + public StreamDataDecoderImpl(StreamMessageDecoder valueDecoder) { + _valueDecoder = valueDecoder; + } + + @Override + public StreamDataDecoderResult decode(StreamMessage message) { + assert message.getValue() != null; + + try { + GenericRow row = _valueDecoder.decode(message.getValue(), 0, message.getValue().length, new GenericRow()); + if (row != null) { + if (message.getKey() != null) { + row.putValue(KEY, message.getKey()); + } + RowMetadata metadata = message.getMetadata(); Review Comment: the metadata and other parts are already extracted when the consumer returns results for `fetchMessages` . This decoder decodes/deserializes each part of the `StreamMessage` , namely, key, value, metadata and headers, and adds it into a single`GenericRow` object that will be passed down through the transformers. -- 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: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org