You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2021/05/20 01:56:32 UTC
[iotdb] branch rel/0.11 updated: Automatically close the dataset
while there is no more data (#3237)
This is an automated email from the ASF dual-hosted git repository.
qiaojialin pushed a commit to branch rel/0.11
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/rel/0.11 by this push:
new a6c166c Automatically close the dataset while there is no more data (#3237)
a6c166c is described below
commit a6c166c364412fbff5405b887786fce89185953d
Author: Jackie Tien <Ja...@foxmail.com>
AuthorDate: Thu May 20 09:56:09 2021 +0800
Automatically close the dataset while there is no more data (#3237)
---
.../iotdb/jdbc/IoTDBNonAlignJDBCResultSet.java | 17 +++++++++++------
.../java/org/apache/iotdb/rpc/IoTDBRpcDataSet.java | 20 +++++++++++++++++---
2 files changed, 28 insertions(+), 9 deletions(-)
diff --git a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBNonAlignJDBCResultSet.java b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBNonAlignJDBCResultSet.java
index 8c827d8..f5ab61a 100644
--- a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBNonAlignJDBCResultSet.java
+++ b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBNonAlignJDBCResultSet.java
@@ -21,8 +21,15 @@ package org.apache.iotdb.jdbc;
import static org.apache.iotdb.rpc.IoTDBRpcDataSet.START_INDEX;
import static org.apache.iotdb.rpc.IoTDBRpcDataSet.TIMESTAMP_STR;
-import static org.apache.iotdb.rpc.IoTDBRpcDataSet.VALUE_IS_NULL;
+import java.nio.ByteBuffer;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
import org.apache.iotdb.rpc.RpcUtils;
import org.apache.iotdb.rpc.StatementExecutionException;
import org.apache.iotdb.service.rpc.thrift.TSFetchResultsReq;
@@ -35,11 +42,6 @@ import org.apache.iotdb.tsfile.utils.BytesUtils;
import org.apache.iotdb.tsfile.utils.ReadWriteIOUtils;
import org.apache.thrift.TException;
-import java.nio.ByteBuffer;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.*;
-
public class IoTDBNonAlignJDBCResultSet extends AbstractIoTDBJDBCResultSet {
private static final int TIMESTAMP_STR_LENGTH = 4;
@@ -121,9 +123,12 @@ public class IoTDBNonAlignJDBCResultSet extends AbstractIoTDBJDBCResultSet {
}
if (!resp.hasResultSet) {
ioTDBRpcDataSet.emptyResultSet = true;
+ close();
} else {
tsQueryNonAlignDataSet = resp.getNonAlignQueryDataSet();
if (tsQueryNonAlignDataSet == null) {
+ ioTDBRpcDataSet.emptyResultSet = true;
+ close();
return false;
}
}
diff --git a/service-rpc/src/main/java/org/apache/iotdb/rpc/IoTDBRpcDataSet.java b/service-rpc/src/main/java/org/apache/iotdb/rpc/IoTDBRpcDataSet.java
index 5c9e8f5..a7eeb57 100644
--- a/service-rpc/src/main/java/org/apache/iotdb/rpc/IoTDBRpcDataSet.java
+++ b/service-rpc/src/main/java/org/apache/iotdb/rpc/IoTDBRpcDataSet.java
@@ -192,13 +192,26 @@ public class IoTDBRpcDataSet {
return true;
}
if (emptyResultSet) {
- return false;
+ try {
+ close();
+ return false;
+ } catch (TException e) {
+ throw new IoTDBConnectionException(
+ "Cannot close dataset, because of network connection: {} ", e);
+ }
}
- if (fetchResults()) {
+ if (fetchResults() && hasCachedResults()) {
constructOneRow();
return true;
+ } else {
+ try {
+ close();
+ return false;
+ } catch (TException e) {
+ throw new IoTDBConnectionException(
+ "Cannot close dataset, because of network connection: {} ", e);
+ }
}
- return false;
}
public boolean fetchResults() throws StatementExecutionException, IoTDBConnectionException {
@@ -210,6 +223,7 @@ public class IoTDBRpcDataSet {
RpcUtils.verifySuccess(resp.getStatus());
if (!resp.hasResultSet) {
emptyResultSet = true;
+ close();
} else {
tsQueryDataSet = resp.getQueryDataSet();
}