You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by sp...@apache.org on 2025/03/03 06:33:43 UTC

(iotdb) branch feature/memory_transfer updated (7e61a737c12 -> 72e2debae7d)

This is an automated email from the ASF dual-hosted git repository.

spricoder pushed a change to branch feature/memory_transfer
in repository https://gitbox.apache.org/repos/asf/iotdb.git


    from 7e61a737c12 Merge branch 'feature/memory_collect' into feature/memory_transfer
     add 42474ce99b0 Add MemoryBlock UT Test
     new 72e2debae7d Add MemoryBlock UT Test

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/iotdb/db/conf/IoTDBDescriptor.java  |  4 +-
 .../commons/memory/AtomicLongMemoryBlock.java      |  4 +-
 .../iotdb/commons/memory/MemoryBlockTest.java      | 49 ++++++++++++++++++++++
 3 files changed, 54 insertions(+), 3 deletions(-)
 create mode 100644 iotdb-core/node-commons/src/test/java/org/apache/iotdb/commons/memory/MemoryBlockTest.java


(iotdb) 01/01: Add MemoryBlock UT Test

Posted by sp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

spricoder pushed a commit to branch feature/memory_transfer
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 72e2debae7ddc1b2fc915c6d93e80b604d5437ed
Merge: 7e61a737c12 42474ce99b0
Author: spricoder <sp...@qq.com>
AuthorDate: Mon Mar 3 14:33:33 2025 +0800

    Add MemoryBlock UT Test

 .../org/apache/iotdb/db/conf/IoTDBDescriptor.java  |  4 +-
 .../commons/memory/AtomicLongMemoryBlock.java      |  4 +-
 .../iotdb/commons/memory/MemoryBlockTest.java      | 49 ++++++++++++++++++++++
 3 files changed, 54 insertions(+), 3 deletions(-)

diff --cc iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
index b632c34f274,e1bb7be7054..8c4ecfaed36
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
@@@ -2465,21 -2464,21 +2465,21 @@@ public class IoTDBDescriptor 
        if (proportionSum != 0) {
          try {
            bloomFilterCacheMemorySize =
 -              maxMemoryAvailable * Integer.parseInt(proportions[0].trim()) / proportionSum;
 +              memoryAvailable * Integer.parseInt(proportions[0].trim()) / proportionSum;
            chunkCacheMemorySize =
 -              maxMemoryAvailable * Integer.parseInt(proportions[1].trim()) / proportionSum;
 +              memoryAvailable * Integer.parseInt(proportions[1].trim()) / proportionSum;
            timeSeriesMetaDataCacheMemorySize =
 -              maxMemoryAvailable * Integer.parseInt(proportions[2].trim()) / proportionSum;
 +              memoryAvailable * Integer.parseInt(proportions[2].trim()) / proportionSum;
            coordinatorMemorySize =
 -              maxMemoryAvailable * Integer.parseInt(proportions[3].trim()) / proportionSum;
 +              memoryAvailable * Integer.parseInt(proportions[3].trim()) / proportionSum;
            operatorsMemorySize =
 -              maxMemoryAvailable * Integer.parseInt(proportions[4].trim()) / proportionSum;
 +              memoryAvailable * Integer.parseInt(proportions[4].trim()) / proportionSum;
            dataExchangeMemorySize =
 -              maxMemoryAvailable * Integer.parseInt(proportions[5].trim()) / proportionSum;
 +              memoryAvailable * Integer.parseInt(proportions[5].trim()) / proportionSum;
            timeIndexMemorySize =
 -              maxMemoryAvailable * Integer.parseInt(proportions[6].trim()) / proportionSum;
 +              memoryAvailable * Integer.parseInt(proportions[6].trim()) / proportionSum;
-         } catch (IllegalArgumentException e) {
-           throw new RuntimeException(
+         } catch (Exception e) {
+           throw new IllegalArgumentException(
                "Each subsection of configuration item chunkmeta_chunk_timeseriesmeta_free_memory_proportion"
                    + " should be an integer, which is "
                    + queryMemoryAllocateProportion,
diff --cc iotdb-core/node-commons/src/test/java/org/apache/iotdb/commons/memory/MemoryBlockTest.java
index 00000000000,e72a0765de3..85c18010d85
mode 000000,100644..100644
--- a/iotdb-core/node-commons/src/test/java/org/apache/iotdb/commons/memory/MemoryBlockTest.java
+++ b/iotdb-core/node-commons/src/test/java/org/apache/iotdb/commons/memory/MemoryBlockTest.java
@@@ -1,0 -1,49 +1,49 @@@
+ package org.apache.iotdb.commons.memory;
+ 
+ import org.junit.Assert;
+ import org.junit.Test;
+ 
+ public class MemoryBlockTest {
+ 
+   @Test
+   public void test() throws Exception {
+     IMemoryBlock memoryBlock1 = new AtomicLongMemoryBlock("Block1", null, 20);
+     IMemoryBlock memoryBlock2 =
 -        new AtomicLongMemoryBlock("Block2", null, 100, MemoryBlockType.PERFORMANCE);
++        new AtomicLongMemoryBlock("Block2", null, 100, MemoryBlockType.DYNAMIC);
+     // Test Attributes
+     Assert.assertEquals("Block1", memoryBlock1.getName());
+     Assert.assertEquals(0, memoryBlock1.getUsedMemoryInBytes());
+     Assert.assertEquals(20, memoryBlock1.getFreeMemoryInBytes());
+     Assert.assertEquals(20, memoryBlock1.getTotalMemorySizeInBytes());
+     Assert.assertEquals(MemoryBlockType.NONE, memoryBlock1.getMemoryBlockType());
+     Assert.assertFalse(memoryBlock1.isReleased());
+ 
+     Assert.assertEquals("Block2", memoryBlock2.getName());
+     Assert.assertEquals(0, memoryBlock2.getUsedMemoryInBytes());
+     Assert.assertEquals(100, memoryBlock2.getFreeMemoryInBytes());
+     Assert.assertEquals(100, memoryBlock2.getTotalMemorySizeInBytes());
 -    Assert.assertEquals(MemoryBlockType.PERFORMANCE, memoryBlock2.getMemoryBlockType());
++    Assert.assertEquals(MemoryBlockType.DYNAMIC, memoryBlock2.getMemoryBlockType());
+     Assert.assertFalse(memoryBlock2.isReleased());
+ 
+     // Test Allocation
+     Assert.assertTrue(memoryBlock1.allocate(10));
+     Assert.assertEquals(10, memoryBlock1.getUsedMemoryInBytes());
+     Assert.assertEquals(10, memoryBlock1.getFreeMemoryInBytes());
+     Assert.assertFalse(memoryBlock1.allocate(20));
+     Assert.assertEquals(10, memoryBlock1.getUsedMemoryInBytes());
+     Assert.assertEquals(10, memoryBlock1.getFreeMemoryInBytes());
+     Assert.assertFalse(memoryBlock1.allocateIfSufficient(10, 0.5));
+     Assert.assertEquals(0, memoryBlock1.release(10));
+     Assert.assertEquals(0, memoryBlock1.getUsedMemoryInBytes());
+     Assert.assertEquals(20, memoryBlock1.getFreeMemoryInBytes());
+     Assert.assertTrue(memoryBlock1.allocateIfSufficient(10, 0.5));
+     Assert.assertEquals(10, memoryBlock1.getUsedMemoryInBytes());
+     Assert.assertEquals(10, memoryBlock1.getFreeMemoryInBytes());
+ 
+     memoryBlock2.markAsReleased();
+     Assert.assertTrue(memoryBlock2.isReleased());
+ 
+     memoryBlock1.close();
+     memoryBlock2.close();
+   }
+ }