Search in sources :

Example 6 with OByteBufferPool

use of com.orientechnologies.common.directmemory.OByteBufferPool in project orientdb by orientechnologies.

the class WALChangesTreeTest method testInsertCaseThreeDM.

public void testInsertCaseThreeDM() {
    final OWALChangesTree tree = new OWALChangesTree();
    tree.setDebug(true);
    tree.add(new byte[] { 10 }, 10);
    tree.add(new byte[] { 5 }, 5);
    tree.add(new byte[] { 15 }, 15);
    tree.add(new byte[] { 2 }, 2);
    OByteBufferPool bufferPool = new OByteBufferPool(20);
    ByteBuffer buffer = bufferPool.acquireDirect(true);
    tree.applyChanges(buffer);
    Assert.assertEquals(getByteArray(buffer, 10, 1), new byte[] { 10 });
    Assert.assertEquals(getByteArray(buffer, 5, 1), new byte[] { 5 });
    Assert.assertEquals(getByteArray(buffer, 15, 1), new byte[] { 15 });
    Assert.assertEquals(getByteArray(buffer, 2, 1), new byte[] { 2 });
}
Also used : OByteBufferPool(com.orientechnologies.common.directmemory.OByteBufferPool) ByteBuffer(java.nio.ByteBuffer)

Example 7 with OByteBufferPool

use of com.orientechnologies.common.directmemory.OByteBufferPool in project orientdb by orientechnologies.

the class LRUListTest method testAddOneRemoveLRU.

@Test
public void testAddOneRemoveLRU() {
    final OByteBufferPool bufferPool = new OByteBufferPool(1);
    ByteBuffer buffer = bufferPool.acquireDirect(true);
    OCachePointer cachePointerOne = new OCachePointer(buffer, bufferPool, new OLogSequenceNumber(0, 0), 0, 0);
    lruList.putToMRU(new OCacheEntry(1, 10, cachePointerOne, false));
    lruList.removeLRU();
    Assert.assertEquals(lruList.size(), 0);
    Iterator<OCacheEntry> entryIterator = lruList.iterator();
    Assert.assertFalse(entryIterator.hasNext());
}
Also used : OCacheEntry(com.orientechnologies.orient.core.storage.cache.OCacheEntry) OLogSequenceNumber(com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OLogSequenceNumber) OByteBufferPool(com.orientechnologies.common.directmemory.OByteBufferPool) ByteBuffer(java.nio.ByteBuffer) OCachePointer(com.orientechnologies.orient.core.storage.cache.OCachePointer) Test(org.testng.annotations.Test)

Example 8 with OByteBufferPool

use of com.orientechnologies.common.directmemory.OByteBufferPool in project orientdb by orientechnologies.

the class LRUListTest method testSingleAdd.

@Test
public void testSingleAdd() {
    final OByteBufferPool bufferPool = new OByteBufferPool(1);
    final ByteBuffer buffer = bufferPool.acquireDirect(true);
    OCachePointer cachePointer = new OCachePointer(buffer, bufferPool, new OLogSequenceNumber(0, 0), 0, 0);
    lruList.putToMRU(new OCacheEntry(1, 10, cachePointer, false));
    Iterator<OCacheEntry> entryIterator = lruList.iterator();
    Assert.assertTrue(entryIterator.hasNext());
    Assert.assertEquals(entryIterator.next(), new OCacheEntry(1, 10, cachePointer, false));
}
Also used : OCacheEntry(com.orientechnologies.orient.core.storage.cache.OCacheEntry) OLogSequenceNumber(com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OLogSequenceNumber) OByteBufferPool(com.orientechnologies.common.directmemory.OByteBufferPool) ByteBuffer(java.nio.ByteBuffer) OCachePointer(com.orientechnologies.orient.core.storage.cache.OCachePointer) Test(org.testng.annotations.Test)

Example 9 with OByteBufferPool

use of com.orientechnologies.common.directmemory.OByteBufferPool in project orientdb by orientechnologies.

the class WOWCacheTest method initBuffer.

private void initBuffer() throws IOException {
    wowCache = new OWOWCache(true, pageSize, new OByteBufferPool(pageSize), 10000, writeAheadLog, 10, 100, 100, storageLocal, false, files, 1);
    wowCache.loadRegisteredFiles();
}
Also used : OWOWCache(com.orientechnologies.orient.core.storage.cache.local.OWOWCache) OByteBufferPool(com.orientechnologies.common.directmemory.OByteBufferPool)

Example 10 with OByteBufferPool

use of com.orientechnologies.common.directmemory.OByteBufferPool in project orientdb by orientechnologies.

the class LRUListTest method testAddThreePutMiddleToTopChangePointer.

@Test
public void testAddThreePutMiddleToTopChangePointer() {
    final OByteBufferPool bufferPool = new OByteBufferPool(1);
    ByteBuffer bufferOne = bufferPool.acquireDirect(true);
    ByteBuffer bufferTwo = bufferPool.acquireDirect(true);
    ByteBuffer bufferThree = bufferPool.acquireDirect(true);
    ByteBuffer bufferFour = bufferPool.acquireDirect(true);
    OCachePointer cachePointerOne = new OCachePointer(bufferOne, bufferPool, new OLogSequenceNumber(0, 0), 0, 0);
    OCachePointer cachePointerTwo = new OCachePointer(bufferTwo, bufferPool, new OLogSequenceNumber(0, 0), 0, 0);
    OCachePointer cachePointerThree = new OCachePointer(bufferThree, bufferPool, new OLogSequenceNumber(0, 0), 0, 0);
    OCachePointer cachePointerFour = new OCachePointer(bufferFour, bufferPool, new OLogSequenceNumber(0, 0), 0, 0);
    lruList.putToMRU(new OCacheEntry(1, 10, cachePointerOne, false));
    lruList.putToMRU(new OCacheEntry(1, 20, cachePointerTwo, false));
    lruList.putToMRU(new OCacheEntry(3, 30, cachePointerThree, false));
    lruList.putToMRU(new OCacheEntry(1, 20, cachePointerFour, false));
    Assert.assertEquals(lruList.size(), 3);
    Iterator<OCacheEntry> entryIterator = lruList.iterator();
    Assert.assertTrue(entryIterator.hasNext());
    Assert.assertEquals(entryIterator.next(), new OCacheEntry(1, 20, cachePointerFour, false));
    Assert.assertEquals(entryIterator.next(), new OCacheEntry(3, 30, cachePointerThree, false));
    Assert.assertEquals(entryIterator.next(), new OCacheEntry(1, 10, cachePointerOne, false));
}
Also used : OCacheEntry(com.orientechnologies.orient.core.storage.cache.OCacheEntry) OLogSequenceNumber(com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OLogSequenceNumber) OByteBufferPool(com.orientechnologies.common.directmemory.OByteBufferPool) ByteBuffer(java.nio.ByteBuffer) OCachePointer(com.orientechnologies.orient.core.storage.cache.OCachePointer) Test(org.testng.annotations.Test)

Aggregations

OByteBufferPool (com.orientechnologies.common.directmemory.OByteBufferPool)78 ByteBuffer (java.nio.ByteBuffer)73 OCacheEntry (com.orientechnologies.orient.core.storage.cache.OCacheEntry)69 OLogSequenceNumber (com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OLogSequenceNumber)69 OCachePointer (com.orientechnologies.orient.core.storage.cache.OCachePointer)61 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)20 OWALChangesTree (com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OWALChangesTree)19 Test (org.testng.annotations.Test)15 Random (java.util.Random)10 ORecordId (com.orientechnologies.orient.core.id.ORecordId)8 HashMap (java.util.HashMap)8 Map (java.util.Map)8 TreeSet (java.util.TreeSet)8 OWOWCache (com.orientechnologies.orient.core.storage.cache.local.OWOWCache)4 OStorageSegmentConfiguration (com.orientechnologies.orient.core.config.OStorageSegmentConfiguration)1 O2QCache (com.orientechnologies.orient.core.storage.cache.local.twoq.O2QCache)1 ODiskWriteAheadLog (com.orientechnologies.orient.core.storage.impl.local.paginated.wal.ODiskWriteAheadLog)1 WriteAheadLogTest (com.orientechnologies.orient.core.storage.impl.local.paginated.wal.WriteAheadLogTest)1 File (java.io.File)1