navina commented on code in PR #9713: URL: https://github.com/apache/pinot/pull/9713#discussion_r1191568164
########## pinot-plugins/pinot-stream-ingestion/pinot-kinesis/src/main/java/org/apache/pinot/plugin/stream/kinesis/KinesisMetadataExtractor.java: ########## @@ -0,0 +1,44 @@ +/** + * 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.plugin.stream.kinesis; + +import java.util.HashMap; +import java.util.Map; +import org.apache.pinot.spi.stream.RowMetadata; +import software.amazon.awssdk.services.kinesis.model.Record; + +// TODO: Make this an interface/api in the stream spis st StreamMessageMetadata extract(T streamTypeRecord) + +public interface KinesisMetadataExtractor { + static KinesisMetadataExtractor build(boolean populateMetadata) { + return record -> { + long recordTimestamp = record.approximateArrivalTimestamp().toEpochMilli(); + Map<String, String> metadataMap = new HashMap<>(); + metadataMap.put(KinesisStreamMessageMetadata.APPRX_ARRIVAL_TIMESTAMP_KEY, String.valueOf(recordTimestamp)); + if (!populateMetadata) { Review Comment: > why are we putting recordTimestamp as a top level param and also putting it in the metadata map? iirc, this was for backwards compatibility. recordTimestamp was already there when I introduced the StreamMessageMetadata interface. We don't **have** to put it in the metadata map as well. I think the difference is that in the metadata map, key name is more directly related to the incoming stream's record timestamp field instead of calling it "recordTimestamp". > why put it in the map even when the flag is false? lol. good question. This is how the code in `KafkaMetadataExtractor` is and I am guessing I just copied over the logic without thinking much about this config. I am curious why it was implemented this way. I think we can fix forward for both kinesis and kafka . wdyt? -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
