You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2023/03/24 08:11:41 UTC

[iotdb] branch rel/0.13 updated: [To rel/0.13] Add executeLastDataQuery() to ISessionPool and SessionPool

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

jackietien pushed a commit to branch rel/0.13
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/rel/0.13 by this push:
     new cef06b2ae3 [To rel/0.13] Add executeLastDataQuery() to ISessionPool and SessionPool
cef06b2ae3 is described below

commit cef06b2ae3c521e2891ab1ed7e407efbe6b412aa
Author: Li Yu Heng <li...@126.com>
AuthorDate: Fri Mar 24 16:11:34 2023 +0800

    [To rel/0.13] Add executeLastDataQuery() to ISessionPool and SessionPool
---
 .../apache/iotdb/isession/pool/ISessionPool.java   |  6 +++
 .../org/apache/iotdb/session/pool/SessionPool.java | 46 ++++++++++++++++++++++
 2 files changed, 52 insertions(+)

diff --git a/isession/src/main/java/org/apache/iotdb/isession/pool/ISessionPool.java b/isession/src/main/java/org/apache/iotdb/isession/pool/ISessionPool.java
index c3bf112060..9ce28945c3 100644
--- a/isession/src/main/java/org/apache/iotdb/isession/pool/ISessionPool.java
+++ b/isession/src/main/java/org/apache/iotdb/isession/pool/ISessionPool.java
@@ -394,6 +394,12 @@ public interface ISessionPool {
   ISessionDataSetWrapper executeRawDataQuery(List<String> paths, long startTime, long endTime)
       throws IoTDBConnectionException, StatementExecutionException;
 
+  ISessionDataSetWrapper executeLastDataQuery(List<String> paths, long LastTime)
+      throws IoTDBConnectionException, StatementExecutionException;
+
+  ISessionDataSetWrapper executeLastDataQuery(List<String> path)
+      throws IoTDBConnectionException, StatementExecutionException;
+
   boolean operationSyncTransmit(ByteBuffer buffer)
       throws IoTDBConnectionException, StatementExecutionException;
 
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 24891a01e7..112b6d9a53 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
@@ -2374,6 +2374,52 @@ 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 {
+        ISessionDataSet 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;
+      }
+    }
+    // never go here
+    return null;
+  }
+
+  @Override
+  public SessionDataSetWrapper executeLastDataQuery(List<String> paths)
+      throws StatementExecutionException, IoTDBConnectionException {
+    for (int i = 0; i < RETRY; i++) {
+      ISession session = getSession();
+      try {
+        ISessionDataSet resp = session.executeLastDataQuery(paths);
+        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;
+      }
+    }
+    // never go here
+    return null;
+  }
+
   /** Transmit insert record request for OperationSync */
   @Override
   public boolean operationSyncTransmit(ByteBuffer buffer)