This is an automated email from the ASF dual-hosted git repository.

qiaojialin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 8d5184f  add insert string records in SessinPool
8d5184f is described below

commit 8d5184f1fa5e381150bead6ac3adb74bd0bf00b9
Author: qiaojialin <[email protected]>
AuthorDate: Fri May 29 23:29:01 2020 +0800

    add insert string records in SessinPool
---
 .../org/apache/iotdb/session/pool/SessionPool.java | 53 ++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git 
a/session/src/main/java/org/apache/iotdb/session/pool/SessionPool.java 
b/session/src/main/java/org/apache/iotdb/session/pool/SessionPool.java
index 260ab65..97cb37d 100644
--- a/session/src/main/java/org/apache/iotdb/session/pool/SessionPool.java
+++ b/session/src/main/java/org/apache/iotdb/session/pool/SessionPool.java
@@ -341,6 +341,33 @@ public class SessionPool {
     }
   }
 
+
+  /**
+   * Insert data in batch format, which can reduce the overhead of network. 
This method is just like
+   * jdbc batch insert, we pack some insert request in batch and send them to 
server If you want
+   * improve your performance, please see insertTablet method
+   *
+   * @see Session#insertTablet(Tablet)
+   */
+  public void insertRecords(List<String> deviceIds, List<Long> times,
+      List<List<String>> measurementsList, List<List<String>> valuesList)
+      throws IoTDBConnectionException, BatchExecutionException {
+    for (int i = 0; i < RETRY; i++) {
+      Session session = getSession();
+      try {
+        session.insertRecords(deviceIds, times, measurementsList, valuesList);
+        putBack(session);
+        return;
+      } catch (IoTDBConnectionException e) {
+        // TException means the connection is broken, remove it and get a new 
one.
+        cleanSessionAndMayThrowConnectionException(session, i, e);
+      } catch (BatchExecutionException e) {
+        putBack(session);
+        throw e;
+      }
+    }
+  }
+
   /**
    * insert data in one row, if you want improve your performance, please use 
insertRecords method
    * or insertTablet method
@@ -368,6 +395,32 @@ public class SessionPool {
   }
 
   /**
+   * insert data in one row, if you want improve your performance, please use 
insertRecords method
+   * or insertTablet method
+   *
+   * @see Session#insertRecords(List, List, List, List, List)
+   * @see Session#insertTablet(Tablet)
+   */
+  public void insertRecord(String deviceId, long time, List<String> 
measurements,
+      List<String> values)
+      throws IoTDBConnectionException, StatementExecutionException {
+    for (int i = 0; i < RETRY; i++) {
+      Session session = getSession();
+      try {
+        session.insertRecord(deviceId, time, measurements, values);
+        putBack(session);
+        return;
+      } catch (IoTDBConnectionException e) {
+        // TException means the connection is broken, remove it and get a new 
one.
+        cleanSessionAndMayThrowConnectionException(session, i, e);
+      } catch (StatementExecutionException e) {
+        putBack(session);
+        throw e;
+      }
+    }
+  }
+
+  /**
    * This method NOT insert data into database and the server just return 
after accept the request,
    * this method should be used to test other time cost in client
    */

Reply via email to