aalexandrov commented on a change in pull request #13770:
URL: https://github.com/apache/flink/pull/13770#discussion_r517280149



##########
File path: 
flink-connectors/flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/table/KinesisDynamicSource.java
##########
@@ -0,0 +1,223 @@
+/*
+ * 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.flink.streaming.connectors.kinesis.table;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.api.common.serialization.DeserializationSchema;
+import org.apache.flink.streaming.connectors.kinesis.FlinkKinesisConsumer;
+import 
org.apache.flink.streaming.connectors.kinesis.serialization.KinesisDeserializationSchema;
+import 
org.apache.flink.streaming.connectors.kinesis.serialization.KinesisDeserializationSchemaWrapper;
+import org.apache.flink.table.connector.ChangelogMode;
+import org.apache.flink.table.connector.format.DecodingFormat;
+import org.apache.flink.table.connector.source.DynamicTableSource;
+import org.apache.flink.table.connector.source.ScanTableSource;
+import org.apache.flink.table.connector.source.SourceFunctionProvider;
+import 
org.apache.flink.table.connector.source.abilities.SupportsReadingMetadata;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.types.DataType;
+import org.apache.flink.util.Preconditions;
+
+import javax.annotation.Nullable;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Properties;
+import java.util.stream.Collectors;
+
+import static 
org.apache.flink.streaming.connectors.kinesis.table.RowDataKinesisDeserializationSchema.Metadata;
+
+/**
+ * Kinesis-backed {@link ScanTableSource}.
+ */
+@Internal
+public class KinesisDynamicSource implements ScanTableSource, 
SupportsReadingMetadata {
+
+       /** List of read-only metadata fields that the source can provide 
upstream upon request. */
+       private static final Map<String, DataType> READABLE_METADATA =
+               new HashMap<String, DataType>() {{
+                       for (Metadata metadata : Metadata.values()) {
+                               put(metadata.name(), metadata.getDataType());
+                       }
+               }};
+
+       // 
--------------------------------------------------------------------------------------------
+       // Mutable attributes
+       // 
--------------------------------------------------------------------------------------------
+
+       /** Data type that describes the final output of the source. */
+       private DataType producedDataType;
+
+       /** Metadata that is requested to be appended at the end of a physical 
source row. */
+       private List<Metadata> requestedMetadataFields;
+
+       // 
--------------------------------------------------------------------------------------------
+       // Scan format attributes
+       // 
--------------------------------------------------------------------------------------------
+
+       /** Data type to configure the format. */
+       private final DataType physicalDataType;
+
+       /** Scan format for decoding records from Kinesis. */
+       private final DecodingFormat<DeserializationSchema<RowData>> 
decodingFormat;
+
+       // 
--------------------------------------------------------------------------------------------
+       // Kinesis-specific attributes
+       // 
--------------------------------------------------------------------------------------------
+
+       /** The Kinesis stream to consume. */
+       private final String stream;
+
+       /** Properties for the Kinesis consumer. */
+       private final Properties consumerProperties;
+
+       public KinesisDynamicSource(
+               DataType physicalDataType,
+               String stream,
+               Properties consumerProperties,
+               DecodingFormat<DeserializationSchema<RowData>> decodingFormat) {
+               this(
+                       physicalDataType,
+                       stream,
+                       consumerProperties,
+                       decodingFormat,
+                       null,
+                       Collections.emptyList());
+       }
+
+       public KinesisDynamicSource(
+               DataType physicalDataType,
+               String stream,
+               Properties consumerProperties,
+               DecodingFormat<DeserializationSchema<RowData>> decodingFormat,
+               @Nullable DataType producedDataType,
+               List<Metadata> requestedMetadataFields) {
+
+               this.producedDataType = this.physicalDataType = 
Preconditions.checkNotNull(
+                       physicalDataType,
+                       "Produced data type must not be null.");
+               this.stream = Preconditions.checkNotNull(
+                       stream,
+                       "Stream must not be null.");
+               this.consumerProperties = Preconditions.checkNotNull(
+                       consumerProperties,
+                       "Properties must not be null.");
+               this.decodingFormat = Preconditions.checkNotNull(
+                       decodingFormat,
+                       "Decoding format must not be null.");
+               this.producedDataType = producedDataType;

Review comment:
       Done.




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to