This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch object_type
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/object_type by this push:
new 9d6a25301cb Limit the return size for client instead of always using
fetchSize
9d6a25301cb is described below
commit 9d6a25301cb17fbf9d5ee12c5dc0ad06c0542afa
Author: JackieTien97 <[email protected]>
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());
}