jixuan1989 commented on a change in pull request #817: [IOTDB-497] Apache Flink Connector Support URL: https://github.com/apache/incubator-iotdb/pull/817#discussion_r382959912
########## File path: flink-iotdb-connector/src/main/java/org/apache/iotdb/flink/IoTDBSink.java ########## @@ -0,0 +1,153 @@ +/* + * 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.iotdb.flink; + +import org.apache.flink.configuration.Configuration; +import org.apache.flink.runtime.state.FunctionInitializationContext; +import org.apache.flink.runtime.state.FunctionSnapshotContext; +import org.apache.flink.streaming.api.checkpoint.CheckpointedFunction; +import org.apache.flink.streaming.api.functions.sink.RichSinkFunction; +import org.apache.flink.streaming.api.operators.StreamingRuntimeContext; +import org.apache.iotdb.service.rpc.thrift.TSStatus; +import org.apache.iotdb.session.Session; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + +public class IoTDBSink<IN> extends RichSinkFunction<IN> implements CheckpointedFunction { + + private static final long serialVersionUID = 1L; + private static final Logger LOG = LoggerFactory.getLogger(IoTDBSink.class); + + private IoTSerializationSchema<IN> serializationSchema; + private IoTDBOptions options; + private transient Session session; + + private boolean batchFlushOnCheckpoint; // false by default Review comment: When a user uses such a module, two things that he/she may consider: 1. I want to reduce the network cost, therefore I will write data until I collect 1000 data points. 2. However, if some device generates data too rarely, e.g., in 0.01Hz (i.e., generates a data point per 100 seconds),and if I have to wait for 1000 data points coming, I have to want for about 100,000 seconds. So, I want that, if I have buffered data for 3 seconds and the buffer is not full, I will send these data to IoTDB. That is to say, `batchList` is for setting the buffer size, and `enableCheckpointing( time interval)` is for setting the acceptable latency. ---------------------------------------------------------------- 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] With regards, Apache Git Services
