Caideyipi commented on code in PR #17672:
URL: https://github.com/apache/iotdb/pull/17672#discussion_r3322902028
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/mem/MTreeBelowSGMemoryImpl.java:
##########
@@ -208,6 +207,46 @@ private void applySubtreeMeasurementDelta(IMemMNode
startNode, final long delta)
}
}
+ private IDeviceMNode<IMemMNode> setToEntityAndUpdateFlags(final IMemMNode
node) {
+ final boolean wasDevice = node.isDevice();
+ final IDeviceMNode<IMemMNode> deviceMNode = store.setToEntity(node);
+ if (!wasDevice) {
+ markAncestorsHavingDeviceDescendant(node);
+ }
+ return deviceMNode;
+ }
+
+ private void markAncestorsHavingDeviceDescendant(final IMemMNode deviceNode)
{
+ IMemMNode current = deviceNode.getParent();
+ while (current != null && !current.hasDeviceDescendant()) {
+ current.setHasDeviceDescendant(true);
+ current = current.getParent();
+ }
+ }
+
+ private boolean hasDeviceDescendantInChildren(final IMemMNode node) {
+ final IMNodeIterator<IMemMNode> iterator = store.getChildrenIterator(node);
+ try {
Review Comment:
Done. `IMNodeIterator` now extends `AutoCloseable`, and the newly added
child-iterator scans use try-with-resources in memory, cached, and traverser
paths.
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/mem/MTreeBelowSGMemoryImpl.java:
##########
@@ -315,7 +355,7 @@ public IMeasurementMNode<IMemMNode> createTimeSeries(
if (device.isDevice()) {
entityMNode = device.getAsDeviceMNode();
} else {
- entityMNode = store.setToEntity(device);
+ entityMNode = setToEntityAndUpdateFlags(device);
Review Comment:
Confirmed and covered with tests. The delete refresh recomputes ancestors
from children, so when the last device under one prefix is removed, higher
ancestors stay true if another sibling device subtree still exists and become
false only after the last remaining device subtree is removed. I extended both
memory and cached MTree tests for that case, and added memory-mode table-device
drop coverage as well.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]