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


##########
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:
   The second one (without DeliveryGuarantee) could call the first one, with 
the DeliveryGuarantee.NONE.
    this way we could remove the @Nullable, and not duplicate the constructor 
logic 
   
   `
   JdbcSource(
               Configuration configuration,
               JdbcConnectionProvider connectionProvider,
               JdbcSqlSplitEnumeratorBase.Provider<JdbcSourceSplit> 
sqlSplitEnumeratorProvider,
               ResultExtractor<OUT> resultExtractor,
               @Nonnull TypeInformation<OUT> typeInformation) {
           this(configuration,
                  connectionProvider, 
                  sqlSplitEnumeratorProvider,
                  resultExtractor,
                  typeInformation,
                  DeliveryGuarantee.NONE);
   }
   
   JdbcSource(
               Configuration configuration,
               JdbcConnectionProvider connectionProvider,
               JdbcSqlSplitEnumeratorBase.Provider<JdbcSourceSplit> 
sqlSplitEnumeratorProvider,
               ResultExtractor<OUT> resultExtractor,
               @Nonnull TypeInformation<OUT> typeInformation,
               DeliveryGuarantee deliveryGuarantee) {
           this.configuration = Preconditions.checkNotNull(configuration);
           this.connectionProvider = 
Preconditions.checkNotNull(connectionProvider);
           this.sqlSplitEnumeratorProvider = 
Preconditions.checkNotNull(sqlSplitEnumeratorProvider);
           this.resultExtractor = Preconditions.checkNotNull(resultExtractor);
           this.deliveryGuarantee = Preconditions.checkNotNull(configuration);
           this.typeInformation = Preconditions.checkNotNull(deliveryGuarantee);
           this.boundedness = Boundedness.BOUNDED;
       }
   `



##########
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:
   The second one (without DeliveryGuarantee) could call the first one, with 
the DeliveryGuarantee.NONE.
    this way we could remove the @Nullable, and not duplicate the constructor 
logic 
   
   ```
   JdbcSource(
               Configuration configuration,
               JdbcConnectionProvider connectionProvider,
               JdbcSqlSplitEnumeratorBase.Provider<JdbcSourceSplit> 
sqlSplitEnumeratorProvider,
               ResultExtractor<OUT> resultExtractor,
               @Nonnull TypeInformation<OUT> typeInformation) {
           this(configuration,
                  connectionProvider, 
                  sqlSplitEnumeratorProvider,
                  resultExtractor,
                  typeInformation,
                  DeliveryGuarantee.NONE);
   }
   
   JdbcSource(
               Configuration configuration,
               JdbcConnectionProvider connectionProvider,
               JdbcSqlSplitEnumeratorBase.Provider<JdbcSourceSplit> 
sqlSplitEnumeratorProvider,
               ResultExtractor<OUT> resultExtractor,
               @Nonnull TypeInformation<OUT> typeInformation,
               DeliveryGuarantee deliveryGuarantee) {
           this.configuration = Preconditions.checkNotNull(configuration);
           this.connectionProvider = 
Preconditions.checkNotNull(connectionProvider);
           this.sqlSplitEnumeratorProvider = 
Preconditions.checkNotNull(sqlSplitEnumeratorProvider);
           this.resultExtractor = Preconditions.checkNotNull(resultExtractor);
           this.deliveryGuarantee = Preconditions.checkNotNull(configuration);
           this.typeInformation = Preconditions.checkNotNull(deliveryGuarantee);
           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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to