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

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

commit cf79f6d0d816fa890589ccaa05eda6eb04a3e5fd
Author: JackieTien97 <[email protected]>
AuthorDate: Tue Nov 26 20:25:31 2024 +0800

    Set fetchSize to max_tsblock_line_number if it's equal to or less than zero
---
 .../apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java  | 1 +
 .../iotdb/db/queryengine/plan/execution/config/ConfigExecution.java | 2 +-
 .../src/main/java/org/apache/iotdb/db/utils/QueryDataSetUtils.java  | 6 ++++++
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java
index b120b4bfd5e..0bb353bb2c6 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java
@@ -384,6 +384,7 @@ public class ClientRPCServiceImpl implements 
IClientRPCServiceWithHandler {
       try (SetThreadName threadName = new 
SetThreadName(result.queryId.getId())) {
         TSExecuteStatementResp resp;
         if (queryExecution != null && queryExecution.isQuery()) {
+          statementType = statementType == null ? StatementType.QUERY : 
statementType;
           resp = createResponse(queryExecution.getDatasetHeader(), queryId);
           resp.setStatus(result.status);
           finished = setResult.apply(resp, queryExecution, req.fetchSize);
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/ConfigExecution.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/ConfigExecution.java
index c0886d91842..6075c8c64ba 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/ConfigExecution.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/ConfigExecution.java
@@ -246,6 +246,6 @@ public class ConfigExecution implements IQueryExecution {
 
   @Override
   public String getStatementType() {
-    return statementType.name();
+    return statementType == null ? null : statementType.name();
   }
 }
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/QueryDataSetUtils.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/QueryDataSetUtils.java
index dec3864353c..32fff633559 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/QueryDataSetUtils.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/QueryDataSetUtils.java
@@ -24,6 +24,8 @@ import 
org.apache.iotdb.db.queryengine.plan.execution.IQueryExecution;
 import org.apache.iotdb.service.rpc.thrift.TSQueryDataSet;
 
 import org.apache.tsfile.block.column.Column;
+import org.apache.tsfile.common.conf.TSFileConfig;
+import org.apache.tsfile.common.conf.TSFileDescriptor;
 import org.apache.tsfile.enums.TSDataType;
 import org.apache.tsfile.read.common.block.TsBlock;
 import org.apache.tsfile.utils.Binary;
@@ -47,10 +49,13 @@ public class QueryDataSetUtils {
 
   private static final int FLAG = 0x01;
 
+  private static final TSFileConfig TSFLE_CONFIG = 
TSFileDescriptor.getInstance().getConfig();
+
   private QueryDataSetUtils() {}
 
   public static Pair<TSQueryDataSet, Boolean> convertTsBlockByFetchSize(
       IQueryExecution queryExecution, int fetchSize) throws IOException, 
IoTDBException {
+    fetchSize = fetchSize > 0 ? fetchSize : 
TSFLE_CONFIG.getMaxTsBlockLineNumber();
     boolean finished = false;
     int columnNum = queryExecution.getOutputValueColumnCount();
     // one time column and each value column has an actual value buffer and a 
bitmap value to
@@ -607,6 +612,7 @@ public class QueryDataSetUtils {
    */
   public static Pair<List<ByteBuffer>, Boolean> convertQueryResultByFetchSize(
       IQueryExecution queryExecution, int fetchSize) throws IoTDBException {
+    fetchSize = fetchSize > 0 ? fetchSize : 
TSFLE_CONFIG.getMaxTsBlockLineNumber();
     int rowCount = 0;
     List<ByteBuffer> res = new ArrayList<>();
     while (rowCount < fetchSize) {

Reply via email to