This is an automated email from the ASF dual-hosted git repository.
hxd pushed a commit to branch rel/0.9
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
The following commit(s) were added to refs/heads/rel/0.9 by this push:
new 70f757f add insertInBatch() to SessionPool
70f757f is described below
commit 70f757fe2e32ce11e5c54b4851a0f5a02c84f8bb
Author: xiangdong huang <[email protected]>
AuthorDate: Thu Mar 19 20:53:57 2020 +0800
add insertInBatch() to SessionPool
---
.../org/apache/iotdb/session/pool/SessionPool.java | 34 ++++++++++++++++++++--
1 file changed, 32 insertions(+), 2 deletions(-)
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 9918ad9..5b76191 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
@@ -243,13 +243,43 @@ public class SessionPool {
throw new IoTDBSessionException(String.format("retry to execute statement
on %s:%s failed %d times", ip, port, RETRY));
}
+ /**
+ * insert data in one row, if you want improve your performance, please use
insertInBatch method
+ * or insertBatch method
+ *
+ * @see Session#insertInBatch(List, List, List, List)
+ */
+ public List<TSStatus> insertRowInBatch(List<String> deviceIds, List<Long>
times,
+ List<List<String>> measurementsList,
+ List<List<String>> valuesList) throws IoTDBSessionException {
+ for (int i = 0; i < RETRY; i++) {
+ Session session = getSession();
+ try {
+ List<TSStatus> statuses = session
+ .insertInBatch(deviceIds, times, measurementsList, valuesList);
+ putBack(session);
+ return statuses;
+ } catch (IoTDBSessionException e) {
+ if (e.getCause() instanceof TException) {
+ // TException means the connection is broken, remove it and get a
new one.
+ closeSession(session);
+ removeSession();
+ } else {
+ putBack(session);
+ throw e;
+ }
+ }
+ }
+ throw new IoTDBSessionException(
+ String.format("retry to execute statement on %s:%s failed %d times",
ip, port, RETRY));
+ }
/**
- * insert data in one row, if you want improve your performance, please use
insertInBatch method
+ * insert data in one row, if you want improve your performance, please use
insert method
* or insertBatch method
*
- * @see Session#insertBatch(RowBatch)
+ * @see Session#insert(String, long, List, List)
*/
public TSStatus insert(String deviceId, long time, List<String>
measurements, List<String> values)
throws IoTDBSessionException {