yihua commented on code in PR #18224:
URL: https://github.com/apache/hudi/pull/18224#discussion_r2850126063


##########
hudi-utilities/pom.xml:
##########
@@ -533,6 +538,24 @@
       <artifactId>sqs</artifactId>
       <version>${aws.sdk.version}</version>
     </dependency>
+    <dependency>
+      <groupId>software.amazon.awssdk</groupId>
+      <artifactId>kinesis</artifactId>
+      <version>${aws.sdk.version}</version>
+    </dependency>
+    <!-- KPL de-aggregation: extracts user records from Kinesis Producer 
Library aggregated records -->
+    <dependency>
+      <groupId>com.amazonaws</groupId>
+      <artifactId>amazon-kinesis-deaggregator</artifactId>
+      <version>1.0.3</version>
+    </dependency>
+    <!-- KPL aggregation: for creating aggregated records in tests -->
+    <dependency>
+      <groupId>com.amazonaws</groupId>
+      <artifactId>amazon-kinesis-aggregator</artifactId>
+      <version>1.0.3</version>

Review Comment:
   Add `aws.kinesis.version`



##########
hudi-utilities/src/main/java/org/apache/hudi/utilities/sources/KinesisSource.java:
##########
@@ -0,0 +1,114 @@
+/*
+ * 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.hudi.utilities.sources;
+
+import org.apache.hudi.common.config.TypedProperties;
+import org.apache.hudi.common.table.checkpoint.Checkpoint;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.utilities.config.KinesisSourceConfig;
+import org.apache.hudi.utilities.ingestion.HoodieIngestionMetrics;
+import org.apache.hudi.utilities.schema.SchemaProvider;
+import org.apache.hudi.utilities.sources.helpers.KinesisOffsetGen;
+import org.apache.hudi.utilities.streamer.StreamContext;
+
+import lombok.extern.slf4j.Slf4j;
+import org.apache.spark.api.java.JavaSparkContext;
+import org.apache.spark.sql.SparkSession;
+
+import java.util.Arrays;
+import java.util.Map;
+
+import static org.apache.hudi.common.util.ConfigUtils.getBooleanWithAltKeys;
+
+@Slf4j
+public abstract class KinesisSource<T> extends Source<T> {
+
+  protected static final String METRIC_NAME_KINESIS_MESSAGE_IN_COUNT = 
"kinesisMessageInCount";
+
+  protected final HoodieIngestionMetrics metrics;
+  protected final SchemaProvider schemaProvider;
+  protected KinesisOffsetGen offsetGen;
+  protected final boolean shouldAddOffsets;
+  /** Checkpoint data (shardId -> sequenceNumber) collected during toBatch 
execution. Set by subclasses. */
+  protected Map<String, String> lastCheckpointData;
+
+  protected KinesisSource(TypedProperties props, JavaSparkContext 
sparkContext, SparkSession sparkSession,
+                          SourceType sourceType, HoodieIngestionMetrics 
metrics, StreamContext streamContext) {
+    super(props, sparkContext, sparkSession, sourceType, streamContext);
+    this.schemaProvider = streamContext.getSchemaProvider();
+    this.metrics = metrics;
+    this.shouldAddOffsets = getBooleanWithAltKeys(props, 
KinesisSourceConfig.KINESIS_APPEND_OFFSETS);
+  }
+
+  @Override
+  protected final InputBatch<T> fetchNewData(Option<String> lastCkptStr, long 
sourceLimit) {
+    throw new UnsupportedOperationException("KinesisSource#fetchNewData should 
not be called");
+  }
+
+  @Override
+  protected InputBatch<T> readFromCheckpoint(Option<Checkpoint> 
lastCheckpoint, long sourceLimit) {
+    KinesisOffsetGen.KinesisShardRange[] shardRanges = 
offsetGen.getNextShardRanges(
+        lastCheckpoint, sourceLimit, metrics);

Review Comment:
   For all the methods handling shard ranges, could you use 
`List<KinesisOffsetGen.KinesisShardRange>` instead of array so it's easier to 
read?



-- 
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]

Reply via email to