Search in sources :

Example 11 with DataNodeMemoryManager

use of io.mycat.memory.unsafe.memory.mm.DataNodeMemoryManager in project Mycat-Server by MyCATApache.

the class TaskMemoryManagerSuite method cooperativeSpilling.

@Test
public void cooperativeSpilling() throws InterruptedException {
    final TestMemoryManager memoryManager = new TestMemoryManager(new MycatPropertyConf());
    memoryManager.limit(100);
    final DataNodeMemoryManager manager = new DataNodeMemoryManager(memoryManager, 0);
    TestMemoryConsumer c1 = new TestMemoryConsumer(manager);
    TestMemoryConsumer c2 = new TestMemoryConsumer(manager);
    c1.use(100);
    Assert.assertEquals(100, c1.getUsed());
    c2.use(100);
    Assert.assertEquals(100, c2.getUsed());
    // spilled
    Assert.assertEquals(0, c1.getUsed());
    c1.use(100);
    Assert.assertEquals(100, c1.getUsed());
    // spilled
    Assert.assertEquals(0, c2.getUsed());
    c1.use(50);
    // spilled
    Assert.assertEquals(50, c1.getUsed());
    Assert.assertEquals(0, c2.getUsed());
    c2.use(50);
    Assert.assertEquals(50, c1.getUsed());
    Assert.assertEquals(50, c2.getUsed());
    c1.use(100);
    Assert.assertEquals(100, c1.getUsed());
    // spilled
    Assert.assertEquals(0, c2.getUsed());
    c1.free(20);
    Assert.assertEquals(80, c1.getUsed());
    c2.use(10);
    Assert.assertEquals(80, c1.getUsed());
    Assert.assertEquals(10, c2.getUsed());
    c2.use(100);
    Assert.assertEquals(100, c2.getUsed());
    // spilled
    Assert.assertEquals(0, c1.getUsed());
    c1.free(0);
    c2.free(100);
    Assert.assertEquals(0, manager.cleanUpAllAllocatedMemory());
}
Also used : DataNodeMemoryManager(io.mycat.memory.unsafe.memory.mm.DataNodeMemoryManager) MycatPropertyConf(io.mycat.memory.unsafe.utils.MycatPropertyConf) Test(org.junit.Test)

Example 12 with DataNodeMemoryManager

use of io.mycat.memory.unsafe.memory.mm.DataNodeMemoryManager in project Mycat-Server by MyCATApache.

the class UnsafeInMemorySorterSuite method testSortingEmptyInput.

@Test
public void testSortingEmptyInput() {
    final DataNodeMemoryManager memoryManager = new DataNodeMemoryManager(new TestMemoryManager(new MycatPropertyConf().set("mycat.memory.offHeap.enabled", "false")), 0);
    final TestMemoryConsumer consumer = new TestMemoryConsumer(memoryManager);
    final UnsafeInMemorySorter sorter = new UnsafeInMemorySorter(consumer, memoryManager, mock(RecordComparator.class), mock(PrefixComparator.class), 100, shouldUseRadixSort(), true);
    final UnsafeSorterIterator iter = sorter.getSortedIterator();
    Assert.assertFalse(iter.hasNext());
}
Also used : TestMemoryManager(io.mycat.memory.unsafe.memory.TestMemoryManager) TestMemoryConsumer(io.mycat.memory.unsafe.memory.TestMemoryConsumer) DataNodeMemoryManager(io.mycat.memory.unsafe.memory.mm.DataNodeMemoryManager) MycatPropertyConf(io.mycat.memory.unsafe.utils.MycatPropertyConf) Test(org.junit.Test)

Aggregations

DataNodeMemoryManager (io.mycat.memory.unsafe.memory.mm.DataNodeMemoryManager)12 Test (org.junit.Test)10 MycatPropertyConf (io.mycat.memory.unsafe.utils.MycatPropertyConf)8 StructType (io.mycat.memory.unsafe.row.StructType)5 BufferHolder (io.mycat.memory.unsafe.row.BufferHolder)4 UnsafeRow (io.mycat.memory.unsafe.row.UnsafeRow)4 UnsafeRowWriter (io.mycat.memory.unsafe.row.UnsafeRowWriter)4 ColMeta (io.mycat.sqlengine.mpp.ColMeta)4 OrderCol (io.mycat.sqlengine.mpp.OrderCol)4 MyCatMemory (io.mycat.memory.MyCatMemory)3 MemoryManager (io.mycat.memory.unsafe.memory.mm.MemoryManager)3 TestMemoryConsumer (io.mycat.memory.unsafe.memory.TestMemoryConsumer)2 TestMemoryManager (io.mycat.memory.unsafe.memory.TestMemoryManager)2 PrefixComparator (io.mycat.memory.unsafe.utils.sort.PrefixComparator)2 RowPrefixComputer (io.mycat.memory.unsafe.utils.sort.RowPrefixComputer)2 UnsafeExternalRowSorter (io.mycat.memory.unsafe.utils.sort.UnsafeExternalRowSorter)2 MemoryBlock (io.mycat.memory.unsafe.memory.MemoryBlock)1 ResultMergeMemoryManager (io.mycat.memory.unsafe.memory.mm.ResultMergeMemoryManager)1 DataNodeDiskManager (io.mycat.memory.unsafe.storage.DataNodeDiskManager)1 SerializerManager (io.mycat.memory.unsafe.storage.SerializerManager)1