Skip to content

Transfer schema tree in batches & add memory control for schema tree#16035

Merged
JackieTien97 merged 13 commits into
masterfrom
transferSchemaTreeInBatches
Jul 31, 2025
Merged

Transfer schema tree in batches & add memory control for schema tree#16035
JackieTien97 merged 13 commits into
masterfrom
transferSchemaTreeInBatches

Conversation

@shuwenwei

Copy link
Copy Markdown
Member

Description

Transfer schema tree in batches

@codecov

codecov Bot commented Jul 25, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 69 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.93%. Comparing base (ee9d7d1) to head (054ade3).
⚠️ Report is 7 commits behind head on master.

Files with missing lines Patch % Lines
...ution/operator/schema/SchemaFetchScanOperator.java 64.58% 17 Missing ⚠️
...lan/analyze/schema/ClusterSchemaFetchExecutor.java 0.00% 14 Missing ⚠️
...eryengine/common/schematree/ClusterSchemaTree.java 87.64% 11 Missing ⚠️
...e/iotdb/db/queryengine/common/MPPQueryContext.java 44.44% 10 Missing ⚠️
.../common/schematree/node/SchemaMeasurementNode.java 40.00% 6 Missing ⚠️
...ngine/common/schematree/node/SchemaEntityNode.java 50.00% 4 Missing ⚠️
...ine/common/schematree/node/SchemaInternalNode.java 57.14% 3 Missing ⚠️
...pache/iotdb/db/schemaengine/template/Template.java 25.00% 3 Missing ⚠️
...db/db/queryengine/plan/analyze/AnalyzeVisitor.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #16035      +/-   ##
============================================
- Coverage     38.96%   38.93%   -0.03%     
  Complexity      198      198              
============================================
  Files          4874     4876       +2     
  Lines        317061   317569     +508     
  Branches      39958    40034      +76     
============================================
+ Hits         123530   123638     +108     
- Misses       193531   193931     +400     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

}
} else if (type == 1) {
resultSchemaTree.mergeSchemaTree(ClusterSchemaTree.deserialize(inputStream));
} else if (type == 1 || type == 2) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better using type 2 and 3 to keep forward compatibility

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, but it should be noted that the current version and the previous version may still be incompatible, because the datanode of current version may provide incomplete schema tree tsblock to a datanode of old version

} else if (type == 1 || type == 2) {
if (deserializer.isFirstBatch()) {
long memCost = ReadWriteIOUtils.readLong(inputStream);
context.reserveMemoryForSchemaTree(memCost);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add if (context != null)

Comment on lines +165 to +166
// to indicate this binary data is database info
ReadWriteIOUtils.write((byte) 1, baos);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why first byte is 1 means that this binary data is database info

public static class SchemaNodeBatchDeserializer {
private byte nodeType;
private int childNum;
private Deque<SchemaNode> stack = new ArrayDeque<>();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private Deque<SchemaNode> stack = new ArrayDeque<>();
private final Deque<SchemaNode> stack = new ArrayDeque<>();

Comment on lines +624 to +631
nodeType = 0;
childNum = 0;
stack.clear();
child = null;
hasLogicalView = false;
hasNormalTimeSeries = false;
templateMap = new HashMap<>();
isFirstBatch = true;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put these codes into a private method named reset

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add some comments about why you need to construct a new HashMap instead of calling clear method for it

}

private static class SchemaNodePostOrderIterator implements Iterator<SchemaNode> {
private final Deque<Pair<SchemaNode, Iterator<SchemaNode>>> stack = new ArrayDeque<>();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe Stack<Pair<SchemaNode, Boolean>> is enough

@sonarqubecloud

Copy link
Copy Markdown

@JackieTien97 JackieTien97 merged commit f407b66 into master Jul 31, 2025
33 of 36 checks passed
@JackieTien97 JackieTien97 deleted the transferSchemaTreeInBatches branch July 31, 2025 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants