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

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


The following commit(s) were added to refs/heads/master by this push:
     new 4f216f7a125 [IOTDB-5924] feat(SessionPool): add deletion API (#9947)
4f216f7a125 is described below

commit 4f216f7a125a58fbf0127ef845073b2d098d5e74
Author: CritasWang <[email protected]>
AuthorDate: Tue May 30 09:57:30 2023 +0800

    [IOTDB-5924] feat(SessionPool): add deletion API (#9947)
---
 .../apache/iotdb/isession/pool/ISessionPool.java   |  35 +++++
 .../org/apache/iotdb/session/pool/SessionPool.java | 168 +++++++++++++++++++++
 2 files changed, 203 insertions(+)

diff --git 
a/iotdb-client/isession/src/main/java/org/apache/iotdb/isession/pool/ISessionPool.java
 
b/iotdb-client/isession/src/main/java/org/apache/iotdb/isession/pool/ISessionPool.java
index 2f5c0175407..bc6d8c7751e 100644
--- 
a/iotdb-client/isession/src/main/java/org/apache/iotdb/isession/pool/ISessionPool.java
+++ 
b/iotdb-client/isession/src/main/java/org/apache/iotdb/isession/pool/ISessionPool.java
@@ -183,6 +183,14 @@ public interface ISessionPool {
       List<List<String>> valuesList)
       throws IoTDBConnectionException, StatementExecutionException;
 
+  void insertRecord(
+      String deviceId,
+      long time,
+      List<String> measurements,
+      List<TSDataType> types,
+      Object... values)
+      throws IoTDBConnectionException, StatementExecutionException;
+
   void insertRecord(
       String deviceId,
       long time,
@@ -202,6 +210,8 @@ public interface ISessionPool {
   void insertRecord(String deviceId, long time, List<String> measurements, 
List<String> values)
       throws IoTDBConnectionException, StatementExecutionException;
 
+  String getTimestampPrecision() throws IoTDBConnectionException, 
StatementExecutionException;
+
   void insertAlignedRecord(
       String multiSeriesId, long time, List<String> 
multiMeasurementComponents, List<String> values)
       throws IoTDBConnectionException, StatementExecutionException;
@@ -291,6 +301,26 @@ public interface ISessionPool {
       String measurementAlias)
       throws IoTDBConnectionException, StatementExecutionException;
 
+  void createAlignedTimeseries(
+      String deviceId,
+      List<String> measurements,
+      List<TSDataType> dataTypes,
+      List<TSEncoding> encodings,
+      List<CompressionType> compressors,
+      List<String> measurementAliasList)
+      throws IoTDBConnectionException, StatementExecutionException;
+
+  void createAlignedTimeseries(
+      String deviceId,
+      List<String> measurements,
+      List<TSDataType> dataTypes,
+      List<TSEncoding> encodings,
+      List<CompressionType> compressors,
+      List<String> measurementAliasList,
+      List<Map<String, String>> tagsList,
+      List<Map<String, String>> attributesList)
+      throws IoTDBConnectionException, StatementExecutionException;
+
   void createMultiTimeseries(
       List<String> paths,
       List<TSDataType> dataTypes,
@@ -415,6 +445,9 @@ public interface ISessionPool {
       List<String> paths, long startTime, long endTime, long timeOut)
       throws IoTDBConnectionException, StatementExecutionException;
 
+  SessionDataSetWrapper executeLastDataQuery(List<String> paths, long lastTime)
+      throws StatementExecutionException, IoTDBConnectionException;
+
   SessionDataSetWrapper executeLastDataQuery(List<String> paths, long 
LastTime, long timeOut)
       throws StatementExecutionException, IoTDBConnectionException;
 
@@ -478,6 +511,8 @@ public interface ISessionPool {
 
   int getConnectionTimeoutInMs();
 
+  void sortTablet(Tablet tablet) throws IoTDBConnectionException;
+
   TSBackupConfigurationResp getBackupConfiguration()
       throws IoTDBConnectionException, StatementExecutionException;
 
diff --git 
a/iotdb-client/session/src/main/java/org/apache/iotdb/session/pool/SessionPool.java
 
b/iotdb-client/session/src/main/java/org/apache/iotdb/session/pool/SessionPool.java
index e51567c8be8..d545fbb73c5 100644
--- 
a/iotdb-client/session/src/main/java/org/apache/iotdb/session/pool/SessionPool.java
+++ 
b/iotdb-client/session/src/main/java/org/apache/iotdb/session/pool/SessionPool.java
@@ -37,6 +37,7 @@ import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
 import org.apache.iotdb.tsfile.write.record.Tablet;
 
+import org.apache.thrift.TException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -1311,6 +1312,42 @@ public class SessionPool implements ISessionPool {
     }
   }
 
+  /**
+   * 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)
+   */
+  @Override
+  public void insertRecord(
+      String deviceId,
+      long time,
+      List<String> measurements,
+      List<TSDataType> types,
+      Object... values)
+      throws IoTDBConnectionException, StatementExecutionException {
+    for (int i = 0; i < RETRY; i++) {
+      ISession session = getSession();
+      try {
+        session.insertRecord(deviceId, time, measurements, types, values);
+        putBack(session);
+        return;
+      } catch (IoTDBConnectionException e) {
+        // TException means the connection is broken, remove it and get a new 
one.
+        logger.warn("insertRecord failed", e);
+        cleanSessionAndMayThrowConnectionException(session, i, e);
+      } catch (StatementExecutionException | RuntimeException e) {
+        putBack(session);
+        throw e;
+      } catch (Throwable e) {
+        logger.error("unexpected error in insertRecord", e);
+        putBack(session);
+        throw new RuntimeException(e);
+      }
+    }
+  }
+
   /**
    * insert data in one row, if you want improve your performance, please use 
insertRecords method
    * or insertTablet method
@@ -1347,6 +1384,32 @@ public class SessionPool implements ISessionPool {
     }
   }
 
+  @Override
+  public String getTimestampPrecision()
+      throws IoTDBConnectionException, StatementExecutionException {
+    String timestampPrecision = "ms";
+    for (int i = 0; i < RETRY; i++) {
+      ISession session = getSession();
+      try {
+        timestampPrecision = session.getTimestampPrecision();
+        putBack(session);
+        return timestampPrecision;
+      } catch (TException e) {
+        // TException means the connection is broken, remove it and get a new 
one.
+        logger.warn("getTimestampPrecision failed", e);
+        cleanSessionAndMayThrowConnectionException(session, i, new 
IoTDBConnectionException(e));
+      } catch (RuntimeException e) {
+        putBack(session);
+        throw e;
+      } catch (Throwable e) {
+        logger.error("unexpected error in getTimestampPrecision", e);
+        putBack(session);
+        throw new RuntimeException(e);
+      }
+    }
+    return timestampPrecision;
+  }
+
   /**
    * insert aligned data in one row, if you want improve your performance, 
please use
    * insertAlignedRecords method or insertTablet method.
@@ -2043,6 +2106,77 @@ public class SessionPool implements ISessionPool {
     }
   }
 
+  @Override
+  public void createAlignedTimeseries(
+      String deviceId,
+      List<String> measurements,
+      List<TSDataType> dataTypes,
+      List<TSEncoding> encodings,
+      List<CompressionType> compressors,
+      List<String> measurementAliasList)
+      throws IoTDBConnectionException, StatementExecutionException {
+    for (int i = 0; i < RETRY; i++) {
+      ISession session = getSession();
+      try {
+        session.createAlignedTimeseries(
+            deviceId, measurements, dataTypes, encodings, compressors, 
measurementAliasList);
+        putBack(session);
+        return;
+      } catch (IoTDBConnectionException e) {
+        // TException means the connection is broken, remove it and get a new 
one.
+        logger.warn("createAlignedTimeseries failed", e);
+        cleanSessionAndMayThrowConnectionException(session, i, e);
+      } catch (StatementExecutionException | RuntimeException e) {
+        putBack(session);
+        throw e;
+      } catch (Throwable e) {
+        logger.error("unexpected error in createAlignedTimeseries", e);
+        putBack(session);
+        throw new RuntimeException(e);
+      }
+    }
+  }
+
+  @Override
+  public void createAlignedTimeseries(
+      String deviceId,
+      List<String> measurements,
+      List<TSDataType> dataTypes,
+      List<TSEncoding> encodings,
+      List<CompressionType> compressors,
+      List<String> measurementAliasList,
+      List<Map<String, String>> tagsList,
+      List<Map<String, String>> attributesList)
+      throws IoTDBConnectionException, StatementExecutionException {
+    for (int i = 0; i < RETRY; i++) {
+      ISession session = getSession();
+      try {
+        session.createAlignedTimeseries(
+            deviceId,
+            measurements,
+            dataTypes,
+            encodings,
+            compressors,
+            measurementAliasList,
+            tagsList,
+            attributesList);
+        putBack(session);
+        return;
+      } catch (IoTDBConnectionException e) {
+        // TException means the connection is broken, remove it and get a new 
one.
+        logger.warn("createAlignedTimeseries failed", e);
+        cleanSessionAndMayThrowConnectionException(session, i, e);
+      } catch (StatementExecutionException | RuntimeException e) {
+        putBack(session);
+        throw e;
+      } catch (Throwable e) {
+        logger.error("unexpected error in createAlignedTimeseries", e);
+        putBack(session);
+        throw new RuntimeException(e);
+      }
+    }
+  }
+
   @Override
   public void createMultiTimeseries(
       List<String> paths,
@@ -2574,6 +2708,13 @@ public class SessionPool implements ISessionPool {
     return null;
   }
 
+  @Override
+  public void sortTablet(Tablet tablet) throws IoTDBConnectionException {
+    ISession session = getSession();
+    session.sortTablet(tablet);
+    putBack(session);
+  }
+
   @Override
   public void setSchemaTemplate(String templateName, String prefixPath)
       throws StatementExecutionException, IoTDBConnectionException {
@@ -2805,6 +2946,33 @@ public class SessionPool implements ISessionPool {
     return null;
   }
 
+  @Override
+  public SessionDataSetWrapper executeLastDataQuery(List<String> paths, long 
LastTime)
+      throws StatementExecutionException, IoTDBConnectionException {
+    for (int i = 0; i < RETRY; i++) {
+      ISession session = getSession();
+      try {
+        SessionDataSet resp = session.executeLastDataQuery(paths, LastTime);
+        SessionDataSetWrapper wrapper = new SessionDataSetWrapper(resp, 
session, this);
+        occupy(session);
+        return wrapper;
+      } catch (IoTDBConnectionException e) {
+        // TException means the connection is broken, remove it and get a new 
one.
+        logger.warn("executeLastDataQuery failed", e);
+        cleanSessionAndMayThrowConnectionException(session, i, e);
+      } catch (StatementExecutionException | RuntimeException e) {
+        putBack(session);
+        throw e;
+      } catch (Throwable e) {
+        logger.error("unexpected error in executeLastDataQuery", e);
+        putBack(session);
+        throw new RuntimeException(e);
+      }
+    }
+    // never go here
+    return null;
+  }
+
   @Override
   public SessionDataSetWrapper executeLastDataQuery(List<String> paths, long 
LastTime, long timeOut)
       throws StatementExecutionException, IoTDBConnectionException {

Reply via email to