feat: Add task result chunking support (issue #3071) - #3127
Conversation
- Add TASK_RESULT_CHUNK_SIZE config option to CoreOptions - Add chunkKey() and isChunkedProperty() helper methods to P class - Implement chunked write in asArray() method - Add RESULT_CHUNK_COUNT constant Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR aims to add configurable chunking for large Gremlin task results in hugegraph-core, splitting compressed task result blobs into smaller pieces to avoid exceeding per-property storage limits.
Changes:
- Introduces
task.result_chunk_size(CoreOptions.TASK_RESULT_CHUNK_SIZE) with a 1MB default. - Updates
HugeTask.asArray()to optionally split compressed~task_resultinto chunk properties and write a chunk-count marker. - Adds helper constants/methods in
HugeTask.Pfor chunk key naming and identification.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/HugeTask.java | Adds chunked result property writing and chunk-related helpers/constants. |
| hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/config/CoreOptions.java | Adds the task.result_chunk_size configuration option. |
Comments suppressed due to low confidence (2)
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/HugeTask.java:590
checkPropertySize(chunk.length, P.chunkKey(i))uses the default limitBytesBuffer.MAX_PROPERTIES(65,535) for non-RESULT keys, so with the default 1MB chunk size this will always throwLimitExceedExceptionand chunking can never succeed. Validate againstBytesBuffer.BYTES_LEN_MAX(or rely on the config range) instead ofcheckPropertySize()here.
byte[] chunk = new byte[end - start];
System.arraycopy(bytes, start, chunk, 0, end - start);
checkPropertySize(chunk.length, P.chunkKey(i));
list.add(P.chunkKey(i));
list.add(chunk);
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/HugeTask.java:594
- Writing chunked results as
~task_result_0,~task_result_1, … plus~task_result_chunk_countwill break both persistence and loading: (1)TaskTransaction.initProperties()only creates the~task_resultproperty key for the task vertex label, so these new keys are not in schema; (2)HugeTask.property()only handlesP.RESULTand throwsAssertionErrorfor unknown keys, sofromVertex(..., withResult=true)will fail when it encounters the chunk keys/count. This needs a schema/model change (e.g., store chunks under a single multi-valued property or add explicit support for these keys in schema + deserialization).
list.add(P.chunkKey(i));
list.add(chunk);
}
// Write chunk count
list.add(P.RESULT_CHUNK_COUNT);
list.add(String.valueOf(numChunks));
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| checkPropertySize(bytes.length, P.RESULT); | ||
| list.add(P.RESULT); | ||
| list.add(bytes); | ||
| int chunkSize = CoreOptions.instance().get(CoreOptions.TASK_RESULT_CHUNK_SIZE); |
| new ConfigOption<>( | ||
| "task.result_chunk_size", | ||
| "The chunk size for task results in bytes. Set 0 to disable chunking.", | ||
| rangeInt(0, BytesBuffer.BYTES_LEN_MAX), |
imbajin
left a comment
There was a problem hiding this comment.
Blocking: yes. Summary: The chunking implementation does not compile and is not wired into the task schema, read path, or distributed result-storage path. Evidence: exact-head CI compilation errors and static traces through HugeTask, TaskTransaction, StandardHugeGraph, and TaskAndResultScheduler.
| list.add(bytes); | ||
| int chunkSize = CoreOptions.instance().get(CoreOptions.TASK_RESULT_CHUNK_SIZE); | ||
|
|
||
| if (chunkSize > 0 && bytes.length > chunkSize) { |
There was a problem hiding this comment.
TaskAndResultScheduler.save() stores task metadata through asArrayWithoutResult() and writes the result through unchanged HugeTaskResult.asArray(), so HStore/distributed deployments still persist one BLOB; HugeTask.set() also enforces the total result limit before this branch runs. Please center chunking in the actual result-storage abstraction and cover both local and distributed persistence, including old-format compatibility.
Summary
This PR adds support for chunking large task results to avoid memory overflow.
Changes
TASK_RESULT_CHUNK_SIZEconfig option toCoreOptions.java(default 1MB)chunkKey()andisChunkedProperty()helper methods toPclassasArray()methodRESULT_CHUNK_COUNTconstantUsage
When the compressed result exceeds
task.result_chunk_size, it will be split intomultiple properties (
~task_result_0,~task_result_1, ...).Set
task.result_chunk_size=0to disable chunking (preserves original behavior).Related
Part of issue #3071 (Chunk 1-4)
🤖 Generated with Claude Code