kezhenxu94 commented on a change in pull request #1289: URL: https://github.com/apache/incubator-seatunnel/pull/1289#discussion_r810038215
########## File path: seatunnel-connectors/seatunnel-connector-flink-iotdb/src/main/java/org/apache/seatunnel/flink/source/IotDbInputFormat.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.seatunnel.flink.source; + +import org.apache.flink.api.common.io.DefaultInputSplitAssigner; +import org.apache.flink.api.common.io.RichInputFormat; +import org.apache.flink.api.common.io.statistics.BaseStatistics; +import org.apache.flink.api.java.typeutils.ResultTypeQueryable; +import org.apache.flink.api.java.typeutils.RowTypeInfo; +import org.apache.flink.configuration.Configuration; +import org.apache.flink.core.io.GenericInputSplit; +import org.apache.flink.core.io.InputSplit; +import org.apache.flink.core.io.InputSplitAssigner; +import org.apache.flink.types.Row; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.Statement; +import java.util.List; + +public class IotDbInputFormat extends RichInputFormat<Row, InputSplit> implements ResultTypeQueryable<Row> { + + private static final Logger LOG = LoggerFactory.getLogger(IotDbInputFormat.class); + + private static final String IOTDB_DRIVER = "org.apache.iotdb.jdbc.IoTDBDriver"; + + private String url; + private String query; + private List<String> fields; + private RowTypeInfo rowTypeInfo; + + private transient Connection connection; + private transient Statement statement; + + private long offset; + private boolean hasNext; + + public IotDbInputFormat() { + } + + @Override + public RowTypeInfo getProducedType() { + return rowTypeInfo; + } + + @Override + public void configure(Configuration parameters) { + } + + @Override + public void openInputFormat() { + try { + Class.forName(IOTDB_DRIVER); + connection = DriverManager.getConnection(url, "root", "root"); Review comment: > This is the default user and password, I will support auth to make this configurable in future. I'd rather do that in this PR, without that configuration, I don't think users' production environment will use this kind of username/password and hence this is not usable at all -- 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]
