vesense commented on a change in pull request #817: [IOTDB-497] Apache Flink 
Connector Support
URL: https://github.com/apache/incubator-iotdb/pull/817#discussion_r382920705
 
 

 ##########
 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:
   `batchFlushOnCheckpoint` is the **switch** for batch inserting.
   False by default, users can change by invoking 
`withBatchFlushOnCheckpoint(true)`
   
   There are two parameters related to batch.
   * batch size (`iotDBSink.withBatchSize(10)`)
   * checkpoint interval (timer) (`env.enableCheckpointing(3000)`)
   
   ```
   if `batchFlushOnCheckpoint` == true
       if batchList >= batch size || checkpoint interval arises 
(`snapshotState`)
           then session.insertInBatch
       else 
           add to batchList
   else
       session.insert
   ```

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

Reply via email to