RocMarshal commented on code in PR #78:
URL: 
https://github.com/apache/flink-connector-jdbc/pull/78#discussion_r1441298453


##########
flink-connector-jdbc/src/main/java/org/apache/flink/connector/jdbc/source/JdbcSource.java:
##########
@@ -0,0 +1,190 @@
+/*
+ * 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.connector.jdbc.source;
+
+import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.annotation.VisibleForTesting;
+import org.apache.flink.api.common.typeinfo.TypeHint;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.connector.source.Boundedness;
+import org.apache.flink.api.connector.source.Source;
+import org.apache.flink.api.connector.source.SourceReader;
+import org.apache.flink.api.connector.source.SourceReaderContext;
+import org.apache.flink.api.connector.source.SplitEnumerator;
+import org.apache.flink.api.connector.source.SplitEnumeratorContext;
+import org.apache.flink.api.java.typeutils.ResultTypeQueryable;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.connector.base.DeliveryGuarantee;
+import 
org.apache.flink.connector.jdbc.internal.connection.JdbcConnectionProvider;
+import 
org.apache.flink.connector.jdbc.source.enumerator.JdbcSourceEnumStateSerializer;
+import org.apache.flink.connector.jdbc.source.enumerator.JdbcSourceEnumerator;
+import 
org.apache.flink.connector.jdbc.source.enumerator.JdbcSourceEnumeratorState;
+import 
org.apache.flink.connector.jdbc.source.enumerator.JdbcSqlSplitEnumeratorBase;
+import org.apache.flink.connector.jdbc.source.reader.JdbcSourceReader;
+import org.apache.flink.connector.jdbc.source.reader.JdbcSourceSplitReader;
+import org.apache.flink.connector.jdbc.source.reader.extractor.ResultExtractor;
+import org.apache.flink.connector.jdbc.source.split.JdbcSourceSplit;
+import org.apache.flink.connector.jdbc.source.split.JdbcSourceSplitSerializer;
+import org.apache.flink.core.io.SimpleVersionedSerializer;
+import org.apache.flink.util.Preconditions;
+
+import javax.annotation.Nullable;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Objects;
+
+/** JDBC source. */
+@PublicEvolving
+public class JdbcSource<OUT>
+        implements Source<OUT, JdbcSourceSplit, JdbcSourceEnumeratorState>,
+                ResultTypeQueryable<OUT> {
+
+    private final Boundedness boundedness;
+    private final TypeInformation<OUT> typeInformation;
+
+    private final Configuration configuration;
+    private final JdbcSqlSplitEnumeratorBase.Provider<JdbcSourceSplit> 
sqlSplitEnumeratorProvider;
+
+    protected JdbcConnectionProvider connectionProvider;
+    private final ResultExtractor<OUT> resultExtractor;
+    private final DeliveryGuarantee deliveryGuarantee;
+
+    JdbcSource(
+            Configuration configuration,
+            JdbcConnectionProvider connectionProvider,
+            JdbcSqlSplitEnumeratorBase.Provider<JdbcSourceSplit> 
sqlSplitEnumeratorProvider,
+            ResultExtractor<OUT> resultExtractor,
+            @Nullable TypeInformation<OUT> typeInformation,
+            @Nullable DeliveryGuarantee deliveryGuarantee) {

Review Comment:
   Thx for the comment.  
    
   I have rechecked the logic of this section and come to the following 
conclusion in my limited read:
   
   - `typeInformation ` must not be null, because when `typeInformation ` is 
null, we currently cannot provide true type information through type inference.
   
   - `deliveryGuarantee` could be null.
   
   
   
   So how about retaining the following two construction methods?
   
   
   ```
   
       JdbcSource(
               Configuration configuration,
               JdbcConnectionProvider connectionProvider,
               JdbcSqlSplitEnumeratorBase.Provider<JdbcSourceSplit> 
sqlSplitEnumeratorProvider,
               ResultExtractor<OUT> resultExtractor,
               @Nonnull TypeInformation<OUT> typeInformation,
               @Nullable DeliveryGuarantee deliveryGuarantee) {
           this.configuration = Preconditions.checkNotNull(configuration);
           this.connectionProvider = 
Preconditions.checkNotNull(connectionProvider);
           this.sqlSplitEnumeratorProvider = 
Preconditions.checkNotNull(sqlSplitEnumeratorProvider);
           this.resultExtractor = Preconditions.checkNotNull(resultExtractor);
           this.deliveryGuarantee = deliveryGuarantee == null ? 
DeliveryGuarantee.NONE : deliveryGuarantee;
           this.typeInformation = Preconditions.checkNotNull(typeInformation);
           this.boundedness = Boundedness.BOUNDED;
       }
   
       JdbcSource(
               Configuration configuration,
               JdbcConnectionProvider connectionProvider,
               JdbcSqlSplitEnumeratorBase.Provider<JdbcSourceSplit> 
sqlSplitEnumeratorProvider,
               ResultExtractor<OUT> resultExtractor,
               @Nonnull TypeInformation<OUT> typeInformation) {
           this.configuration = Preconditions.checkNotNull(configuration);
           this.connectionProvider = 
Preconditions.checkNotNull(connectionProvider);
           this.sqlSplitEnumeratorProvider = 
Preconditions.checkNotNull(sqlSplitEnumeratorProvider);
           this.resultExtractor = Preconditions.checkNotNull(resultExtractor);
           this.deliveryGuarantee = DeliveryGuarantee.NONE;
           this.typeInformation = Preconditions.checkNotNull(typeInformation);
           this.boundedness = Boundedness.BOUNDED;
       }
   
   
   ```
   



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