This is an automated email from the ASF dual-hosted git repository.
haonan pushed a commit to branch TableSession
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/TableSession by this push:
new 5911aacad04 Dev
5911aacad04 is described below
commit 5911aacad0493dd8c946187b27bcd0b57ca25497
Author: HTHou <[email protected]>
AuthorDate: Thu Nov 21 12:42:38 2024 +0800
Dev
---
.../org/apache/iotdb/TableModelSessionExample.java | 68 ++--
.../apache/iotdb/TableModelSessionPoolExample.java | 35 +-
.../iotdb/it/env/cluster/env/AbstractEnv.java | 90 +++--
.../iotdb/it/env/remote/env/RemoteServerEnv.java | 79 ++--
.../java/org/apache/iotdb/itbase/env/BaseEnv.java | 32 +-
.../iotdb/pipe/it/tablemodel/TableModelUtils.java | 9 +-
.../relational/it/db/it/IoTDBInsertTableIT.java | 57 +--
.../it/query/old/orderBy/IoTDBOrderByTableIT.java | 311 +++++++-------
.../it/session/IoTDBTableModelSessionIT.java | 6 +-
.../pool/IoTDBInsertTableSessionPoolIT.java | 30 +-
.../session/pool/IoTDBTableModelSessionPoolIT.java | 16 +-
.../iotdb/session/it/IoTDBSessionRelationalIT.java | 449 +++++----------------
.../org/apache/iotdb/isession/IPooledSession.java | 65 ---
.../apache/iotdb/isession/pool/ISessionPool.java | 4 +-
.../java/org/apache/iotdb/session/Session.java | 33 +-
.../apache/iotdb/session/TableSessionBuilder.java | 76 ++--
.../org/apache/iotdb/session/pool/SessionPool.java | 6 +-
.../session/pool/TableSessionPoolBuilder.java | 67 +--
...essionWrapper.java => TableSessionWrapper.java} | 120 ++----
19 files changed, 575 insertions(+), 978 deletions(-)
diff --git
a/example/session/src/main/java/org/apache/iotdb/TableModelSessionExample.java
b/example/session/src/main/java/org/apache/iotdb/TableModelSessionExample.java
index b57b5903e07..06c0b477e64 100644
---
a/example/session/src/main/java/org/apache/iotdb/TableModelSessionExample.java
+++
b/example/session/src/main/java/org/apache/iotdb/TableModelSessionExample.java
@@ -19,46 +19,42 @@
package org.apache.iotdb;
+import org.apache.iotdb.isession.ITableSession;
import org.apache.iotdb.isession.SessionDataSet;
-import org.apache.iotdb.isession.util.Version;
import org.apache.iotdb.rpc.IoTDBConnectionException;
import org.apache.iotdb.rpc.StatementExecutionException;
-import org.apache.iotdb.session.Session;
+import org.apache.iotdb.session.TableSessionBuilder;
+
+import java.util.Collections;
public class TableModelSessionExample {
- private static final String LOCAL_HOST = "127.0.0.1";
+ private static final String LOCAL_URL = "127.0.0.1:6667";
public static void main(String[] args) {
// don't specify database in constructor
- Session session =
- new Session.Builder()
- .host(LOCAL_HOST)
- .port(6667)
+ try (ITableSession tableSession =
+ new TableSessionBuilder()
+ .nodeUrls(Collections.singletonList(LOCAL_URL))
.username("root")
.password("root")
- .version(Version.V_1_0)
- .sqlDialect("table")
- .build();
-
- try {
- session.open(false);
+ .build()) {
- session.executeNonQueryStatement("CREATE DATABASE test1");
- session.executeNonQueryStatement("CREATE DATABASE test2");
+ tableSession.executeNonQueryStatement("CREATE DATABASE test1");
+ tableSession.executeNonQueryStatement("CREATE DATABASE test2");
- session.executeNonQueryStatement("use test2");
+ tableSession.executeNonQueryStatement("use test2");
// or use full qualified table name
- session.executeNonQueryStatement(
+ tableSession.executeNonQueryStatement(
"create table test1.table1(region_id STRING ID, plant_id STRING ID,
device_id STRING ID, model STRING ATTRIBUTE, temperature FLOAT MEASUREMENT,
humidity DOUBLE MEASUREMENT) with (TTL=3600000)");
- session.executeNonQueryStatement(
+ tableSession.executeNonQueryStatement(
"create table table2(region_id STRING ID, plant_id STRING ID, color
STRING ATTRIBUTE, temperature FLOAT MEASUREMENT, speed DOUBLE MEASUREMENT) with
(TTL=6600000)");
// show tables from current database
- try (SessionDataSet dataSet = session.executeQueryStatement("SHOW
TABLES")) {
+ try (SessionDataSet dataSet = tableSession.executeQueryStatement("SHOW
TABLES")) {
System.out.println(dataSet.getColumnNames());
while (dataSet.hasNext()) {
System.out.println(dataSet.next());
@@ -67,7 +63,7 @@ public class TableModelSessionExample {
// show tables by specifying another database
// using SHOW tables FROM
- try (SessionDataSet dataSet = session.executeQueryStatement("SHOW TABLES
FROM test1")) {
+ try (SessionDataSet dataSet = tableSession.executeQueryStatement("SHOW
TABLES FROM test1")) {
System.out.println(dataSet.getColumnNames());
while (dataSet.hasNext()) {
System.out.println(dataSet.next());
@@ -78,31 +74,19 @@ public class TableModelSessionExample {
e.printStackTrace();
} catch (StatementExecutionException e) {
e.printStackTrace();
- } finally {
- try {
- session.close();
- } catch (IoTDBConnectionException e) {
- e.printStackTrace();
- }
}
// specify database in constructor
- session =
- new Session.Builder()
- .host(LOCAL_HOST)
- .port(6667)
+ try (ITableSession tableSession =
+ new TableSessionBuilder()
+ .nodeUrls(Collections.singletonList(LOCAL_URL))
.username("root")
.password("root")
- .version(Version.V_1_0)
- .sqlDialect("table")
.database("test1")
- .build();
-
- try {
- session.open(false);
+ .build()) {
// show tables from current database
- try (SessionDataSet dataSet = session.executeQueryStatement("SHOW
TABLES")) {
+ try (SessionDataSet dataSet = tableSession.executeQueryStatement("SHOW
TABLES")) {
System.out.println(dataSet.getColumnNames());
while (dataSet.hasNext()) {
System.out.println(dataSet.next());
@@ -110,11 +94,11 @@ public class TableModelSessionExample {
}
// change database to test2
- session.executeNonQueryStatement("use test2");
+ tableSession.executeNonQueryStatement("use test2");
// show tables by specifying another database
// using SHOW tables FROM
- try (SessionDataSet dataSet = session.executeQueryStatement("SHOW
TABLES")) {
+ try (SessionDataSet dataSet = tableSession.executeQueryStatement("SHOW
TABLES")) {
System.out.println(dataSet.getColumnNames());
while (dataSet.hasNext()) {
System.out.println(dataSet.next());
@@ -125,12 +109,6 @@ public class TableModelSessionExample {
e.printStackTrace();
} catch (StatementExecutionException e) {
e.printStackTrace();
- } finally {
- try {
- session.close();
- } catch (IoTDBConnectionException e) {
- e.printStackTrace();
- }
}
}
}
diff --git
a/example/session/src/main/java/org/apache/iotdb/TableModelSessionPoolExample.java
b/example/session/src/main/java/org/apache/iotdb/TableModelSessionPoolExample.java
index 78af9efdd6d..315c98a5bef 100644
---
a/example/session/src/main/java/org/apache/iotdb/TableModelSessionPoolExample.java
+++
b/example/session/src/main/java/org/apache/iotdb/TableModelSessionPoolExample.java
@@ -19,30 +19,31 @@
package org.apache.iotdb;
-import org.apache.iotdb.isession.IPooledSession;
+import org.apache.iotdb.isession.ITableSession;
import org.apache.iotdb.isession.SessionDataSet;
+import org.apache.iotdb.isession.pool.ITableSessionPool;
import org.apache.iotdb.rpc.IoTDBConnectionException;
import org.apache.iotdb.rpc.StatementExecutionException;
-import org.apache.iotdb.session.pool.SessionPool;
+import org.apache.iotdb.session.pool.TableSessionPoolBuilder;
+
+import java.util.Collections;
public class TableModelSessionPoolExample {
- private static final String LOCAL_HOST = "127.0.0.1";
+ private static final String LOCAL_URL = "127.0.0.1:6667";
public static void main(String[] args) {
// don't specify database in constructor
- SessionPool sessionPool =
- new SessionPool.Builder()
- .host(LOCAL_HOST)
- .port(6667)
+ ITableSessionPool tableSessionPool =
+ new TableSessionPoolBuilder()
+ .nodeUrls(Collections.singletonList(LOCAL_URL))
.user("root")
.password("root")
.maxSize(1)
- .sqlDialect("table")
.build();
- try (IPooledSession session = sessionPool.getPooledSession()) {
+ try (ITableSession session = tableSessionPool.getSession()) {
session.executeNonQueryStatement("CREATE DATABASE test1");
session.executeNonQueryStatement("CREATE DATABASE test2");
@@ -80,22 +81,20 @@ public class TableModelSessionPoolExample {
} catch (StatementExecutionException e) {
e.printStackTrace();
} finally {
- sessionPool.close();
+ tableSessionPool.close();
}
// specify database in constructor
- sessionPool =
- new SessionPool.Builder()
- .host(LOCAL_HOST)
- .port(6667)
+ tableSessionPool =
+ new TableSessionPoolBuilder()
+ .nodeUrls(Collections.singletonList(LOCAL_URL))
.user("root")
.password("root")
.maxSize(1)
- .sqlDialect("table")
.database("test1")
.build();
- try (IPooledSession session = sessionPool.getPooledSession()) {
+ try (ITableSession session = tableSessionPool.getSession()) {
// show tables from current database
try (SessionDataSet dataSet = session.executeQueryStatement("SHOW
TABLES")) {
@@ -125,7 +124,7 @@ public class TableModelSessionPoolExample {
e.printStackTrace();
}
- try (IPooledSession session = sessionPool.getPooledSession()) {
+ try (ITableSession session = tableSessionPool.getSession()) {
// show tables from default database test1
try (SessionDataSet dataSet = session.executeQueryStatement("SHOW
TABLES")) {
@@ -141,7 +140,7 @@ public class TableModelSessionPoolExample {
} catch (StatementExecutionException e) {
e.printStackTrace();
} finally {
- sessionPool.close();
+ tableSessionPool.close();
}
}
}
diff --git
a/integration-test/src/main/java/org/apache/iotdb/it/env/cluster/env/AbstractEnv.java
b/integration-test/src/main/java/org/apache/iotdb/it/env/cluster/env/AbstractEnv.java
index 90d61d754c6..7260f92b730 100644
---
a/integration-test/src/main/java/org/apache/iotdb/it/env/cluster/env/AbstractEnv.java
+++
b/integration-test/src/main/java/org/apache/iotdb/it/env/cluster/env/AbstractEnv.java
@@ -34,8 +34,10 @@ import
org.apache.iotdb.confignode.rpc.thrift.TShowDataNodesResp;
import org.apache.iotdb.confignode.rpc.thrift.TShowRegionReq;
import org.apache.iotdb.confignode.rpc.thrift.TShowRegionResp;
import org.apache.iotdb.isession.ISession;
+import org.apache.iotdb.isession.ITableSession;
import org.apache.iotdb.isession.SessionConfig;
import org.apache.iotdb.isession.pool.ISessionPool;
+import org.apache.iotdb.isession.pool.ITableSessionPool;
import org.apache.iotdb.it.env.EnvFactory;
import org.apache.iotdb.it.env.cluster.EnvUtils;
import org.apache.iotdb.it.env.cluster.config.*;
@@ -54,8 +56,10 @@ import org.apache.iotdb.jdbc.IoTDBConnection;
import org.apache.iotdb.rpc.IoTDBConnectionException;
import org.apache.iotdb.rpc.TSStatusCode;
import org.apache.iotdb.session.Session;
+import org.apache.iotdb.session.TableSessionBuilder;
import org.apache.iotdb.session.pool.SessionPool;
+import org.apache.iotdb.session.pool.TableSessionPoolBuilder;
import org.apache.thrift.TException;
import org.apache.thrift.transport.TTransportException;
import org.slf4j.Logger;
@@ -476,30 +480,13 @@ public abstract class AbstractEnv implements BaseEnv {
}
@Override
- public ISession getSessionConnection(final String sqlDialect) throws
IoTDBConnectionException {
+ public ISession getSessionConnection() throws IoTDBConnectionException {
final DataNodeWrapper dataNode =
this.dataNodeWrapperList.get(rand.nextInt(this.dataNodeWrapperList.size()));
final Session session =
new Session.Builder()
.host(dataNode.getIp())
.port(dataNode.getPort())
- .sqlDialect(sqlDialect)
- .build();
- session.open();
- return session;
- }
-
- @Override
- public ISession getSessionConnectionWithDB(final String sqlDialect, final
String database)
- throws IoTDBConnectionException {
- final DataNodeWrapper dataNode =
-
this.dataNodeWrapperList.get(rand.nextInt(this.dataNodeWrapperList.size()));
- final Session session =
- new Session.Builder()
- .host(dataNode.getIp())
- .port(dataNode.getPort())
- .sqlDialect(sqlDialect)
- .database(database)
.build();
session.open();
return session;
@@ -507,7 +494,7 @@ public abstract class AbstractEnv implements BaseEnv {
@Override
public ISession getSessionConnection(
- final String userName, final String password, final String sqlDialect)
+ final String userName, final String password)
throws IoTDBConnectionException {
final DataNodeWrapper dataNode =
this.dataNodeWrapperList.get(rand.nextInt(this.dataNodeWrapperList.size()));
@@ -517,14 +504,13 @@ public abstract class AbstractEnv implements BaseEnv {
.port(dataNode.getPort())
.username(userName)
.password(password)
- .sqlDialect(sqlDialect)
.build();
session.open();
return session;
}
@Override
- public ISession getSessionConnection(final List<String> nodeUrls, final
String sqlDialect)
+ public ISession getSessionConnection(final List<String> nodeUrls)
throws IoTDBConnectionException {
final Session session =
new Session.Builder()
@@ -537,14 +523,47 @@ public abstract class AbstractEnv implements BaseEnv {
.thriftMaxFrameSize(SessionConfig.DEFAULT_MAX_FRAME_SIZE)
.enableRedirection(SessionConfig.DEFAULT_REDIRECTION_MODE)
.version(SessionConfig.DEFAULT_VERSION)
- .sqlDialect(sqlDialect)
.build();
session.open();
return session;
}
@Override
- public ISessionPool getSessionPool(final int maxSize, final String
sqlDialect) {
+ public ITableSession getTableSessionConnection()
+ throws IoTDBConnectionException {
+ final DataNodeWrapper dataNode =
+
this.dataNodeWrapperList.get(rand.nextInt(this.dataNodeWrapperList.size()));
+ return new TableSessionBuilder()
+ .nodeUrls(Collections.singletonList(dataNode.getIpAndPortString()))
+ .build();
+ }
+
+ @Override
+ public ITableSession getTableSessionConnectionWithDB(final String database)
+ throws IoTDBConnectionException {
+ final DataNodeWrapper dataNode =
+
this.dataNodeWrapperList.get(rand.nextInt(this.dataNodeWrapperList.size()));
+ return new TableSessionBuilder()
+ .nodeUrls(Collections.singletonList(dataNode.getIpAndPortString()))
+ .database(database)
+ .build();
+ }
+
+ public ITableSession getTableSessionConnection(List<String> nodeUrls) throws
IoTDBConnectionException {
+ return new TableSessionBuilder()
+ .nodeUrls(nodeUrls)
+ .username(SessionConfig.DEFAULT_USER)
+ .password(SessionConfig.DEFAULT_PASSWORD)
+ .fetchSize(SessionConfig.DEFAULT_FETCH_SIZE)
+ .zoneId(null)
+ .thriftDefaultBufferSize(SessionConfig.DEFAULT_INITIAL_BUFFER_CAPACITY)
+ .thriftMaxFrameSize(SessionConfig.DEFAULT_MAX_FRAME_SIZE)
+ .enableRedirection(SessionConfig.DEFAULT_REDIRECTION_MODE)
+ .build();
+ }
+
+ @Override
+ public ISessionPool getSessionPool(final int maxSize) {
final DataNodeWrapper dataNode =
this.dataNodeWrapperList.get(rand.nextInt(this.dataNodeWrapperList.size()));
return new SessionPool.Builder()
@@ -553,23 +572,32 @@ public abstract class AbstractEnv implements BaseEnv {
.user(SessionConfig.DEFAULT_USER)
.password(SessionConfig.DEFAULT_PASSWORD)
.maxSize(maxSize)
- .sqlDialect(sqlDialect)
.build();
}
@Override
- public ISessionPool getSessionPool(
- final int maxSize, final String sqlDialect, final String database) {
- DataNodeWrapper dataNode =
+ public ITableSessionPool getTableSessionPool(final int maxSize) {
+ final DataNodeWrapper dataNode =
this.dataNodeWrapperList.get(rand.nextInt(this.dataNodeWrapperList.size()));
- return new SessionPool.Builder()
- .host(dataNode.getIp())
- .port(dataNode.getPort())
+ return new TableSessionPoolBuilder()
+ .nodeUrls(Collections.singletonList(dataNode.getIpAndPortString()))
.user(SessionConfig.DEFAULT_USER)
.password(SessionConfig.DEFAULT_PASSWORD)
.maxSize(maxSize)
- .sqlDialect(sqlDialect)
+ .build();
+ }
+
+ @Override
+ public ITableSessionPool getTableSessionPool(
+ final int maxSize, final String database) {
+ DataNodeWrapper dataNode =
+
this.dataNodeWrapperList.get(rand.nextInt(this.dataNodeWrapperList.size()));
+ return new TableSessionPoolBuilder()
+ .nodeUrls(Collections.singletonList(dataNode.getIpAndPortString()))
+ .user(SessionConfig.DEFAULT_USER)
+ .password(SessionConfig.DEFAULT_PASSWORD)
.database(database)
+ .maxSize(maxSize)
.build();
}
diff --git
a/integration-test/src/main/java/org/apache/iotdb/it/env/remote/env/RemoteServerEnv.java
b/integration-test/src/main/java/org/apache/iotdb/it/env/remote/env/RemoteServerEnv.java
index 70617f41f28..d06d670036e 100644
---
a/integration-test/src/main/java/org/apache/iotdb/it/env/remote/env/RemoteServerEnv.java
+++
b/integration-test/src/main/java/org/apache/iotdb/it/env/remote/env/RemoteServerEnv.java
@@ -27,8 +27,10 @@ import
org.apache.iotdb.commons.client.sync.SyncConfigNodeIServiceClient;
import org.apache.iotdb.commons.cluster.NodeStatus;
import org.apache.iotdb.confignode.rpc.thrift.IConfigNodeRPCService;
import org.apache.iotdb.isession.ISession;
+import org.apache.iotdb.isession.ITableSession;
import org.apache.iotdb.isession.SessionConfig;
import org.apache.iotdb.isession.pool.ISessionPool;
+import org.apache.iotdb.isession.pool.ITableSessionPool;
import org.apache.iotdb.it.env.EnvFactory;
import org.apache.iotdb.it.env.cluster.node.AbstractNodeWrapper;
import org.apache.iotdb.it.env.cluster.node.ConfigNodeWrapper;
@@ -41,6 +43,7 @@ import org.apache.iotdb.jdbc.Config;
import org.apache.iotdb.jdbc.Constant;
import org.apache.iotdb.rpc.IoTDBConnectionException;
import org.apache.iotdb.session.Session;
+import org.apache.iotdb.session.TableSessionBuilder;
import org.apache.iotdb.session.pool.SessionPool;
import java.sql.Connection;
@@ -51,6 +54,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
+import org.apache.iotdb.session.pool.TableSessionPoolBuilder;
import static org.apache.iotdb.jdbc.Config.VERSION;
@@ -202,7 +206,7 @@ public class RemoteServerEnv implements BaseEnv {
}
@Override
- public ISessionPool getSessionPool(int maxSize, String sqlDialect) {
+ public ISessionPool getSessionPool(int maxSize) {
return new SessionPool.Builder()
.host(SessionConfig.DEFAULT_HOST)
.port(SessionConfig.DEFAULT_PORT)
@@ -218,15 +222,13 @@ public class RemoteServerEnv implements BaseEnv {
.version(SessionConfig.DEFAULT_VERSION)
.thriftDefaultBufferSize(SessionConfig.DEFAULT_INITIAL_BUFFER_CAPACITY)
.thriftMaxFrameSize(SessionConfig.DEFAULT_MAX_FRAME_SIZE)
- .sqlDialect(sqlDialect)
.build();
}
@Override
- public ISessionPool getSessionPool(int maxSize, String sqlDialect, String
database) {
- return new SessionPool.Builder()
- .host(SessionConfig.DEFAULT_HOST)
- .port(SessionConfig.DEFAULT_PORT)
+ public ITableSessionPool getTableSessionPool(int maxSize) {
+ return new TableSessionPoolBuilder()
+ .nodeUrls(Collections.singletonList(SessionConfig.DEFAULT_HOST + ":"
+SessionConfig.DEFAULT_PORT))
.user(SessionConfig.DEFAULT_USER)
.password(SessionConfig.DEFAULT_PASSWORD)
.maxSize(maxSize)
@@ -236,42 +238,75 @@ public class RemoteServerEnv implements BaseEnv {
.zoneId(null)
.enableRedirection(SessionConfig.DEFAULT_REDIRECTION_MODE)
.connectionTimeoutInMs(SessionConfig.DEFAULT_CONNECTION_TIMEOUT_MS)
- .version(SessionConfig.DEFAULT_VERSION)
.thriftDefaultBufferSize(SessionConfig.DEFAULT_INITIAL_BUFFER_CAPACITY)
.thriftMaxFrameSize(SessionConfig.DEFAULT_MAX_FRAME_SIZE)
- .sqlDialect(sqlDialect)
+ .build();
+ }
+
+ @Override
+ public ITableSessionPool getTableSessionPool(int maxSize, String database) {
+ return new TableSessionPoolBuilder()
+ .nodeUrls(Collections.singletonList(SessionConfig.DEFAULT_HOST + ":"
+SessionConfig.DEFAULT_PORT))
+ .user(SessionConfig.DEFAULT_USER)
+ .password(SessionConfig.DEFAULT_PASSWORD)
.database(database)
+ .maxSize(maxSize)
+ .fetchSize(SessionConfig.DEFAULT_FETCH_SIZE)
+ .waitToGetSessionTimeoutInMs(60_000)
+ .enableCompression(false)
+ .zoneId(null)
+ .enableRedirection(SessionConfig.DEFAULT_REDIRECTION_MODE)
+ .connectionTimeoutInMs(SessionConfig.DEFAULT_CONNECTION_TIMEOUT_MS)
+ .thriftDefaultBufferSize(SessionConfig.DEFAULT_INITIAL_BUFFER_CAPACITY)
+ .thriftMaxFrameSize(SessionConfig.DEFAULT_MAX_FRAME_SIZE)
.build();
}
@Override
- public ISession getSessionConnection(String sqlDialect) throws
IoTDBConnectionException {
+ public ISession getSessionConnection() throws IoTDBConnectionException {
Session session =
new Session.Builder()
.host(ip_addr)
.port(Integer.parseInt(port))
- .sqlDialect(sqlDialect)
.build();
session.open();
return session;
}
@Override
- public ISession getSessionConnectionWithDB(String sqlDialect, String
database)
+ public ITableSession getTableSessionConnection()
throws IoTDBConnectionException {
- Session session =
- new Session.Builder()
- .host(ip_addr)
- .port(Integer.parseInt(port))
- .sqlDialect(sqlDialect)
- .database(database)
+ return new TableSessionBuilder()
+ .nodeUrls(Collections.singletonList(ip_addr + ":" + port))
+ .build();
+ }
+
+ @Override
+ public ITableSession getTableSessionConnectionWithDB(String database)
+ throws IoTDBConnectionException {
+ return new TableSessionBuilder()
+ .nodeUrls(Collections.singletonList(ip_addr + ":" + port))
+ .database(database)
+ .build();
+ }
+
+ @Override
+ public ITableSession getTableSessionConnection(List<String> nodeUrls)
+ throws IoTDBConnectionException {
+ return new TableSessionBuilder()
+ .nodeUrls(nodeUrls)
+ .username(SessionConfig.DEFAULT_USER)
+ .password(SessionConfig.DEFAULT_PASSWORD)
+ .fetchSize(SessionConfig.DEFAULT_FETCH_SIZE)
+ .zoneId(null)
+
.thriftDefaultBufferSize(SessionConfig.DEFAULT_INITIAL_BUFFER_CAPACITY)
+ .thriftMaxFrameSize(SessionConfig.DEFAULT_MAX_FRAME_SIZE)
+ .enableRedirection(SessionConfig.DEFAULT_REDIRECTION_MODE)
.build();
- session.open();
- return session;
}
@Override
- public ISession getSessionConnection(String userName, String password,
String sqlDialect)
+ public ISession getSessionConnection(String userName, String password)
throws IoTDBConnectionException {
Session session =
new Session.Builder()
@@ -279,14 +314,13 @@ public class RemoteServerEnv implements BaseEnv {
.port(Integer.parseInt(port))
.username(userName)
.password(password)
- .sqlDialect(sqlDialect)
.build();
session.open();
return session;
}
@Override
- public ISession getSessionConnection(List<String> nodeUrls, String
sqlDialect)
+ public ISession getSessionConnection(List<String> nodeUrls)
throws IoTDBConnectionException {
Session session =
new Session.Builder()
@@ -299,7 +333,6 @@ public class RemoteServerEnv implements BaseEnv {
.thriftMaxFrameSize(SessionConfig.DEFAULT_MAX_FRAME_SIZE)
.enableRedirection(SessionConfig.DEFAULT_REDIRECTION_MODE)
.version(SessionConfig.DEFAULT_VERSION)
- .sqlDialect(sqlDialect)
.build();
session.open();
return session;
diff --git
a/integration-test/src/main/java/org/apache/iotdb/itbase/env/BaseEnv.java
b/integration-test/src/main/java/org/apache/iotdb/itbase/env/BaseEnv.java
index 4ef14786d8c..5af92687e8d 100644
--- a/integration-test/src/main/java/org/apache/iotdb/itbase/env/BaseEnv.java
+++ b/integration-test/src/main/java/org/apache/iotdb/itbase/env/BaseEnv.java
@@ -23,8 +23,10 @@ import
org.apache.iotdb.commons.client.exception.ClientManagerException;
import org.apache.iotdb.commons.cluster.NodeStatus;
import org.apache.iotdb.confignode.rpc.thrift.IConfigNodeRPCService;
import org.apache.iotdb.isession.ISession;
+import org.apache.iotdb.isession.ITableSession;
import org.apache.iotdb.isession.SessionConfig;
import org.apache.iotdb.isession.pool.ISessionPool;
+import org.apache.iotdb.isession.pool.ITableSessionPool;
import org.apache.iotdb.it.env.cluster.node.AbstractNodeWrapper;
import org.apache.iotdb.it.env.cluster.node.ConfigNodeWrapper;
import org.apache.iotdb.it.env.cluster.node.DataNodeWrapper;
@@ -183,36 +185,26 @@ public interface BaseEnv {
IConfigNodeRPCService.Iface getLeaderConfigNodeConnection()
throws ClientManagerException, IOException, InterruptedException;
- default ISessionPool getSessionPool(int maxSize) {
- return getSessionPool(maxSize, TREE_SQL_DIALECT);
- }
+ ISessionPool getSessionPool(int maxSize);
- ISessionPool getSessionPool(int maxSize, String sqlDialect);
+ ITableSessionPool getTableSessionPool(int maxSize);
- ISessionPool getSessionPool(int maxSize, String sqlDialect, String database);
+ ITableSessionPool getTableSessionPool(int maxSize, String database);
- default ISession getSessionConnection() throws IoTDBConnectionException {
- return getSessionConnection(TREE_SQL_DIALECT);
- }
+ ISession getSessionConnection() throws IoTDBConnectionException;
- ISession getSessionConnection(String sqlDialect) throws
IoTDBConnectionException;
+ ISession getSessionConnection(String userName, String password)
+ throws IoTDBConnectionException;
- ISession getSessionConnectionWithDB(String sqlDialect, String database)
+ ISession getSessionConnection(List<String> nodeUrls)
throws IoTDBConnectionException;
- default ISession getSessionConnection(String userName, String password)
- throws IoTDBConnectionException {
- return getSessionConnection(userName, password, TREE_SQL_DIALECT);
- }
+ ITableSession getTableSessionConnection() throws IoTDBConnectionException;
- ISession getSessionConnection(String userName, String password, String
sqlDialect)
+ ITableSession getTableSessionConnectionWithDB(String database)
throws IoTDBConnectionException;
- default ISession getSessionConnection(List<String> nodeUrls) throws
IoTDBConnectionException {
- return getSessionConnection(nodeUrls, TREE_SQL_DIALECT);
- }
-
- ISession getSessionConnection(List<String> nodeUrls, String sqlDialect)
+ ITableSession getTableSessionConnection(List<String> nodeUrls)
throws IoTDBConnectionException;
/**
diff --git
a/integration-test/src/test/java/org/apache/iotdb/pipe/it/tablemodel/TableModelUtils.java
b/integration-test/src/test/java/org/apache/iotdb/pipe/it/tablemodel/TableModelUtils.java
index 4c8ff89b024..2447a1fae84 100644
---
a/integration-test/src/test/java/org/apache/iotdb/pipe/it/tablemodel/TableModelUtils.java
+++
b/integration-test/src/test/java/org/apache/iotdb/pipe/it/tablemodel/TableModelUtils.java
@@ -20,8 +20,9 @@
package org.apache.iotdb.pipe.it.tablemodel;
import org.apache.iotdb.db.it.utils.TestUtils;
-import org.apache.iotdb.isession.IPooledSession;
+import org.apache.iotdb.isession.ITableSession;
import org.apache.iotdb.isession.pool.ISessionPool;
+import org.apache.iotdb.isession.pool.ITableSessionPool;
import org.apache.iotdb.it.env.cluster.node.DataNodeWrapper;
import org.apache.iotdb.itbase.env.BaseEnv;
import org.apache.iotdb.rpc.RpcUtils;
@@ -182,10 +183,10 @@ public class TableModelUtils {
BaseEnv baseEnv,
boolean allowNullValue) {
final Tablet tablet = generateTablet(tableName, start, end,
allowNullValue);
- ISessionPool sessionPool = baseEnv.getSessionPool(1, "table");
- try (final IPooledSession session = sessionPool.getPooledSession()) {
+ ITableSessionPool tableSessionPool = baseEnv.getTableSessionPool(1);
+ try (final ITableSession session = tableSessionPool.getSession()) {
session.executeNonQueryStatement("use " + dataBaseName);
- session.insertTablet(tablet);
+ session.insert(tablet);
session.executeNonQueryStatement("flush");
return true;
} catch (Exception e) {
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBInsertTableIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBInsertTableIT.java
index 49e870e7abf..bb6ff145322 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBInsertTableIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBInsertTableIT.java
@@ -20,6 +20,7 @@
package org.apache.iotdb.relational.it.db.it;
import org.apache.iotdb.isession.ISession;
+import org.apache.iotdb.isession.ITableSession;
import org.apache.iotdb.isession.SessionDataSet;
import org.apache.iotdb.it.env.EnvFactory;
import org.apache.iotdb.it.framework.IoTDBTestRunner;
@@ -176,7 +177,7 @@ public class IoTDBInsertTableIT {
@Test
public void testPartialInsertTablet() {
- try (ISession session =
EnvFactory.getEnv().getSessionConnection(BaseEnv.TABLE_SQL_DIALECT)) {
+ try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
session.executeNonQueryStatement("use \"test\"");
session.executeNonQueryStatement("SET CONFIGURATION
enable_auto_create_schema='false'");
session.executeNonQueryStatement(
@@ -222,7 +223,7 @@ public class IoTDBInsertTableIT {
timestamp++;
}
try {
- session.insertRelationalTablet(tablet);
+ session.insert(tablet);
} catch (Exception e) {
if (!e.getMessage().contains("507")) {
fail(e.getMessage());
@@ -564,7 +565,7 @@ public class IoTDBInsertTableIT {
}
// table case sensitivity with record and auto creation
- try (ISession session =
EnvFactory.getEnv().getSessionConnection(BaseEnv.TABLE_SQL_DIALECT)) {
+ try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
session.executeNonQueryStatement("USE \"test\"");
List<IMeasurementSchema> schemaList = new ArrayList<>();
@@ -582,11 +583,11 @@ public class IoTDBInsertTableIT {
long timestamp = 0;
- for (long row = 0; row < 15; row++) {
- Object[] values = new Object[] {"id:" + row, "attr:" + row, row * 1.0};
- session.insertRelationalRecord(
- "TaBle19_2", timestamp + row, measurementIds, dataTypes,
columnTypes, values);
- }
+// for (long row = 0; row < 15; row++) {
+// Object[] values = new Object[] {"id:" + row, "attr:" + row, row *
1.0};
+// session.insertRelationalRecord(
+// "TaBle19_2", timestamp + row, measurementIds, dataTypes,
columnTypes, values);
+// }
int cnt = 0;
SessionDataSet dataSet =
@@ -603,7 +604,7 @@ public class IoTDBInsertTableIT {
}
// table case sensitivity with record and no auto creation
- try (ISession session =
EnvFactory.getEnv().getSessionConnection(BaseEnv.TABLE_SQL_DIALECT)) {
+ try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
session.executeNonQueryStatement("USE \"test\"");
session.executeNonQueryStatement(
"CREATE TABLE tAbLE19_3 (id1 string id, attr1 string attribute, "
@@ -625,11 +626,11 @@ public class IoTDBInsertTableIT {
long timestamp = 0;
- for (long row = 0; row < 15; row++) {
- Object[] values = new Object[] {"id:" + row, "attr:" + row, row * 1.0};
- session.insertRelationalRecord(
- "TaBle19_3", timestamp + row, measurementIds, dataTypes,
columnTypes, values);
- }
+// for (long row = 0; row < 15; row++) {
+// Object[] values = new Object[] {"id:" + row, "attr:" + row, row *
1.0};
+// session.insertRelationalRecord(
+// "TaBle19_3", timestamp + row, measurementIds, dataTypes,
columnTypes, values);
+// }
int cnt = 0;
SessionDataSet dataSet =
@@ -646,7 +647,7 @@ public class IoTDBInsertTableIT {
}
// table case sensitivity with tablet and no auto creation
- try (ISession session =
EnvFactory.getEnv().getSessionConnection(BaseEnv.TABLE_SQL_DIALECT)) {
+ try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
session.executeNonQueryStatement("USE \"test\"");
List<IMeasurementSchema> schemaList = new ArrayList<>();
@@ -666,13 +667,13 @@ public class IoTDBInsertTableIT {
tablet.addValue("attr1", rowIndex, "attr:" + row);
tablet.addValue("m1", rowIndex, row * 1.0);
if (tablet.rowSize == tablet.getMaxRowNumber()) {
- session.insertRelationalTablet(tablet, true);
+ session.insert(tablet);
tablet.reset();
}
}
if (tablet.rowSize != 0) {
- session.insertRelationalTablet(tablet);
+ session.insert(tablet);
tablet.reset();
}
@@ -691,7 +692,7 @@ public class IoTDBInsertTableIT {
}
// table case sensitivity with tablet and auto creation
- try (ISession session =
EnvFactory.getEnv().getSessionConnection(BaseEnv.TABLE_SQL_DIALECT)) {
+ try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
session.executeNonQueryStatement("USE \"test\"");
session.executeNonQueryStatement(
"CREATE TABLE tAbLE19_5 (id1 string id, attr1 string attribute, "
@@ -715,13 +716,13 @@ public class IoTDBInsertTableIT {
tablet.addValue("attr1", rowIndex, "attr:" + row);
tablet.addValue("m1", rowIndex, row * 1.0);
if (tablet.rowSize == tablet.getMaxRowNumber()) {
- session.insertRelationalTablet(tablet, true);
+ session.insert(tablet);
tablet.reset();
}
}
if (tablet.rowSize != 0) {
- session.insertRelationalTablet(tablet);
+ session.insert(tablet);
tablet.reset();
}
@@ -742,7 +743,7 @@ public class IoTDBInsertTableIT {
@Test
public void testInsertKeyword() throws IoTDBConnectionException,
StatementExecutionException {
- try (ISession session =
EnvFactory.getEnv().getSessionConnection(BaseEnv.TABLE_SQL_DIALECT)) {
+ try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
session.executeNonQueryStatement("USE \"test\"");
session.executeNonQueryStatement(
"create table table20 ("
@@ -806,7 +807,7 @@ public class IoTDBInsertTableIT {
tablet.addValue("timestamp", rowIndex, 1L);
tablet.addValue("date", rowIndex, LocalDate.parse("2024-08-15"));
}
- session.insertRelationalTablet(tablet, true);
+ session.insert(tablet);
SessionDataSet rs1 =
session.executeQueryStatement(
@@ -901,7 +902,7 @@ public class IoTDBInsertTableIT {
public void testInsertTabletWithTTL()
throws IoTDBConnectionException, StatementExecutionException {
long ttl = 1;
- try (ISession session =
EnvFactory.getEnv().getSessionConnection(BaseEnv.TABLE_SQL_DIALECT)) {
+ try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
session.executeNonQueryStatement("use \"test\"");
session.executeNonQueryStatement("create table sg23 (id1 string id, s1
int64 measurement)");
session.executeNonQueryStatement("alter table sg23 set properties TTL="
+ ttl);
@@ -922,7 +923,7 @@ public class IoTDBInsertTableIT {
tablet.addValue("s1", rowIndex, row);
}
try {
- session.insertRelationalTablet(tablet, true);
+ session.insert(tablet);
fail();
} catch (Exception e) {
Assert.assertTrue(e.getMessage().contains("less than ttl time bound"));
@@ -940,7 +941,7 @@ public class IoTDBInsertTableIT {
}
try {
- session.insertRelationalTablet(tablet, true);
+ session.insert(tablet);
fail();
} catch (Exception e) {
Assert.assertTrue(e.getMessage().contains("less than ttl time bound"));
@@ -962,7 +963,7 @@ public class IoTDBInsertTableIT {
@Test
public void testInsertUnsequenceData()
throws IoTDBConnectionException, StatementExecutionException {
- try (ISession session =
EnvFactory.getEnv().getSessionConnection(BaseEnv.TABLE_SQL_DIALECT)) {
+ try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
session.executeNonQueryStatement("USE \"test\"");
// the table is missing column "m2"
session.executeNonQueryStatement(
@@ -995,7 +996,7 @@ public class IoTDBInsertTableIT {
tablet.addValue("m2", rowIndex, row * 1.0);
if (tablet.rowSize == tablet.getMaxRowNumber()) {
try {
- session.insertRelationalTablet(tablet, true);
+ session.insert(tablet);
} catch (StatementExecutionException e) {
// a partial insertion should be reported
if (!e.getMessage()
@@ -1019,7 +1020,7 @@ public class IoTDBInsertTableIT {
tablet.addValue("m2", rowIndex, row * 1.0);
if (tablet.rowSize == tablet.getMaxRowNumber()) {
try {
- session.insertRelationalTablet(tablet, true);
+ session.insert(tablet);
} catch (StatementExecutionException e) {
if (!e.getMessage()
.equals(
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/orderBy/IoTDBOrderByTableIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/orderBy/IoTDBOrderByTableIT.java
index d3cc7b19f36..e823a918af1 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/orderBy/IoTDBOrderByTableIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/orderBy/IoTDBOrderByTableIT.java
@@ -20,6 +20,7 @@
package org.apache.iotdb.relational.it.query.old.orderBy;
import org.apache.iotdb.isession.ISession;
+import org.apache.iotdb.isession.ITableSession;
import org.apache.iotdb.it.env.EnvFactory;
import org.apache.iotdb.it.framework.IoTDBTestRunner;
import org.apache.iotdb.itbase.category.TableClusterIT;
@@ -1418,161 +1419,157 @@ public class IoTDBOrderByTableIT {
testLastQueryOrderBy(sql, ans);
}
- @Ignore
- @Test
- public void lastQueryOrderBy4() {
- String[][] ans =
- new String[][] {
- {"51536000000", "51536000000", "51536000000", "51536000000"},
- {"root.sg.d2.num", "root.sg.d.num", "root.sg.d2.bigNum",
"root.sg.d.bigNum"},
- {"15", "15", "3147483648", "3147483648"},
- {"INT32", "INT32", "INT64", "INT64"}
- };
- String sql = "select last bigNum,num from root.** order by value,
timeseries desc";
- testLastQueryOrderBy(sql, ans);
- }
-
- @Ignore
- @Test
- public void lastQueryOrderBy5() {
- String[][] ans =
- new String[][] {
- {"51536000000", "51536000000", "51536000000", "51536000000"},
- {"root.sg.d2.num", "root.sg.d.num", "root.sg.d2.bigNum",
"root.sg.d.bigNum"},
- {"15", "15", "3147483648", "3147483648"},
- {"INT32", "INT32", "INT64", "INT64"}
- };
- String sql = "select last bigNum,num from root.** order by datatype,
timeseries desc";
- testLastQueryOrderBy(sql, ans);
- }
-
- private static List<Long> TIMES =
- Arrays.asList(
- 0L,
- 20L,
- 40L,
- 80L,
- 100L,
- 31536000000L,
- 31536000100L,
- 31536000500L,
- 31536001000L,
- 31536010000L,
- 31536100000L,
- 41536000000L,
- 41536000020L,
- 41536900000L,
- 51536000000L);
-
- protected static void sessionInsertData1() {
- try (ISession session =
EnvFactory.getEnv().getSessionConnection(TABLE_SQL_DIALECT)) {
-
- session.open();
- session.executeNonQueryStatement("CREATE DATABASE \"db0\"");
- session.executeNonQueryStatement("USE \"db0\"");
-
- List<IMeasurementSchema> schemaList = new ArrayList<>();
- schemaList.add(new MeasurementSchema("device", TSDataType.STRING));
- schemaList.add(new MeasurementSchema("attr1", TSDataType.STRING));
- schemaList.add(new MeasurementSchema("num", TSDataType.INT32));
- schemaList.add(new MeasurementSchema("bigNum", TSDataType.INT64));
- schemaList.add(new MeasurementSchema("floatNum", TSDataType.DOUBLE));
- schemaList.add(new MeasurementSchema("str", TSDataType.TEXT));
- schemaList.add(new MeasurementSchema("bool", TSDataType.BOOLEAN));
- final List<Tablet.ColumnType> columnTypes =
- Arrays.asList(
- Tablet.ColumnType.ID,
- Tablet.ColumnType.ATTRIBUTE,
- Tablet.ColumnType.MEASUREMENT,
- Tablet.ColumnType.MEASUREMENT,
- Tablet.ColumnType.MEASUREMENT,
- Tablet.ColumnType.MEASUREMENT,
- Tablet.ColumnType.MEASUREMENT);
- List<String> measurementIds =
- schemaList.stream()
- .map(IMeasurementSchema::getMeasurementId)
- .collect(Collectors.toList());
- List<TSDataType> dataTypes =
-
schemaList.stream().map(IMeasurementSchema::getType).collect(Collectors.toList());
-
- List<Object[]> values =
- Arrays.asList(
- new Object[] {"d1", "a1", 3, 2947483648L, 231.2121, "coconut",
false},
- new Object[] {"d1", "a1", 2, 2147483648L, 434.12, "pineapple",
true},
- new Object[] {"d1", "a1", 1, 2247483648L, 12.123, "apricot",
true},
- new Object[] {"d1", "a1", 9, 2147483646L, 43.12, "apple", false},
- new Object[] {"d1", "a1", 8, 2147483964L, 4654.231, "papaya",
true},
- new Object[] {"d1", "a1", 6, 2147483650L, 1231.21, "banana",
true},
- new Object[] {"d1", "a1", 10, 3147483648L, 231.55, "pumelo",
false},
- new Object[] {"d1", "a1", 4, 2147493648L, 213.1, "peach", false},
- new Object[] {"d1", "a1", 5, 2149783648L, 56.32, "orange",
false},
- new Object[] {"d1", "a1", 7, 2147983648L, 213.112, "lemon",
true},
- new Object[] {"d1", "a1", 11, 2147468648L, 54.121, "pitaya",
false},
- new Object[] {"d1", "a1", 12, 2146483648L, 45.231, "strawberry",
false},
- new Object[] {"d1", "a1", 14, 2907483648L, 231.34, "cherry",
false},
- new Object[] {"d1", "a1", 13, 2107483648L, 54.12, "lychee",
true},
- new Object[] {"d1", "a1", 15, 3147483648L, 235.213,
"watermelon", true});
- for (int i = 0; i < TIMES.size(); i++) {
- session.insertRelationalRecord(
- "table0", TIMES.get(i), measurementIds, dataTypes, columnTypes,
values.get(i));
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- protected static void sessionInsertData2() {
- try (ISession session =
EnvFactory.getEnv().getSessionConnection(TABLE_SQL_DIALECT)) {
-
- session.open();
- session.executeNonQueryStatement("USE \"db0\"");
-
- List<IMeasurementSchema> schemaList = new ArrayList<>();
- schemaList.add(new MeasurementSchema("device", TSDataType.STRING));
- schemaList.add(new MeasurementSchema("attr1", TSDataType.STRING));
- schemaList.add(new MeasurementSchema("num", TSDataType.INT32));
- schemaList.add(new MeasurementSchema("bigNum", TSDataType.INT64));
- schemaList.add(new MeasurementSchema("floatNum", TSDataType.DOUBLE));
- schemaList.add(new MeasurementSchema("str", TSDataType.TEXT));
- schemaList.add(new MeasurementSchema("bool", TSDataType.BOOLEAN));
- final List<Tablet.ColumnType> columnTypes =
- Arrays.asList(
- Tablet.ColumnType.ID,
- Tablet.ColumnType.ATTRIBUTE,
- Tablet.ColumnType.MEASUREMENT,
- Tablet.ColumnType.MEASUREMENT,
- Tablet.ColumnType.MEASUREMENT,
- Tablet.ColumnType.MEASUREMENT,
- Tablet.ColumnType.MEASUREMENT);
- List<String> measurementIds =
- schemaList.stream()
- .map(IMeasurementSchema::getMeasurementId)
- .collect(Collectors.toList());
- List<TSDataType> dataTypes =
-
schemaList.stream().map(IMeasurementSchema::getType).collect(Collectors.toList());
- List<Object[]> values =
- Arrays.asList(
- new Object[] {"d2", "a2", 3, 2947483648L, 231.2121, "coconut",
false},
- new Object[] {"d2", "a2", 2, 2147483648L, 434.12, "pineapple",
true},
- new Object[] {"d2", "a2", 1, 2247483648L, 12.123, "apricot",
true},
- new Object[] {"d2", "a2", 9, 2147483646L, 43.12, "apple", false},
- new Object[] {"d2", "a2", 8, 2147483964L, 4654.231, "papaya",
true},
- new Object[] {"d2", "a2", 6, 2147483650L, 1231.21, "banana",
true},
- new Object[] {"d2", "a2", 10, 3147483648L, 231.55, "pumelo",
false},
- new Object[] {"d2", "a2", 4, 2147493648L, 213.1, "peach", false},
- new Object[] {"d2", "a2", 5, 2149783648L, 56.32, "orange",
false},
- new Object[] {"d2", "a2", 7, 2147983648L, 213.112, "lemon",
true},
- new Object[] {"d2", "a2", 11, 2147468648L, 54.121, "pitaya",
false},
- new Object[] {"d2", "a2", 12, 2146483648L, 45.231, "strawberry",
false},
- new Object[] {"d2", "a2", 14, 2907483648L, 231.34, "cherry",
false},
- new Object[] {"d2", "a2", 13, 2107483648L, 54.12, "lychee",
true},
- new Object[] {"d2", "a2", 15, 3147483648L, 235.213,
"watermelon", true});
- for (int i = 0; i < TIMES.size(); i++) {
- session.insertRelationalRecord(
- "table0", TIMES.get(i), measurementIds, dataTypes, columnTypes,
values.get(i));
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
+// @Ignore
+// @Test
+// public void lastQueryOrderBy4() {
+// String[][] ans =
+// new String[][] {
+// {"51536000000", "51536000000", "51536000000", "51536000000"},
+// {"root.sg.d2.num", "root.sg.d.num", "root.sg.d2.bigNum",
"root.sg.d.bigNum"},
+// {"15", "15", "3147483648", "3147483648"},
+// {"INT32", "INT32", "INT64", "INT64"}
+// };
+// String sql = "select last bigNum,num from root.** order by value,
timeseries desc";
+// testLastQueryOrderBy(sql, ans);
+// }
+//
+// @Ignore
+// @Test
+// public void lastQueryOrderBy5() {
+// String[][] ans =
+// new String[][] {
+// {"51536000000", "51536000000", "51536000000", "51536000000"},
+// {"root.sg.d2.num", "root.sg.d.num", "root.sg.d2.bigNum",
"root.sg.d.bigNum"},
+// {"15", "15", "3147483648", "3147483648"},
+// {"INT32", "INT32", "INT64", "INT64"}
+// };
+// String sql = "select last bigNum,num from root.** order by datatype,
timeseries desc";
+// testLastQueryOrderBy(sql, ans);
+// }
+//
+// private static List<Long> TIMES =
+// Arrays.asList(
+// 0L,
+// 20L,
+// 40L,
+// 80L,
+// 100L,
+// 31536000000L,
+// 31536000100L,
+// 31536000500L,
+// 31536001000L,
+// 31536010000L,
+// 31536100000L,
+// 41536000000L,
+// 41536000020L,
+// 41536900000L,
+// 51536000000L);
+//
+// protected static void sessionInsertData1() {
+// try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
+// session.executeNonQueryStatement("CREATE DATABASE \"db0\"");
+// session.executeNonQueryStatement("USE \"db0\"");
+//
+// List<IMeasurementSchema> schemaList = new ArrayList<>();
+// schemaList.add(new MeasurementSchema("device", TSDataType.STRING));
+// schemaList.add(new MeasurementSchema("attr1", TSDataType.STRING));
+// schemaList.add(new MeasurementSchema("num", TSDataType.INT32));
+// schemaList.add(new MeasurementSchema("bigNum", TSDataType.INT64));
+// schemaList.add(new MeasurementSchema("floatNum", TSDataType.DOUBLE));
+// schemaList.add(new MeasurementSchema("str", TSDataType.TEXT));
+// schemaList.add(new MeasurementSchema("bool", TSDataType.BOOLEAN));
+// final List<Tablet.ColumnType> columnTypes =
+// Arrays.asList(
+// Tablet.ColumnType.ID,
+// Tablet.ColumnType.ATTRIBUTE,
+// Tablet.ColumnType.MEASUREMENT,
+// Tablet.ColumnType.MEASUREMENT,
+// Tablet.ColumnType.MEASUREMENT,
+// Tablet.ColumnType.MEASUREMENT,
+// Tablet.ColumnType.MEASUREMENT);
+// List<String> measurementIds =
+// schemaList.stream()
+// .map(IMeasurementSchema::getMeasurementId)
+// .collect(Collectors.toList());
+// List<TSDataType> dataTypes =
+//
schemaList.stream().map(IMeasurementSchema::getType).collect(Collectors.toList());
+//
+// List<Object[]> values =
+// Arrays.asList(
+// new Object[] {"d1", "a1", 3, 2947483648L, 231.2121, "coconut",
false},
+// new Object[] {"d1", "a1", 2, 2147483648L, 434.12, "pineapple",
true},
+// new Object[] {"d1", "a1", 1, 2247483648L, 12.123, "apricot",
true},
+// new Object[] {"d1", "a1", 9, 2147483646L, 43.12, "apple",
false},
+// new Object[] {"d1", "a1", 8, 2147483964L, 4654.231, "papaya",
true},
+// new Object[] {"d1", "a1", 6, 2147483650L, 1231.21, "banana",
true},
+// new Object[] {"d1", "a1", 10, 3147483648L, 231.55, "pumelo",
false},
+// new Object[] {"d1", "a1", 4, 2147493648L, 213.1, "peach",
false},
+// new Object[] {"d1", "a1", 5, 2149783648L, 56.32, "orange",
false},
+// new Object[] {"d1", "a1", 7, 2147983648L, 213.112, "lemon",
true},
+// new Object[] {"d1", "a1", 11, 2147468648L, 54.121, "pitaya",
false},
+// new Object[] {"d1", "a1", 12, 2146483648L, 45.231,
"strawberry", false},
+// new Object[] {"d1", "a1", 14, 2907483648L, 231.34, "cherry",
false},
+// new Object[] {"d1", "a1", 13, 2107483648L, 54.12, "lychee",
true},
+// new Object[] {"d1", "a1", 15, 3147483648L, 235.213,
"watermelon", true});
+// for (int i = 0; i < TIMES.size(); i++) {
+// session.insertRelationalRecord(
+// "table0", TIMES.get(i), measurementIds, dataTypes, columnTypes,
values.get(i));
+// }
+// } catch (Exception e) {
+// e.printStackTrace();
+// }
+// }
+
+// protected static void sessionInsertData2() {
+// try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
+// session.executeNonQueryStatement("USE \"db0\"");
+//
+// List<IMeasurementSchema> schemaList = new ArrayList<>();
+// schemaList.add(new MeasurementSchema("device", TSDataType.STRING));
+// schemaList.add(new MeasurementSchema("attr1", TSDataType.STRING));
+// schemaList.add(new MeasurementSchema("num", TSDataType.INT32));
+// schemaList.add(new MeasurementSchema("bigNum", TSDataType.INT64));
+// schemaList.add(new MeasurementSchema("floatNum", TSDataType.DOUBLE));
+// schemaList.add(new MeasurementSchema("str", TSDataType.TEXT));
+// schemaList.add(new MeasurementSchema("bool", TSDataType.BOOLEAN));
+// final List<Tablet.ColumnType> columnTypes =
+// Arrays.asList(
+// Tablet.ColumnType.ID,
+// Tablet.ColumnType.ATTRIBUTE,
+// Tablet.ColumnType.MEASUREMENT,
+// Tablet.ColumnType.MEASUREMENT,
+// Tablet.ColumnType.MEASUREMENT,
+// Tablet.ColumnType.MEASUREMENT,
+// Tablet.ColumnType.MEASUREMENT);
+// List<String> measurementIds =
+// schemaList.stream()
+// .map(IMeasurementSchema::getMeasurementId)
+// .collect(Collectors.toList());
+// List<TSDataType> dataTypes =
+//
schemaList.stream().map(IMeasurementSchema::getType).collect(Collectors.toList());
+// List<Object[]> values =
+// Arrays.asList(
+// new Object[] {"d2", "a2", 3, 2947483648L, 231.2121, "coconut",
false},
+// new Object[] {"d2", "a2", 2, 2147483648L, 434.12, "pineapple",
true},
+// new Object[] {"d2", "a2", 1, 2247483648L, 12.123, "apricot",
true},
+// new Object[] {"d2", "a2", 9, 2147483646L, 43.12, "apple",
false},
+// new Object[] {"d2", "a2", 8, 2147483964L, 4654.231, "papaya",
true},
+// new Object[] {"d2", "a2", 6, 2147483650L, 1231.21, "banana",
true},
+// new Object[] {"d2", "a2", 10, 3147483648L, 231.55, "pumelo",
false},
+// new Object[] {"d2", "a2", 4, 2147493648L, 213.1, "peach",
false},
+// new Object[] {"d2", "a2", 5, 2149783648L, 56.32, "orange",
false},
+// new Object[] {"d2", "a2", 7, 2147983648L, 213.112, "lemon",
true},
+// new Object[] {"d2", "a2", 11, 2147468648L, 54.121, "pitaya",
false},
+// new Object[] {"d2", "a2", 12, 2146483648L, 45.231,
"strawberry", false},
+// new Object[] {"d2", "a2", 14, 2907483648L, 231.34, "cherry",
false},
+// new Object[] {"d2", "a2", 13, 2107483648L, 54.12, "lychee",
true},
+// new Object[] {"d2", "a2", 15, 3147483648L, 235.213,
"watermelon", true});
+// for (int i = 0; i < TIMES.size(); i++) {
+// session.insertRelationalRecord(
+// "table0", TIMES.get(i), measurementIds, dataTypes, columnTypes,
values.get(i));
+// }
+// } catch (Exception e) {
+// e.printStackTrace();
+// }
+// }
}
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/session/IoTDBTableModelSessionIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/session/IoTDBTableModelSessionIT.java
index eb64a57bde5..61f048e1af7 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/session/IoTDBTableModelSessionIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/session/IoTDBTableModelSessionIT.java
@@ -19,7 +19,7 @@
package org.apache.iotdb.relational.it.session;
-import org.apache.iotdb.isession.ISession;
+import org.apache.iotdb.isession.ITableSession;
import org.apache.iotdb.isession.SessionDataSet;
import org.apache.iotdb.it.env.EnvFactory;
import org.apache.iotdb.it.framework.IoTDBTestRunner;
@@ -61,8 +61,8 @@ public class IoTDBTableModelSessionIT {
final String[] table2Names = new String[] {"table2"};
final String[] table2ttls = new String[] {"6600000"};
- try (final ISession session =
- EnvFactory.getEnv().getSessionConnectionWithDB("table", "test2")) {
+ try (final ITableSession session =
+ EnvFactory.getEnv().getTableSessionConnectionWithDB("test2")) {
session.executeNonQueryStatement("CREATE DATABASE test1");
session.executeNonQueryStatement("CREATE DATABASE test2");
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/session/pool/IoTDBInsertTableSessionPoolIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/session/pool/IoTDBInsertTableSessionPoolIT.java
index c4f95f846f2..3c71417404e 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/session/pool/IoTDBInsertTableSessionPoolIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/session/pool/IoTDBInsertTableSessionPoolIT.java
@@ -19,9 +19,9 @@
package org.apache.iotdb.relational.it.session.pool;
-import org.apache.iotdb.isession.IPooledSession;
+import org.apache.iotdb.isession.ITableSession;
import org.apache.iotdb.isession.SessionDataSet;
-import org.apache.iotdb.isession.pool.ISessionPool;
+import org.apache.iotdb.isession.pool.ITableSessionPool;
import org.apache.iotdb.it.env.EnvFactory;
import org.apache.iotdb.it.framework.IoTDBTestRunner;
import org.apache.iotdb.itbase.category.TableClusterIT;
@@ -61,8 +61,8 @@ public class IoTDBInsertTableSessionPoolIT {
@BeforeClass
public static void setUp() throws Exception {
EnvFactory.getEnv().initClusterEnvironment();
- ISessionPool sessionPool = EnvFactory.getEnv().getSessionPool(1, "table");
- try (final IPooledSession session = sessionPool.getPooledSession()) {
+ ITableSessionPool sessionPool = EnvFactory.getEnv().getTableSessionPool(1);
+ try (final ITableSession session = sessionPool.getSession()) {
session.executeNonQueryStatement("create database if not exists test");
}
}
@@ -74,8 +74,8 @@ public class IoTDBInsertTableSessionPoolIT {
@Test
public void testPartialInsertTablet() {
- ISessionPool sessionPool = EnvFactory.getEnv().getSessionPool(1, "table");
- try (final IPooledSession session = sessionPool.getPooledSession()) {
+ ITableSessionPool sessionPool = EnvFactory.getEnv().getTableSessionPool(1);
+ try (final ITableSession session = sessionPool.getSession()) {
session.executeNonQueryStatement("use \"test\"");
session.executeNonQueryStatement("SET CONFIGURATION
enable_auto_create_schema='false'");
session.executeNonQueryStatement(
@@ -121,7 +121,7 @@ public class IoTDBInsertTableSessionPoolIT {
timestamp++;
}
try {
- session.insertTablet(tablet);
+ session.insert(tablet);
} catch (Exception e) {
if (!e.getMessage().contains("507")) {
fail(e.getMessage());
@@ -130,11 +130,11 @@ public class IoTDBInsertTableSessionPoolIT {
session.executeNonQueryStatement("SET CONFIGURATION
enable_auto_create_schema='false'");
}
try (SessionDataSet dataSet = session.executeQueryStatement("SELECT *
FROM sg6")) {
- assertEquals(dataSet.getColumnNames().size(), 4);
- assertEquals(dataSet.getColumnNames().get(0), "time");
- assertEquals(dataSet.getColumnNames().get(1), "id1");
- assertEquals(dataSet.getColumnNames().get(2), "s1");
- assertEquals(dataSet.getColumnNames().get(3), "s2");
+ assertEquals(4, dataSet.getColumnNames().size());
+ assertEquals("time", dataSet.getColumnNames().get(0));
+ assertEquals("id1", dataSet.getColumnNames().get(1));
+ assertEquals("s1", dataSet.getColumnNames().get(2));
+ assertEquals("s2", dataSet.getColumnNames().get(3));
int cnt = 0;
while (dataSet.hasNext()) {
RowRecord rowRecord = dataSet.next();
@@ -153,8 +153,8 @@ public class IoTDBInsertTableSessionPoolIT {
@Test
public void testInsertKeyword() throws IoTDBConnectionException,
StatementExecutionException {
- ISessionPool sessionPool = EnvFactory.getEnv().getSessionPool(1, "table");
- try (final IPooledSession session = sessionPool.getPooledSession()) {
+ ITableSessionPool sessionPool = EnvFactory.getEnv().getTableSessionPool(1);
+ try (final ITableSession session = sessionPool.getSession()) {
session.executeNonQueryStatement("USE \"test\"");
session.executeNonQueryStatement(
"create table table20 ("
@@ -218,7 +218,7 @@ public class IoTDBInsertTableSessionPoolIT {
tablet.addValue("timestamp", rowIndex, 1L);
tablet.addValue("date", rowIndex, LocalDate.parse("2024-08-15"));
}
- session.insertTablet(tablet);
+ session.insert(tablet);
SessionDataSet rs1 =
session.executeQueryStatement(
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/session/pool/IoTDBTableModelSessionPoolIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/session/pool/IoTDBTableModelSessionPoolIT.java
index 7e5590010c4..d1d5e41ff5c 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/session/pool/IoTDBTableModelSessionPoolIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/session/pool/IoTDBTableModelSessionPoolIT.java
@@ -19,9 +19,9 @@
package org.apache.iotdb.relational.it.session.pool;
-import org.apache.iotdb.isession.IPooledSession;
+import org.apache.iotdb.isession.ITableSession;
import org.apache.iotdb.isession.SessionDataSet;
-import org.apache.iotdb.isession.pool.ISessionPool;
+import org.apache.iotdb.isession.pool.ITableSessionPool;
import org.apache.iotdb.it.env.EnvFactory;
import org.apache.iotdb.it.framework.IoTDBTestRunner;
import org.apache.iotdb.itbase.category.TableClusterIT;
@@ -63,8 +63,8 @@ public class IoTDBTableModelSessionPoolIT {
final String[] table2Names = new String[] {"table2"};
final String[] table2ttls = new String[] {"6600000"};
- ISessionPool sessionPool = EnvFactory.getEnv().getSessionPool(1, "table");
- try (final IPooledSession session = sessionPool.getPooledSession()) {
+ ITableSessionPool sessionPool = EnvFactory.getEnv().getTableSessionPool(1);
+ try (final ITableSession session = sessionPool.getSession()) {
session.executeNonQueryStatement("CREATE DATABASE test1");
session.executeNonQueryStatement("CREATE DATABASE test2");
@@ -98,7 +98,7 @@ public class IoTDBTableModelSessionPoolIT {
fail(e.getMessage());
}
- try (final IPooledSession session = sessionPool.getPooledSession()) {
+ try (final ITableSession session = sessionPool.getSession()) {
// current session's database is still test2
try (final SessionDataSet dataSet = session.executeQueryStatement("SHOW
TABLES")) {
int cnt = 0;
@@ -123,9 +123,9 @@ public class IoTDBTableModelSessionPoolIT {
}
// specify database in constructor
- sessionPool = EnvFactory.getEnv().getSessionPool(1, "table", "test1");
+ sessionPool = EnvFactory.getEnv().getTableSessionPool(1, "test1");
- try (final IPooledSession session = sessionPool.getPooledSession()) {
+ try (final ITableSession session = sessionPool.getSession()) {
// current session's database is test1
try (final SessionDataSet dataSet = session.executeQueryStatement("SHOW
TABLES")) {
@@ -168,7 +168,7 @@ public class IoTDBTableModelSessionPoolIT {
}
// after putting back, the session's database should be changed back to
default test1
- try (final IPooledSession session = sessionPool.getPooledSession()) {
+ try (final ITableSession session = sessionPool.getSession()) {
try (final SessionDataSet dataSet = session.executeQueryStatement("SHOW
TABLES")) {
int cnt = 0;
diff --git
a/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionRelationalIT.java
b/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionRelationalIT.java
index d77b2c81907..eea3a594c7e 100644
---
a/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionRelationalIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionRelationalIT.java
@@ -19,6 +19,7 @@
package org.apache.iotdb.session.it;
import org.apache.iotdb.isession.ISession;
+import org.apache.iotdb.isession.ITableSession;
import org.apache.iotdb.isession.SessionDataSet;
import org.apache.iotdb.it.env.EnvFactory;
import org.apache.iotdb.it.framework.IoTDBTestRunner;
@@ -64,7 +65,7 @@ public class IoTDBSessionRelationalIT {
@Before
public void setUp() throws Exception {
- try (ISession session =
EnvFactory.getEnv().getSessionConnection(TABLE_SQL_DIALECT)) {
+ try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
session.executeNonQueryStatement("CREATE DATABASE IF NOT EXISTS db1");
session.executeNonQueryStatement("CREATE DATABASE IF NOT EXISTS db2");
}
@@ -72,7 +73,7 @@ public class IoTDBSessionRelationalIT {
@After
public void tearDown() throws Exception {
- try (ISession session =
EnvFactory.getEnv().getSessionConnection(TABLE_SQL_DIALECT)) {
+ try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
session.executeNonQueryStatement("DROP DATABASE IF EXISTS db1");
}
}
@@ -85,7 +86,7 @@ public class IoTDBSessionRelationalIT {
// for manual debugging
public static void main(String[] args)
throws IoTDBConnectionException, StatementExecutionException {
- try (ISession session =
EnvFactory.getEnv().getSessionConnection(TABLE_SQL_DIALECT)) {
+ try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
session.executeNonQueryStatement("CREATE DATABASE \"db1\"");
session.executeNonQueryStatement("CREATE DATABASE \"db2\"");
session.executeNonQueryStatement("USE \"db1\"");
@@ -95,7 +96,7 @@ public class IoTDBSessionRelationalIT {
+ "measurement)");
}
// insert without db
- try (ISession session =
EnvFactory.getEnv().getSessionConnection(TABLE_SQL_DIALECT)) {
+ try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
long timestamp;
// no db in session and sql
@@ -141,9 +142,7 @@ public class IoTDBSessionRelationalIT {
private static void insertRelationalTabletPerformanceTest()
throws IoTDBConnectionException, StatementExecutionException {
- try (ISession session =
- new
Session.Builder().host("127.0.0.1").port(6667).sqlDialect(TABLE_SQL_DIALECT).build())
{
- session.open();
+ try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
session.executeNonQueryStatement("USE \"db1\"");
session.executeNonQueryStatement(
"CREATE TABLE table1 (id1 string id, attr1 string attribute, "
@@ -167,13 +166,13 @@ public class IoTDBSessionRelationalIT {
tablet.addValue("attr1", rowIndex, "attr:" + row);
tablet.addValue("m1", rowIndex, row * 1.0);
if (tablet.rowSize == tablet.getMaxRowNumber()) {
- session.insertRelationalTablet(tablet, true);
+ session.insert(tablet);
tablet.reset();
}
}
if (tablet.rowSize != 0) {
- session.insertRelationalTablet(tablet);
+ session.insert(tablet);
tablet.reset();
}
@@ -186,13 +185,13 @@ public class IoTDBSessionRelationalIT {
tablet.addValue("attr1", rowIndex, "attr:" + row);
tablet.addValue("m1", rowIndex, row * 1.0);
if (tablet.rowSize == tablet.getMaxRowNumber()) {
- session.insertRelationalTablet(tablet, true);
+ session.insert(tablet);
tablet.reset();
}
}
if (tablet.rowSize != 0) {
- session.insertRelationalTablet(tablet);
+ session.insert(tablet);
tablet.reset();
}
@@ -211,7 +210,7 @@ public class IoTDBSessionRelationalIT {
@Category({LocalStandaloneIT.class, ClusterIT.class})
public void insertRelationalSqlTest()
throws IoTDBConnectionException, StatementExecutionException {
- try (ISession session =
EnvFactory.getEnv().getSessionConnection(TABLE_SQL_DIALECT)) {
+ try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
session.executeNonQueryStatement("USE \"db1\"");
session.executeNonQueryStatement(
"CREATE TABLE table1 (id1 string id, attr1 string attribute, "
@@ -259,99 +258,14 @@ public class IoTDBSessionRelationalIT {
}
}
- @Test
- @Category({LocalStandaloneIT.class, ClusterIT.class})
- public void partialInsertRelationalRowTest()
- throws IoTDBConnectionException, StatementExecutionException {
- try (ISession session =
EnvFactory.getEnv().getSessionConnection(TREE_SQL_DIALECT)) {
- // disable auto-creation only for this test
- session.executeNonQueryStatement("SET CONFIGURATION
\"enable_auto_create_schema\"=\"false\"");
- }
- try (ISession session =
EnvFactory.getEnv().getSessionConnection(TABLE_SQL_DIALECT)) {
- session.executeNonQueryStatement("USE \"db1\"");
- // the table is missing column "m2"
- session.executeNonQueryStatement(
- "CREATE TABLE table2 (id1 string id, attr1 string attribute, "
- + "m1 double "
- + "measurement)");
-
- // the insertion contains "m2"
- List<IMeasurementSchema> schemaList = new ArrayList<>();
- schemaList.add(new MeasurementSchema("id1", TSDataType.STRING));
- schemaList.add(new MeasurementSchema("attr1", TSDataType.STRING));
- schemaList.add(new MeasurementSchema("m1", TSDataType.DOUBLE));
- schemaList.add(new MeasurementSchema("m2", TSDataType.DOUBLE));
- final List<ColumnType> columnTypes =
- Arrays.asList(
- ColumnType.ID, ColumnType.ATTRIBUTE, ColumnType.MEASUREMENT,
ColumnType.MEASUREMENT);
- List<String> measurementIds =
- schemaList.stream()
- .map(IMeasurementSchema::getMeasurementId)
- .collect(Collectors.toList());
- List<TSDataType> dataTypes =
-
schemaList.stream().map(IMeasurementSchema::getType).collect(Collectors.toList());
-
- long timestamp = 0;
-
- for (long row = 0; row < 15; row++) {
- Object[] values = new Object[] {"id:" + row, "attr:" + row, row * 1.0,
row * 1.0};
- try {
- session.insertRelationalRecord(
- "table2", timestamp + row, measurementIds, dataTypes,
columnTypes, values);
- } catch (StatementExecutionException e) {
- if (!e.getMessage()
- .equals(
- "507: Fail to insert measurements [m2] caused by [Column m2
does not exists or fails to be created]")) {
- throw e;
- }
- }
- }
-
- session.executeNonQueryStatement("FLush");
-
- for (long row = 15; row < 30; row++) {
- Object[] values = new Object[] {"id:" + row, "attr:" + row, row * 1.0,
row * 1.0};
- try {
- session.insertRelationalRecord(
- "table2", timestamp + row, measurementIds, dataTypes,
columnTypes, values);
- } catch (StatementExecutionException e) {
- if (!e.getMessage()
- .equals(
- "507: Fail to insert measurements [m2] caused by [Column m2
does not exists or fails to be created]")) {
- throw e;
- }
- }
- }
-
- SessionDataSet dataSet = session.executeQueryStatement("select * from
table2 order by time");
- int cnt = 0;
- while (dataSet.hasNext()) {
- RowRecord rowRecord = dataSet.next();
- timestamp = rowRecord.getFields().get(0).getLongV();
- assertEquals("id:" + timestamp,
rowRecord.getFields().get(1).getBinaryV().toString());
- assertEquals("attr:" + timestamp,
rowRecord.getFields().get(2).getBinaryV().toString());
- assertEquals(timestamp * 1.0,
rowRecord.getFields().get(3).getDoubleV(), 0.0001);
- // "m2" should not be present
- assertEquals(4, rowRecord.getFields().size());
- cnt++;
- }
- assertEquals(30, cnt);
- } finally {
- try (ISession session =
EnvFactory.getEnv().getSessionConnection(TREE_SQL_DIALECT)) {
- session.executeNonQueryStatement(
- "SET CONFIGURATION \"enable_auto_create_schema\"=\"true\"");
- }
- }
- }
-
@Test
@Category({LocalStandaloneIT.class, ClusterIT.class})
public void partialInsertSQLTest() throws IoTDBConnectionException,
StatementExecutionException {
- try (ISession session =
EnvFactory.getEnv().getSessionConnection(TREE_SQL_DIALECT)) {
+ try (ISession session = EnvFactory.getEnv().getSessionConnection()) {
// disable auto-creation only for this test
session.executeNonQueryStatement("SET CONFIGURATION
\"enable_auto_create_schema\"=\"false\"");
}
- try (ISession session =
EnvFactory.getEnv().getSessionConnection(TABLE_SQL_DIALECT)) {
+ try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
session.executeNonQueryStatement("USE \"db1\"");
// the table is missing column "m2"
session.executeNonQueryStatement(
@@ -368,129 +282,22 @@ public class IoTDBSessionRelationalIT {
}
} finally {
- try (ISession session =
EnvFactory.getEnv().getSessionConnection(TREE_SQL_DIALECT)) {
- session.executeNonQueryStatement(
- "SET CONFIGURATION \"enable_auto_create_schema\"=\"true\"");
- }
- }
- }
-
- @Test
- @Category({LocalStandaloneIT.class, ClusterIT.class})
- public void partialInsertRelationalRowFailTest()
- throws IoTDBConnectionException, StatementExecutionException {
- try (ISession session =
EnvFactory.getEnv().getSessionConnection(TREE_SQL_DIALECT)) {
- // disable auto-creation only for this test
- session.executeNonQueryStatement("SET CONFIGURATION
\"enable_auto_create_schema\"=\"false\"");
- session.executeNonQueryStatement("SET CONFIGURATION
\"enable_partial_insert\"=\"false\"");
- }
- try (ISession session =
EnvFactory.getEnv().getSessionConnection(TABLE_SQL_DIALECT)) {
- session.executeNonQueryStatement("USE \"db1\"");
- // the table is missing column "m2"
- session.executeNonQueryStatement(
- "CREATE TABLE table2_3 (id1 string id, attr1 string attribute, "
- + "m1 double "
- + "measurement)");
-
- // the insertion contains "m2"
- List<IMeasurementSchema> schemaList = new ArrayList<>();
- schemaList.add(new MeasurementSchema("id1", TSDataType.STRING));
- schemaList.add(new MeasurementSchema("attr1", TSDataType.STRING));
- schemaList.add(new MeasurementSchema("m1", TSDataType.DOUBLE));
- schemaList.add(new MeasurementSchema("m2", TSDataType.DOUBLE));
- final List<ColumnType> columnTypes =
- Arrays.asList(
- ColumnType.ID, ColumnType.ATTRIBUTE, ColumnType.MEASUREMENT,
ColumnType.MEASUREMENT);
- List<String> measurementIds =
- schemaList.stream()
- .map(IMeasurementSchema::getMeasurementId)
- .collect(Collectors.toList());
- List<TSDataType> dataTypes =
-
schemaList.stream().map(IMeasurementSchema::getType).collect(Collectors.toList());
-
- Object[] values = new Object[] {"id:" + 1, "attr:" + 1, 1 * 1.0, 1 *
1.0};
- try {
- session.insertRelationalRecord(
- "table2_3", 1, measurementIds, dataTypes, columnTypes, values);
- fail("Exception expected");
- } catch (StatementExecutionException e) {
- assertEquals(
- "507: Fail to insert measurements [m2] caused by [Column m2 does
not exists or fails to be created]",
- e.getMessage());
- }
-
- } finally {
- try (ISession session =
EnvFactory.getEnv().getSessionConnection(TREE_SQL_DIALECT)) {
+ try (ISession session = EnvFactory.getEnv().getSessionConnection()) {
session.executeNonQueryStatement(
"SET CONFIGURATION \"enable_auto_create_schema\"=\"true\"");
- session.executeNonQueryStatement("SET CONFIGURATION
\"enable_partial_insert\"=\"true\"");
}
}
}
- @Test
- @Category({LocalStandaloneIT.class, ClusterIT.class})
- public void insertRelationalRowTest()
- throws IoTDBConnectionException, StatementExecutionException {
- try (ISession session =
EnvFactory.getEnv().getSessionConnection(TABLE_SQL_DIALECT)) {
- session.executeNonQueryStatement("USE \"db1\"");
- session.executeNonQueryStatement(
- "CREATE TABLE table3 (id1 string id, attr1 string attribute, "
- + "m1 double "
- + "measurement)");
-
- List<IMeasurementSchema> schemaList = new ArrayList<>();
- schemaList.add(new MeasurementSchema("id1", TSDataType.STRING));
- schemaList.add(new MeasurementSchema("attr1", TSDataType.STRING));
- schemaList.add(new MeasurementSchema("m1", TSDataType.DOUBLE));
- final List<ColumnType> columnTypes =
- Arrays.asList(ColumnType.ID, ColumnType.ATTRIBUTE,
ColumnType.MEASUREMENT);
- List<String> measurementIds =
- schemaList.stream()
- .map(IMeasurementSchema::getMeasurementId)
- .collect(Collectors.toList());
- List<TSDataType> dataTypes =
-
schemaList.stream().map(IMeasurementSchema::getType).collect(Collectors.toList());
-
- long timestamp = 0;
-
- for (long row = 0; row < 15; row++) {
- Object[] values = new Object[] {"id:" + row, "attr:" + row, row * 1.0};
- session.insertRelationalRecord(
- "table3", timestamp + row, measurementIds, dataTypes, columnTypes,
values);
- }
-
- session.executeNonQueryStatement("FLush");
-
- for (long row = 15; row < 30; row++) {
- Object[] values = new Object[] {"id:" + row, "attr:" + row, row * 1.0};
- session.insertRelationalRecord(
- "table3", timestamp + row, measurementIds, dataTypes, columnTypes,
values);
- }
-
- SessionDataSet dataSet = session.executeQueryStatement("select * from
table3 order by time");
- int cnt = 0;
- while (dataSet.hasNext()) {
- RowRecord rowRecord = dataSet.next();
- timestamp = rowRecord.getFields().get(0).getLongV();
- assertEquals("id:" + timestamp,
rowRecord.getFields().get(1).getBinaryV().toString());
- assertEquals("attr:" + timestamp,
rowRecord.getFields().get(2).getBinaryV().toString());
- assertEquals(timestamp * 1.0,
rowRecord.getFields().get(3).getDoubleV(), 0.0001);
- cnt++;
- }
- assertEquals(30, cnt);
- }
- }
-
@Test
@Category({LocalStandaloneIT.class, ClusterIT.class})
public void partialInsertRelationalTabletTest()
throws IoTDBConnectionException, StatementExecutionException {
- try (ISession session =
EnvFactory.getEnv().getSessionConnection(TREE_SQL_DIALECT)) {
+ try (ISession session = EnvFactory.getEnv().getSessionConnection()) {
// disable auto-creation only for this test
session.executeNonQueryStatement("SET CONFIGURATION
\"enable_auto_create_schema\"=\"false\"");
}
- try (ISession session =
EnvFactory.getEnv().getSessionConnection(TABLE_SQL_DIALECT)) {
+ try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
session.executeNonQueryStatement("USE \"db1\"");
// the table is missing column "m2"
session.executeNonQueryStatement(
@@ -520,7 +327,7 @@ public class IoTDBSessionRelationalIT {
tablet.addValue("m2", rowIndex, row * 1.0);
if (tablet.rowSize == tablet.getMaxRowNumber()) {
try {
- session.insertRelationalTablet(tablet, true);
+ session.insert(tablet);
} catch (StatementExecutionException e) {
// a partial insertion should be reported
if (!e.getMessage()
@@ -535,7 +342,7 @@ public class IoTDBSessionRelationalIT {
if (tablet.rowSize != 0) {
try {
- session.insertRelationalTablet(tablet, true);
+ session.insert(tablet);
} catch (StatementExecutionException e) {
if (!e.getMessage()
.equals(
@@ -557,7 +364,7 @@ public class IoTDBSessionRelationalIT {
tablet.addValue("m2", rowIndex, row * 1.0);
if (tablet.rowSize == tablet.getMaxRowNumber()) {
try {
- session.insertRelationalTablet(tablet, true);
+ session.insert(tablet);
} catch (StatementExecutionException e) {
if (!e.getMessage()
.equals(
@@ -571,7 +378,7 @@ public class IoTDBSessionRelationalIT {
if (tablet.rowSize != 0) {
try {
- session.insertRelationalTablet(tablet, true);
+ session.insert(tablet);
} catch (StatementExecutionException e) {
if (!e.getMessage()
.equals(
@@ -596,7 +403,7 @@ public class IoTDBSessionRelationalIT {
}
assertEquals(30, cnt);
} finally {
- try (ISession session =
EnvFactory.getEnv().getSessionConnection(TREE_SQL_DIALECT)) {
+ try (ISession session = EnvFactory.getEnv().getSessionConnection()) {
session.executeNonQueryStatement(
"SET CONFIGURATION \"enable_auto_create_schema\"=\"true\"");
}
@@ -607,7 +414,7 @@ public class IoTDBSessionRelationalIT {
@Category({LocalStandaloneIT.class, ClusterIT.class})
public void insertRelationalTabletTest()
throws IoTDBConnectionException, StatementExecutionException {
- try (ISession session =
EnvFactory.getEnv().getSessionConnection(TABLE_SQL_DIALECT)) {
+ try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
session.executeNonQueryStatement("USE \"db1\"");
session.executeNonQueryStatement(
"CREATE TABLE table5 (id1 string id, attr1 string attribute, "
@@ -631,13 +438,13 @@ public class IoTDBSessionRelationalIT {
tablet.addValue("attr1", rowIndex, "attr:" + row);
tablet.addValue("m1", rowIndex, row * 1.0);
if (tablet.rowSize == tablet.getMaxRowNumber()) {
- session.insertRelationalTablet(tablet, true);
+ session.insert(tablet);
tablet.reset();
}
}
if (tablet.rowSize != 0) {
- session.insertRelationalTablet(tablet);
+ session.insert(tablet);
tablet.reset();
}
@@ -650,13 +457,13 @@ public class IoTDBSessionRelationalIT {
tablet.addValue("attr1", rowIndex, "attr:" + row);
tablet.addValue("m1", rowIndex, row * 1.0);
if (tablet.rowSize == tablet.getMaxRowNumber()) {
- session.insertRelationalTablet(tablet, true);
+ session.insert(tablet);
tablet.reset();
}
}
if (tablet.rowSize != 0) {
- session.insertRelationalTablet(tablet);
+ session.insert(tablet);
tablet.reset();
}
@@ -678,7 +485,7 @@ public class IoTDBSessionRelationalIT {
@Category({LocalStandaloneIT.class, ClusterIT.class})
public void insertRelationalTabletWithCacheLeaderTest()
throws IoTDBConnectionException, StatementExecutionException {
- try (ISession session =
EnvFactory.getEnv().getSessionConnection(TABLE_SQL_DIALECT)) {
+ try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
session.executeNonQueryStatement("USE \"db1\"");
session.executeNonQueryStatement(
"CREATE TABLE table5 (id1 string id, attr1 string attribute, "
@@ -702,13 +509,13 @@ public class IoTDBSessionRelationalIT {
tablet.addValue("attr1", rowIndex, "attr:" + row);
tablet.addValue("m1", rowIndex, row * 1.0);
if (tablet.rowSize == tablet.getMaxRowNumber()) {
- session.insertRelationalTablet(tablet, true);
+ session.insert(tablet);
tablet.reset();
}
}
if (tablet.rowSize != 0) {
- session.insertRelationalTablet(tablet);
+ session.insert(tablet);
tablet.reset();
}
@@ -722,13 +529,13 @@ public class IoTDBSessionRelationalIT {
tablet.addValue("attr1", rowIndex, "attr:" + (row - 15));
tablet.addValue("m1", rowIndex, row * 1.0);
if (tablet.rowSize == tablet.getMaxRowNumber()) {
- session.insertRelationalTablet(tablet, true);
+ session.insert(tablet);
tablet.reset();
}
}
if (tablet.rowSize != 0) {
- session.insertRelationalTablet(tablet);
+ session.insert(tablet);
tablet.reset();
}
@@ -750,61 +557,11 @@ public class IoTDBSessionRelationalIT {
}
}
- @Test
- @Category({LocalStandaloneIT.class, ClusterIT.class})
- public void autoCreateTableTest() throws IoTDBConnectionException,
StatementExecutionException {
- try (ISession session =
EnvFactory.getEnv().getSessionConnection(TABLE_SQL_DIALECT)) {
- session.executeNonQueryStatement("USE \"db1\"");
- // no table created here
-
- List<IMeasurementSchema> schemaList = new ArrayList<>();
- schemaList.add(new MeasurementSchema("id1", TSDataType.STRING));
- schemaList.add(new MeasurementSchema("attr1", TSDataType.STRING));
- schemaList.add(new MeasurementSchema("m1", TSDataType.DOUBLE));
- final List<ColumnType> columnTypes =
- Arrays.asList(ColumnType.ID, ColumnType.ATTRIBUTE,
ColumnType.MEASUREMENT);
- List<String> measurementIds =
- schemaList.stream()
- .map(IMeasurementSchema::getMeasurementId)
- .collect(Collectors.toList());
- List<TSDataType> dataTypes =
-
schemaList.stream().map(IMeasurementSchema::getType).collect(Collectors.toList());
-
- long timestamp = 0;
-
- for (long row = 0; row < 15; row++) {
- Object[] values = new Object[] {"id:" + row, "attr:" + row, row * 1.0};
- session.insertRelationalRecord(
- "table6", timestamp + row, measurementIds, dataTypes, columnTypes,
values);
- }
-
- session.executeNonQueryStatement("FLush");
-
- for (long row = 15; row < 30; row++) {
- Object[] values = new Object[] {"id:" + row, "attr:" + row, row * 1.0};
- session.insertRelationalRecord(
- "table6", timestamp + row, measurementIds, dataTypes, columnTypes,
values);
- }
-
- int cnt = 0;
- SessionDataSet dataSet = session.executeQueryStatement("select * from
table6 order by time");
- while (dataSet.hasNext()) {
- RowRecord rowRecord = dataSet.next();
- timestamp = rowRecord.getFields().get(0).getLongV();
- assertEquals("id:" + timestamp,
rowRecord.getFields().get(1).getBinaryV().toString());
- assertEquals("attr:" + timestamp,
rowRecord.getFields().get(2).getBinaryV().toString());
- assertEquals(timestamp * 1.0,
rowRecord.getFields().get(3).getDoubleV(), 0.0001);
- cnt++;
- }
- assertEquals(30, cnt);
- }
- }
-
@Test
@Category({LocalStandaloneIT.class, ClusterIT.class})
public void autoCreateNonIdColumnTest()
throws IoTDBConnectionException, StatementExecutionException {
- try (ISession session =
EnvFactory.getEnv().getSessionConnection(TABLE_SQL_DIALECT)) {
+ try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
session.executeNonQueryStatement("USE \"db1\"");
// only one column in this table, and others should be auto-created
session.executeNonQueryStatement("CREATE TABLE table7 (id1 string id)");
@@ -826,13 +583,13 @@ public class IoTDBSessionRelationalIT {
tablet.addValue("attr1", rowIndex, "attr:" + row);
tablet.addValue("m1", rowIndex, row * 1.0);
if (tablet.rowSize == tablet.getMaxRowNumber()) {
- session.insertRelationalTablet(tablet, true);
+ session.insert(tablet);
tablet.reset();
}
}
if (tablet.rowSize != 0) {
- session.insertRelationalTablet(tablet);
+ session.insert(tablet);
tablet.reset();
}
@@ -845,13 +602,13 @@ public class IoTDBSessionRelationalIT {
tablet.addValue("attr1", rowIndex, "attr:" + row);
tablet.addValue("m1", rowIndex, row * 1.0);
if (tablet.rowSize == tablet.getMaxRowNumber()) {
- session.insertRelationalTablet(tablet, true);
+ session.insert(tablet);
tablet.reset();
}
}
if (tablet.rowSize != 0) {
- session.insertRelationalTablet(tablet);
+ session.insert(tablet);
tablet.reset();
}
@@ -873,7 +630,7 @@ public class IoTDBSessionRelationalIT {
@Category({LocalStandaloneIT.class, ClusterIT.class})
public void autoCreateIdColumnTest()
throws IoTDBConnectionException, StatementExecutionException {
- try (ISession session =
EnvFactory.getEnv().getSessionConnection(TABLE_SQL_DIALECT)) {
+ try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
session.executeNonQueryStatement("USE \"db1\"");
// only one column in this table, and others should be auto-created
session.executeNonQueryStatement("CREATE TABLE table8 (id1 string id)");
@@ -895,13 +652,13 @@ public class IoTDBSessionRelationalIT {
tablet.addValue("attr1", rowIndex, "attr:" + row);
tablet.addValue("m1", rowIndex, row * 1.0);
if (tablet.rowSize == tablet.getMaxRowNumber()) {
- session.insertRelationalTablet(tablet, true);
+ session.insert(tablet);
tablet.reset();
}
}
if (tablet.rowSize != 0) {
- session.insertRelationalTablet(tablet);
+ session.insert(tablet);
tablet.reset();
}
@@ -914,13 +671,13 @@ public class IoTDBSessionRelationalIT {
tablet.addValue("attr1", rowIndex, "attr:" + row);
tablet.addValue("m1", rowIndex, row * 1.0);
if (tablet.rowSize == tablet.getMaxRowNumber()) {
- session.insertRelationalTablet(tablet, true);
+ session.insert(tablet);
tablet.reset();
}
}
if (tablet.rowSize != 0) {
- session.insertRelationalTablet(tablet);
+ session.insert(tablet);
tablet.reset();
}
@@ -940,68 +697,68 @@ public class IoTDBSessionRelationalIT {
}
}
- @Test
- @Category({LocalStandaloneIT.class, ClusterIT.class})
- public void autoAdjustIdTest() throws IoTDBConnectionException,
StatementExecutionException {
- try (ISession session =
EnvFactory.getEnv().getSessionConnection(TABLE_SQL_DIALECT)) {
- session.executeNonQueryStatement("USE \"db1\"");
- // the id order in the table is (id1, id2)
- session.executeNonQueryStatement(
- "CREATE TABLE table9 (id1 string id, id2 string id, attr1 string
attribute, "
- + "m1 double "
- + "measurement)");
-
- // the id order in the row is (id2, id1)
- List<IMeasurementSchema> schemaList = new ArrayList<>();
- schemaList.add(new MeasurementSchema("id2", TSDataType.STRING));
- schemaList.add(new MeasurementSchema("id1", TSDataType.STRING));
- schemaList.add(new MeasurementSchema("attr1", TSDataType.STRING));
- schemaList.add(new MeasurementSchema("m1", TSDataType.DOUBLE));
- final List<ColumnType> columnTypes =
- Arrays.asList(ColumnType.ID, ColumnType.ID, ColumnType.ATTRIBUTE,
ColumnType.MEASUREMENT);
- List<String> measurementIds =
- schemaList.stream()
- .map(IMeasurementSchema::getMeasurementId)
- .collect(Collectors.toList());
- List<TSDataType> dataTypes =
-
schemaList.stream().map(IMeasurementSchema::getType).collect(Collectors.toList());
-
- long timestamp = 0;
-
- for (long row = 0; row < 15; row++) {
- Object[] values = new Object[] {"id2:" + row, "id1:" + row, "attr1:" +
row, row * 1.0};
- session.insertRelationalRecord(
- "table9", timestamp + row, measurementIds, dataTypes, columnTypes,
values);
- }
-
- session.executeNonQueryStatement("FLush");
-
- for (long row = 15; row < 30; row++) {
- Object[] values = new Object[] {"id2:" + row, "id1:" + row, "attr1:" +
row, row * 1.0};
- session.insertRelationalRecord(
- "table9", timestamp + row, measurementIds, dataTypes, columnTypes,
values);
- }
-
- SessionDataSet dataSet = session.executeQueryStatement("select * from
table9 order by time");
- int cnt = 0;
- while (dataSet.hasNext()) {
- RowRecord rowRecord = dataSet.next();
- timestamp = rowRecord.getFields().get(0).getLongV();
- assertEquals("id1:" + timestamp,
rowRecord.getFields().get(1).getBinaryV().toString());
- assertEquals("id2:" + timestamp,
rowRecord.getFields().get(2).getBinaryV().toString());
- assertEquals("attr1:" + timestamp,
rowRecord.getFields().get(3).getBinaryV().toString());
- assertEquals(timestamp * 1.0,
rowRecord.getFields().get(4).getDoubleV(), 0.0001);
- cnt++;
- }
- assertEquals(30, cnt);
- }
- }
+// @Test
+// @Category({LocalStandaloneIT.class, ClusterIT.class})
+// public void autoAdjustIdTest() throws IoTDBConnectionException,
StatementExecutionException {
+// try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
+// session.executeNonQueryStatement("USE \"db1\"");
+// // the id order in the table is (id1, id2)
+// session.executeNonQueryStatement(
+// "CREATE TABLE table9 (id1 string id, id2 string id, attr1 string
attribute, "
+// + "m1 double "
+// + "measurement)");
+//
+// // the id order in the row is (id2, id1)
+// List<IMeasurementSchema> schemaList = new ArrayList<>();
+// schemaList.add(new MeasurementSchema("id2", TSDataType.STRING));
+// schemaList.add(new MeasurementSchema("id1", TSDataType.STRING));
+// schemaList.add(new MeasurementSchema("attr1", TSDataType.STRING));
+// schemaList.add(new MeasurementSchema("m1", TSDataType.DOUBLE));
+// final List<ColumnType> columnTypes =
+// Arrays.asList(ColumnType.ID, ColumnType.ID, ColumnType.ATTRIBUTE,
ColumnType.MEASUREMENT);
+// List<String> measurementIds =
+// schemaList.stream()
+// .map(IMeasurementSchema::getMeasurementId)
+// .collect(Collectors.toList());
+// List<TSDataType> dataTypes =
+//
schemaList.stream().map(IMeasurementSchema::getType).collect(Collectors.toList());
+//
+// long timestamp = 0;
+//
+// for (long row = 0; row < 15; row++) {
+// Object[] values = new Object[] {"id2:" + row, "id1:" + row, "attr1:"
+ row, row * 1.0};
+// session.insertRelationalRecord(
+// "table9", timestamp + row, measurementIds, dataTypes,
columnTypes, values);
+// }
+//
+// session.executeNonQueryStatement("FLush");
+//
+// for (long row = 15; row < 30; row++) {
+// Object[] values = new Object[] {"id2:" + row, "id1:" + row, "attr1:"
+ row, row * 1.0};
+// session.insertRelationalRecord(
+// "table9", timestamp + row, measurementIds, dataTypes,
columnTypes, values);
+// }
+//
+// SessionDataSet dataSet = session.executeQueryStatement("select * from
table9 order by time");
+// int cnt = 0;
+// while (dataSet.hasNext()) {
+// RowRecord rowRecord = dataSet.next();
+// timestamp = rowRecord.getFields().get(0).getLongV();
+// assertEquals("id1:" + timestamp,
rowRecord.getFields().get(1).getBinaryV().toString());
+// assertEquals("id2:" + timestamp,
rowRecord.getFields().get(2).getBinaryV().toString());
+// assertEquals("attr1:" + timestamp,
rowRecord.getFields().get(3).getBinaryV().toString());
+// assertEquals(timestamp * 1.0,
rowRecord.getFields().get(4).getDoubleV(), 0.0001);
+// cnt++;
+// }
+// assertEquals(30, cnt);
+// }
+// }
@Test
@Category({LocalStandaloneIT.class, ClusterIT.class})
public void insertRelationalSqlWithoutDBTest()
throws IoTDBConnectionException, StatementExecutionException {
- try (ISession session =
EnvFactory.getEnv().getSessionConnection(TABLE_SQL_DIALECT)) {
+ try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
session.executeNonQueryStatement("USE \"db1\"");
session.executeNonQueryStatement(
"CREATE TABLE table10 (id1 string id, attr1 string attribute, "
@@ -1009,7 +766,7 @@ public class IoTDBSessionRelationalIT {
+ "measurement)");
}
// insert without db
- try (ISession session =
EnvFactory.getEnv().getSessionConnection(TABLE_SQL_DIALECT)) {
+ try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
long timestamp;
// no db in session and sql
@@ -1059,7 +816,7 @@ public class IoTDBSessionRelationalIT {
@Category({LocalStandaloneIT.class, ClusterIT.class})
public void insertRelationalSqlAnotherDBTest()
throws IoTDBConnectionException, StatementExecutionException {
- try (ISession session =
EnvFactory.getEnv().getSessionConnection(TABLE_SQL_DIALECT)) {
+ try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
session.executeNonQueryStatement("USE \"db1\"");
session.executeNonQueryStatement(
"CREATE TABLE table11 (id1 string id, attr1 string attribute, "
@@ -1067,7 +824,7 @@ public class IoTDBSessionRelationalIT {
+ "measurement)");
}
// use db2 but insert db1
- try (ISession session =
EnvFactory.getEnv().getSessionConnection(TABLE_SQL_DIALECT)) {
+ try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
long timestamp;
session.executeNonQueryStatement("USE \"db2\"");
@@ -1108,7 +865,7 @@ public class IoTDBSessionRelationalIT {
@Category({LocalStandaloneIT.class, ClusterIT.class})
public void insertNonExistTableTest()
throws IoTDBConnectionException, StatementExecutionException {
- try (ISession session =
EnvFactory.getEnv().getSessionConnection(TABLE_SQL_DIALECT)) {
+ try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
session.executeNonQueryStatement("USE \"db1\"");
try {
@@ -1136,7 +893,7 @@ public class IoTDBSessionRelationalIT {
@Test
@Category({LocalStandaloneIT.class, ClusterIT.class})
public void insertNonExistDBTest() throws IoTDBConnectionException,
StatementExecutionException {
- try (ISession session =
EnvFactory.getEnv().getSessionConnection(TABLE_SQL_DIALECT)) {
+ try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
session.executeNonQueryStatement("USE \"db1\"");
try {
diff --git
a/iotdb-client/isession/src/main/java/org/apache/iotdb/isession/IPooledSession.java
b/iotdb-client/isession/src/main/java/org/apache/iotdb/isession/IPooledSession.java
deleted file mode 100644
index f8764f9a203..00000000000
---
a/iotdb-client/isession/src/main/java/org/apache/iotdb/isession/IPooledSession.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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.isession;
-
-import org.apache.iotdb.isession.util.Version;
-import org.apache.iotdb.rpc.IoTDBConnectionException;
-import org.apache.iotdb.rpc.StatementExecutionException;
-import org.apache.iotdb.service.rpc.thrift.TSBackupConfigurationResp;
-import org.apache.iotdb.service.rpc.thrift.TSConnectionInfoResp;
-
-import org.apache.thrift.TException;
-import org.apache.tsfile.write.record.Tablet;
-
-/** NOTICE: IPooledSession is specific to the table model. */
-public interface IPooledSession extends AutoCloseable {
-
- Version getVersion();
-
- int getFetchSize();
-
- void close() throws IoTDBConnectionException;
-
- String getTimeZone();
-
- SessionDataSet executeQueryStatement(String sql)
- throws StatementExecutionException, IoTDBConnectionException;
-
- SessionDataSet executeQueryStatement(String sql, long timeoutInMs)
- throws StatementExecutionException, IoTDBConnectionException;
-
- void executeNonQueryStatement(String sql)
- throws IoTDBConnectionException, StatementExecutionException;
-
- String getTimestampPrecision() throws TException;
-
- void insertTablet(Tablet tablet) throws StatementExecutionException,
IoTDBConnectionException;
-
- boolean isEnableQueryRedirection();
-
- boolean isEnableRedirection();
-
- TSBackupConfigurationResp getBackupConfiguration()
- throws IoTDBConnectionException, StatementExecutionException;
-
- TSConnectionInfoResp fetchAllConnections() throws IoTDBConnectionException;
-
- long getQueryTimeout();
-}
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 768a4ceb136..5b82f755620 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
@@ -20,7 +20,7 @@
package org.apache.iotdb.isession.pool;
import org.apache.iotdb.common.rpc.thrift.TAggregationType;
-import org.apache.iotdb.isession.IPooledSession;
+import org.apache.iotdb.isession.ITableSession;
import org.apache.iotdb.isession.template.Template;
import org.apache.iotdb.isession.util.SystemStatus;
import org.apache.iotdb.isession.util.Version;
@@ -559,7 +559,7 @@ public interface ISessionPool {
long getQueryTimeout();
- IPooledSession getPooledSession() throws IoTDBConnectionException;
+ ITableSession getPooledTableSession() throws IoTDBConnectionException;
/**
* @deprecated
diff --git
a/iotdb-client/session/src/main/java/org/apache/iotdb/session/Session.java
b/iotdb-client/session/src/main/java/org/apache/iotdb/session/Session.java
index dad11b14f04..d60734b276c 100644
--- a/iotdb-client/session/src/main/java/org/apache/iotdb/session/Session.java
+++ b/iotdb-client/session/src/main/java/org/apache/iotdb/session/Session.java
@@ -4182,21 +4182,6 @@ public class Session implements ISession {
public static class Builder extends AbstractSessionBuilder {
- public Builder useSSL(boolean useSSL) {
- this.useSSL = useSSL;
- return this;
- }
-
- public Builder trustStore(String keyStore) {
- this.trustStore = keyStore;
- return this;
- }
-
- public Builder trustStorePwd(String keyStorePwd) {
- this.trustStorePwd = keyStorePwd;
- return this;
- }
-
private List<String> nodeUrls = null;
public Builder host(String host) {
@@ -4289,14 +4274,28 @@ public class Session implements ISession {
return this;
}
+ public Builder useSSL(boolean useSSL) {
+ this.useSSL = useSSL;
+ return this;
+ }
+
+ public Builder trustStore(String keyStore) {
+ this.trustStore = keyStore;
+ return this;
+ }
+
+ public Builder trustStorePwd(String keyStorePwd) {
+ this.trustStorePwd = keyStorePwd;
+ return this;
+ }
+
public Session build() {
if (nodeUrls != null
&& (!SessionConfig.DEFAULT_HOST.equals(host) || rpcPort !=
SessionConfig.DEFAULT_PORT)) {
throw new IllegalArgumentException(
"You should specify either nodeUrls or (host + rpcPort), but not
both");
}
- Session newSession = new Session(this);
- return newSession;
+ return new Session(this);
}
}
}
diff --git
a/iotdb-client/session/src/main/java/org/apache/iotdb/session/TableSessionBuilder.java
b/iotdb-client/session/src/main/java/org/apache/iotdb/session/TableSessionBuilder.java
index c63e99e53fb..2c4ed062cb7 100644
---
a/iotdb-client/session/src/main/java/org/apache/iotdb/session/TableSessionBuilder.java
+++
b/iotdb-client/session/src/main/java/org/apache/iotdb/session/TableSessionBuilder.java
@@ -21,7 +21,6 @@ package org.apache.iotdb.session;
import org.apache.iotdb.isession.ITableSession;
import org.apache.iotdb.isession.SessionConfig;
-import org.apache.iotdb.isession.util.Version;
import org.apache.iotdb.rpc.IoTDBConnectionException;
import java.time.ZoneId;
@@ -32,38 +31,28 @@ public class TableSessionBuilder extends
AbstractSessionBuilder {
private boolean enableCompression = false;
private int connectionTimeoutInMs =
SessionConfig.DEFAULT_CONNECTION_TIMEOUT_MS;
- public TableSessionBuilder useSSL(boolean useSSL) {
- this.useSSL = useSSL;
- return this;
- }
-
- public TableSessionBuilder trustStore(String keyStore) {
- this.trustStore = keyStore;
- return this;
- }
-
- public TableSessionBuilder trustStorePwd(String keyStorePwd) {
- this.trustStorePwd = keyStorePwd;
+ public TableSessionBuilder nodeUrls(List<String> nodeUrls) {
+ this.nodeUrls = nodeUrls;
return this;
}
- public TableSessionBuilder host(String host) {
- this.host = host;
+ public TableSessionBuilder username(String username) {
+ this.username = username;
return this;
}
- public TableSessionBuilder port(int port) {
- this.rpcPort = port;
+ public TableSessionBuilder password(String password) {
+ this.pw = password;
return this;
}
- public TableSessionBuilder username(String username) {
- this.username = username;
+ public TableSessionBuilder database(String database) {
+ this.database = database;
return this;
}
- public TableSessionBuilder password(String password) {
- this.pw = password;
+ public TableSessionBuilder queryTimeoutInMs(long queryTimeoutInMs) {
+ this.timeOut = queryTimeoutInMs;
return this;
}
@@ -92,27 +81,6 @@ public class TableSessionBuilder extends
AbstractSessionBuilder {
return this;
}
- public TableSessionBuilder enableRecordsAutoConvertTablet(
- boolean enableRecordsAutoConvertTablet) {
- this.enableRecordsAutoConvertTablet = enableRecordsAutoConvertTablet;
- return this;
- }
-
- public TableSessionBuilder nodeUrls(List<String> nodeUrls) {
- this.nodeUrls = nodeUrls;
- return this;
- }
-
- public TableSessionBuilder version(Version version) {
- this.version = version;
- return this;
- }
-
- public TableSessionBuilder timeOut(long timeOut) {
- this.timeOut = timeOut;
- return this;
- }
-
public TableSessionBuilder enableAutoFetch(boolean enableAutoFetch) {
this.enableAutoFetch = enableAutoFetch;
return this;
@@ -128,13 +96,18 @@ public class TableSessionBuilder extends
AbstractSessionBuilder {
return this;
}
- public TableSessionBuilder sqlDialect(String sqlDialect) {
- this.sqlDialect = sqlDialect;
+ public TableSessionBuilder useSSL(boolean useSSL) {
+ this.useSSL = useSSL;
return this;
}
- public TableSessionBuilder database(String database) {
- this.database = database;
+ public TableSessionBuilder trustStore(String keyStore) {
+ this.trustStore = keyStore;
+ return this;
+ }
+
+ public TableSessionBuilder trustStorePwd(String keyStorePwd) {
+ this.trustStorePwd = keyStorePwd;
return this;
}
@@ -149,13 +122,12 @@ public class TableSessionBuilder extends
AbstractSessionBuilder {
}
public ITableSession build() throws IoTDBConnectionException {
- if (nodeUrls != null
- && (!SessionConfig.DEFAULT_HOST.equals(host) || rpcPort !=
SessionConfig.DEFAULT_PORT)) {
- throw new IllegalArgumentException(
- "You should specify either nodeUrls or (host + rpcPort), but not
both");
+ if (nodeUrls != null) {
+ throw new IllegalArgumentException("You should specify nodeUrls");
}
+ this.sqlDialect = "table";
Session newSession = new Session(this);
- // TODO open
- return newSession;
+ newSession.open(enableCompression, connectionTimeoutInMs);
+ return new TableSession(newSession);
}
}
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 133d7f0fe16..dcbaf54608d 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
@@ -22,8 +22,8 @@ package org.apache.iotdb.session.pool;
import org.apache.iotdb.common.rpc.thrift.TAggregationType;
import org.apache.iotdb.common.rpc.thrift.TEndPoint;
import org.apache.iotdb.isession.INodeSupplier;
-import org.apache.iotdb.isession.IPooledSession;
import org.apache.iotdb.isession.ISession;
+import org.apache.iotdb.isession.ITableSession;
import org.apache.iotdb.isession.SessionConfig;
import org.apache.iotdb.isession.SessionDataSet;
import org.apache.iotdb.isession.pool.ISessionPool;
@@ -740,8 +740,8 @@ public class SessionPool implements ISessionPool {
}
@Override
- public IPooledSession getPooledSession() throws IoTDBConnectionException {
- return new SessionWrapper((Session) getSession(), this);
+ public ITableSession getPooledTableSession() throws IoTDBConnectionException
{
+ return new TableSessionWrapper((Session) getSession(), this);
}
@Override
diff --git
a/iotdb-client/session/src/main/java/org/apache/iotdb/session/pool/TableSessionPoolBuilder.java
b/iotdb-client/session/src/main/java/org/apache/iotdb/session/pool/TableSessionPoolBuilder.java
index 6dba7cbd866..5295c918bd8 100644
---
a/iotdb-client/session/src/main/java/org/apache/iotdb/session/pool/TableSessionPoolBuilder.java
+++
b/iotdb-client/session/src/main/java/org/apache/iotdb/session/pool/TableSessionPoolBuilder.java
@@ -20,38 +20,12 @@
package org.apache.iotdb.session.pool;
import org.apache.iotdb.isession.pool.ITableSessionPool;
-import org.apache.iotdb.isession.util.Version;
import java.time.ZoneId;
import java.util.List;
public class TableSessionPoolBuilder extends AbstractSessionPoolBuilder {
- public TableSessionPoolBuilder useSSL(boolean useSSL) {
- this.useSSL = useSSL;
- return this;
- }
-
- public TableSessionPoolBuilder trustStore(String keyStore) {
- this.trustStore = keyStore;
- return this;
- }
-
- public TableSessionPoolBuilder trustStorePwd(String keyStorePwd) {
- this.trustStorePwd = keyStorePwd;
- return this;
- }
-
- public TableSessionPoolBuilder host(String host) {
- this.host = host;
- return this;
- }
-
- public TableSessionPoolBuilder port(int port) {
- this.rpcPort = port;
- return this;
- }
-
public TableSessionPoolBuilder nodeUrls(List<String> nodeUrls) {
this.nodeUrls = nodeUrls;
return this;
@@ -72,6 +46,16 @@ public class TableSessionPoolBuilder extends
AbstractSessionPoolBuilder {
return this;
}
+ public TableSessionPoolBuilder database(String database) {
+ this.database = database;
+ return this;
+ }
+
+ public TableSessionPoolBuilder queryTimeoutInMs(long queryTimeoutInMs) {
+ this.timeOut = queryTimeoutInMs;
+ return this;
+ }
+
public TableSessionPoolBuilder fetchSize(int fetchSize) {
this.fetchSize = fetchSize;
return this;
@@ -107,22 +91,11 @@ public class TableSessionPoolBuilder extends
AbstractSessionPoolBuilder {
return this;
}
- public TableSessionPoolBuilder enableRecordsAutoConvertTablet(
- boolean enableRecordsAutoConvertTablet) {
- this.enableRecordsAutoConvertTablet = enableRecordsAutoConvertTablet;
- return this;
- }
-
public TableSessionPoolBuilder connectionTimeoutInMs(int
connectionTimeoutInMs) {
this.connectionTimeoutInMs = connectionTimeoutInMs;
return this;
}
- public TableSessionPoolBuilder version(Version version) {
- this.version = version;
- return this;
- }
-
public TableSessionPoolBuilder enableAutoFetch(boolean enableAutoFetch) {
this.enableAutoFetch = enableAutoFetch;
return this;
@@ -138,23 +111,27 @@ public class TableSessionPoolBuilder extends
AbstractSessionPoolBuilder {
return this;
}
- public TableSessionPoolBuilder sqlDialect(String sqlDialect) {
- this.sqlDialect = sqlDialect;
+ public TableSessionPoolBuilder useSSL(boolean useSSL) {
+ this.useSSL = useSSL;
return this;
}
- public TableSessionPoolBuilder queryTimeoutInMs(long queryTimeoutInMs) {
- this.timeOut = queryTimeoutInMs;
+ public TableSessionPoolBuilder trustStore(String keyStore) {
+ this.trustStore = keyStore;
return this;
}
- public TableSessionPoolBuilder database(String database) {
- this.database = database;
+ public TableSessionPoolBuilder trustStorePwd(String keyStorePwd) {
+ this.trustStorePwd = keyStorePwd;
return this;
}
public ITableSessionPool build() {
- // TODO
- return new SessionPool(this);
+ if (nodeUrls != null) {
+ throw new IllegalArgumentException("You should specify nodeUrls");
+ }
+ this.sqlDialect = "table";
+ SessionPool sessionPool = new SessionPool(this);
+ return new TableSessionPool(sessionPool);
}
}
diff --git
a/iotdb-client/session/src/main/java/org/apache/iotdb/session/pool/SessionWrapper.java
b/iotdb-client/session/src/main/java/org/apache/iotdb/session/pool/TableSessionWrapper.java
similarity index 62%
rename from
iotdb-client/session/src/main/java/org/apache/iotdb/session/pool/SessionWrapper.java
rename to
iotdb-client/session/src/main/java/org/apache/iotdb/session/pool/TableSessionWrapper.java
index 5a007921a89..4e7f40a6a8c 100644
---
a/iotdb-client/session/src/main/java/org/apache/iotdb/session/pool/SessionWrapper.java
+++
b/iotdb-client/session/src/main/java/org/apache/iotdb/session/pool/TableSessionWrapper.java
@@ -19,16 +19,12 @@
package org.apache.iotdb.session.pool;
-import org.apache.iotdb.isession.IPooledSession;
+import org.apache.iotdb.isession.ITableSession;
import org.apache.iotdb.isession.SessionDataSet;
-import org.apache.iotdb.isession.util.Version;
import org.apache.iotdb.rpc.IoTDBConnectionException;
import org.apache.iotdb.rpc.StatementExecutionException;
-import org.apache.iotdb.service.rpc.thrift.TSBackupConfigurationResp;
-import org.apache.iotdb.service.rpc.thrift.TSConnectionInfoResp;
import org.apache.iotdb.session.Session;
-import org.apache.thrift.TException;
import org.apache.tsfile.write.record.Tablet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -37,15 +33,15 @@ import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean;
/**
- * NOTICE: SessionWrapper is specific to the table model.
+ * NOTICE: TableSessionWrapper is specific to the table model.
*
* <p>used for SessionPool.getSession need to do some other things like calling
* cleanSessionAndMayThrowConnectionException in SessionPool while
encountering connection exception
* only need to putBack to SessionPool while closing.
*/
-public class SessionWrapper implements IPooledSession {
+public class TableSessionWrapper implements ITableSession {
- private static final Logger LOGGER =
LoggerFactory.getLogger(SessionWrapper.class);
+ private static final Logger LOGGER =
LoggerFactory.getLogger(TableSessionWrapper.class);
private Session session;
@@ -53,44 +49,24 @@ public class SessionWrapper implements IPooledSession {
private final AtomicBoolean closed;
- public SessionWrapper(Session session, SessionPool sessionPool) {
+ protected TableSessionWrapper(Session session, SessionPool sessionPool) {
this.session = session;
this.sessionPool = sessionPool;
this.closed = new AtomicBoolean(false);
}
@Override
- public Version getVersion() {
- return session.getVersion();
- }
-
- @Override
- public int getFetchSize() {
- return session.getFetchSize();
- }
-
- @Override
- public void close() throws IoTDBConnectionException {
- if (closed.compareAndSet(false, true)) {
- if (!Objects.equals(session.getDatabase(), sessionPool.database)
- && sessionPool.database != null) {
- try {
- session.executeNonQueryStatement("use " + sessionPool.database);
- } catch (StatementExecutionException e) {
- LOGGER.warn(
- "Failed to change back database by executing: use " +
sessionPool.database, e);
- }
- }
- sessionPool.putBack(session);
+ public void insert(Tablet tablet) throws StatementExecutionException,
IoTDBConnectionException {
+ try {
+ session.insertRelationalTablet(tablet);
+ } catch (IoTDBConnectionException e) {
+ sessionPool.cleanSessionAndMayThrowConnectionException(session);
+ closed.set(true);
session = null;
+ throw e;
}
}
- @Override
- public String getTimeZone() {
- return session.getTimeZone();
- }
-
@Override
public SessionDataSet executeQueryStatement(String sql)
throws StatementExecutionException, IoTDBConnectionException {
@@ -131,67 +107,19 @@ public class SessionWrapper implements IPooledSession {
}
@Override
- public String getTimestampPrecision() throws TException {
- try {
- return session.getTimestampPrecision();
- } catch (TException e) {
- sessionPool.cleanSessionAndMayThrowConnectionException(session);
- closed.set(true);
- session = null;
- throw e;
- }
- }
-
- @Override
- public void insertTablet(Tablet tablet)
- throws StatementExecutionException, IoTDBConnectionException {
- try {
- session.insertRelationalTablet(tablet);
- } catch (IoTDBConnectionException e) {
- sessionPool.cleanSessionAndMayThrowConnectionException(session);
- closed.set(true);
- session = null;
- throw e;
- }
- }
-
- @Override
- public boolean isEnableQueryRedirection() {
- return session.isEnableQueryRedirection();
- }
-
- @Override
- public boolean isEnableRedirection() {
- return session.isEnableRedirection();
- }
-
- @Override
- public TSBackupConfigurationResp getBackupConfiguration()
- throws IoTDBConnectionException, StatementExecutionException {
- try {
- return session.getBackupConfiguration();
- } catch (IoTDBConnectionException e) {
- sessionPool.cleanSessionAndMayThrowConnectionException(session);
- closed.set(true);
- session = null;
- throw e;
- }
- }
-
- @Override
- public TSConnectionInfoResp fetchAllConnections() throws
IoTDBConnectionException {
- try {
- return session.fetchAllConnections();
- } catch (IoTDBConnectionException e) {
- sessionPool.cleanSessionAndMayThrowConnectionException(session);
- closed.set(true);
+ public void close() throws IoTDBConnectionException {
+ if (closed.compareAndSet(false, true)) {
+ if (!Objects.equals(session.getDatabase(), sessionPool.database)
+ && sessionPool.database != null) {
+ try {
+ session.executeNonQueryStatement("use " + sessionPool.database);
+ } catch (StatementExecutionException e) {
+ LOGGER.warn(
+ "Failed to change back database by executing: use {}",
sessionPool.database, e);
+ }
+ }
+ sessionPool.putBack(session);
session = null;
- throw e;
}
}
-
- @Override
- public long getQueryTimeout() {
- return session.getQueryTimeout();
- }
}