fix comment
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/function/tvf/read_tsfile/ExternalTsFileQueryResource.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/function/tvf/read_tsfile/ExternalTsFileQueryResource.java index 2f9981c..75249c1 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/function/tvf/read_tsfile/ExternalTsFileQueryResource.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/function/tvf/read_tsfile/ExternalTsFileQueryResource.java
@@ -140,7 +140,8 @@ } DeviceEntry deviceEntry = new AlignedDeviceEntry(deviceID, new Binary[0]); int deviceEntryIndex = sharedDeviceEntries.size(); - // Reserve the boxed index that partition.add will append to deviceEntryIndexes. + // Reserve the DeviceEntry reference in sharedDeviceEntries, plus the boxed index and its + // reference that partition.add will append to deviceEntryIndexes. externalTsFileResourceMemoryReservationManager.reserveMemoryCumulatively( deviceEntry.ramBytesUsed() + MemoryEstimationHelper.INTEGER_INSTANCE_SIZE @@ -376,10 +377,9 @@ } void finish() { - if (deviceEntryComparator == null) { - return; + if (deviceEntryComparator != null) { + deviceEntryIndexes.sort(ExternalTsFileQueryResource.this::compareDeviceEntryIndexes); } - deviceEntryIndexes.sort(ExternalTsFileQueryResource.this::compareDeviceEntryIndexes); if (pendingDeviceTasks.isEmpty()) { return;