This is an automated email from the ASF dual-hosted git repository.
jiangtian pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new b7562e3cd17 fix index out of bound exception in settle compaction task (#13462)
b7562e3cd17 is described below
commit b7562e3cd177e0d4a43b12843e3b42a3f18f6c12
Author: shuwenwei <55...@users.noreply.github.com>
AuthorDate: Tue Sep 10 15:04:56 2024 +0800
fix index out of bound exception in settle compaction task (#13462)
---
.../execute/task/SettleCompactionTask.java | 8 ++++++
.../settle/SettleCompactionTaskTest.java | 31 ++++++++++++++++++++++
2 files changed, 39 insertions(+)
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/task/SettleCompactionTask.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/task/SettleCompactionTask.java
index 21ca36833d1..2a6d6e6099b 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/task/SettleCompactionTask.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/task/SettleCompactionTask.java
@@ -359,6 +359,14 @@ public class SettleCompactionTask extends InnerSpaceCompactionTask {
return totalModsFileSize;
}
+ @Override
+ public long getEstimatedMemoryCost() {
+ if (filesView.sourceFilesInCompactionPerformer.isEmpty()) {
+ return 0;
+ }
+ return super.getEstimatedMemoryCost();
+ }
+
@Override
public String toString() {
return storageGroupName
diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/compaction/settle/SettleCompactionTaskTest.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/compaction/settle/SettleCompactionTaskTest.java
index 9f8768aa45f..cbedc6d69e2 100644
--- a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/compaction/settle/SettleCompactionTaskTest.java
+++ b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/compaction/settle/SettleCompactionTaskTest.java
@@ -449,6 +449,37 @@ public class SettleCompactionTaskTest extends AbstractCompactionTest {
validateTargetDatas(sourceDatas, Collections.emptyList());
}
+ @Test
+ public void testTaskEstimateMemory()
+ throws IOException, MetadataException, WriteProcessException {
+ ICompactionPerformer performer = getPerformer();
+ if (performer instanceof ReadPointCompactionPerformer) {
+ // not implemented
+ return;
+ }
+ createFiles(3, 3, 10, 100, 0, 0, 0, 0, isAligned, true);
+ SettleCompactionTask task1 =
+ new SettleCompactionTask(
+ 0,
+ tsFileManager,
+ Collections.singletonList(seqResources.get(0)),
+ Arrays.asList(seqResources.get(1), seqResources.get(2)),
+ true,
+ performer,
+ 0);
+
+ SettleCompactionTask task2 =
+ new SettleCompactionTask(
+ 0, tsFileManager, seqResources, Collections.emptyList(), true, performer, 0);
+
+ SettleCompactionTask task3 =
+ new SettleCompactionTask(
+ 0, tsFileManager, Collections.emptyList(), seqResources, true, performer, 0);
+ Assert.assertTrue(task1.getEstimatedMemoryCost() > 0);
+ Assert.assertEquals(0, task2.getEstimatedMemoryCost());
+ Assert.assertTrue(task3.getEstimatedMemoryCost() > 0);
+ }
+
public static List<IFullPath> createTimeseries(
int deviceNum, int measurementNum, boolean isAligned) throws IllegalPathException {
List<IFullPath> timeseriesPath = new ArrayList<>();