You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2025/12/18 03:55:25 UTC
(iotdb) 03/33: Limit the return size for client instead of always using fetchSize
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch force_ci/object_type
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit f408427264fcd8bad1502a8aa374d2b0d7025403
Author: JackieTien97 <ja...@gmail.com>
AuthorDate: Sat Jul 12 10:30:06 2025 +0800
Limit the return size for client instead of always using fetchSize
---
.../src/main/java/org/apache/iotdb/db/utils/QueryDataSetUtils.java | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
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 fed80815f69..6220623dd3b 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
@@ -51,6 +51,9 @@ public class QueryDataSetUtils {
private static final TSFileConfig TSFLE_CONFIG = TSFileDescriptor.getInstance().getConfig();
+ // default return 8 MB each time
+ private static final long MAX_RETURN_SIZE = 8 * 1024 * 1024;
+
private QueryDataSetUtils() {}
public static Pair<TSQueryDataSet, Boolean> convertTsBlockByFetchSize(
@@ -616,8 +619,9 @@ public class QueryDataSetUtils {
IQueryExecution queryExecution, int fetchSize) throws IoTDBException {
fetchSize = fetchSize > 0 ? fetchSize : TSFLE_CONFIG.getMaxTsBlockLineNumber();
int rowCount = 0;
+ long memorySize = 0;
List<ByteBuffer> res = new ArrayList<>();
- while (rowCount < fetchSize) {
+ while (rowCount < fetchSize && memorySize < MAX_RETURN_SIZE) {
Optional<ByteBuffer> optionalByteBuffer = queryExecution.getByteBufferBatchResult();
if (!optionalByteBuffer.isPresent()) {
break;
@@ -634,6 +638,7 @@ public class QueryDataSetUtils {
res.add(byteBuffer);
}
rowCount += positionCount;
+ memorySize += byteBuffer.limit();
}
return new Pair<>(res, !queryExecution.hasNextResult());
}