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 });
}
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());
}
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));
}
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();
}
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));
}
Aggregations