Package com.orientechnologies.common.directmemory

Examples of com.orientechnologies.common.directmemory.ODirectMemoryPointer


    cachePointer.decrementReferrer();
  }

  public void testSetRightSibling() throws Exception {
    ODirectMemoryPointer pointer = new ODirectMemoryPointer(OSBTreeBucket.MAX_PAGE_SIZE_BYTES + ODurablePage.PAGE_PADDING);
    OCachePointer cachePointer = new OCachePointer(pointer, new OLogSequenceNumber(0, 0));
    cachePointer.incrementReferrer();

    OCacheEntry cacheEntry = new OCacheEntry(0, 0, cachePointer, false);
View Full Code Here


  @Override
  @Test(enabled = false)
  public void init() throws Exception {
    super.init();

    directMemoryPointer = new ODirectMemoryPointer(OBinarySerializerFactory.getInstance().getObjectSerializer(OType.STRING)
        .getObjectSize(longString));
  }
View Full Code Here

  protected LRUList lruList;

  @Test
  public void testSingleAdd() {
    ODirectMemoryPointer directMemoryPointer = new ODirectMemoryPointer(1);
    OCachePointer cachePointer = new OCachePointer(directMemoryPointer, new OLogSequenceNumber(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));
    directMemoryPointer.free();
  }
View Full Code Here

    directMemoryPointer.free();
  }

  @Test
  public void testAddTwo() {
    ODirectMemoryPointer directMemoryPointerOne = new ODirectMemoryPointer(1);
    ODirectMemoryPointer directMemoryPointerTwo = new ODirectMemoryPointer(1);

    OCachePointer cachePointerOne = new OCachePointer(directMemoryPointerOne, new OLogSequenceNumber(0, 0));
    OCachePointer cachePointerTwo = new OCachePointer(directMemoryPointerTwo, new OLogSequenceNumber(0, 0));

    lruList.putToMRU(new OCacheEntry(1, 10, cachePointerOne, false));
    lruList.putToMRU(new OCacheEntry(1, 20, cachePointerTwo, false));

    Assert.assertEquals(lruList.size(), 2);

    Iterator<OCacheEntry> entryIterator = lruList.iterator();
    Assert.assertTrue(entryIterator.hasNext());

    Assert.assertEquals(entryIterator.next(), new OCacheEntry(1, 20, cachePointerTwo, false));
    Assert.assertEquals(entryIterator.next(), new OCacheEntry(1, 10, cachePointerOne, false));

    directMemoryPointerOne.free();
    directMemoryPointerTwo.free();
  }
View Full Code Here

    directMemoryPointerTwo.free();
  }

  @Test
  public void testAddThree() {
    ODirectMemoryPointer directMemoryPointerOne = new ODirectMemoryPointer(1);
    ODirectMemoryPointer directMemoryPointerTwo = new ODirectMemoryPointer(1);
    ODirectMemoryPointer directMemoryPointerThree = new ODirectMemoryPointer(1);

    OCachePointer cachePointerOne = new OCachePointer(directMemoryPointerOne, new OLogSequenceNumber(0, 0));
    OCachePointer cachePointerTwo = new OCachePointer(directMemoryPointerTwo, new OLogSequenceNumber(0, 0));
    OCachePointer cachePointerThree = new OCachePointer(directMemoryPointerThree, new OLogSequenceNumber(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));

    Assert.assertEquals(lruList.size(), 3);

    Iterator<OCacheEntry> entryIterator = lruList.iterator();
    Assert.assertTrue(entryIterator.hasNext());

    Assert.assertEquals(entryIterator.next(), new OCacheEntry(3, 30, cachePointerThree, false));
    Assert.assertEquals(entryIterator.next(), new OCacheEntry(1, 20, cachePointerTwo, false));
    Assert.assertEquals(entryIterator.next(), new OCacheEntry(1, 10, cachePointerOne, false));

    directMemoryPointerOne.free();
    directMemoryPointerTwo.free();
    directMemoryPointerThree.free();
  }
View Full Code Here

    directMemoryPointerThree.free();
  }

  @Test
  public void testAddThreePutMiddleToTop() {
    ODirectMemoryPointer directMemoryPointerOne = new ODirectMemoryPointer(1);
    ODirectMemoryPointer directMemoryPointerTwo = new ODirectMemoryPointer(1);
    ODirectMemoryPointer directMemoryPointerThree = new ODirectMemoryPointer(1);

    OCachePointer cachePointerOne = new OCachePointer(directMemoryPointerOne, new OLogSequenceNumber(0, 0));
    OCachePointer cachePointerTwo = new OCachePointer(directMemoryPointerTwo, new OLogSequenceNumber(0, 0));
    OCachePointer cachePointerThree = new OCachePointer(directMemoryPointerThree, new OLogSequenceNumber(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, cachePointerTwo, false));

    Assert.assertEquals(lruList.size(), 3);

    Iterator<OCacheEntry> entryIterator = lruList.iterator();
    Assert.assertTrue(entryIterator.hasNext());

    Assert.assertEquals(entryIterator.next(), new OCacheEntry(1, 20, cachePointerTwo, false));
    Assert.assertEquals(entryIterator.next(), new OCacheEntry(3, 30, cachePointerThree, false));
    Assert.assertEquals(entryIterator.next(), new OCacheEntry(1, 10, cachePointerOne, false));

    directMemoryPointerOne.free();
    directMemoryPointerTwo.free();
    directMemoryPointerThree.free();
  }
View Full Code Here

    directMemoryPointerThree.free();
  }

  @Test
  public void testAddThreePutMiddleToTopChangePointer() {
    ODirectMemoryPointer directMemoryPointerOne = new ODirectMemoryPointer(1);
    ODirectMemoryPointer directMemoryPointerTwo = new ODirectMemoryPointer(1);
    ODirectMemoryPointer directMemoryPointerThree = new ODirectMemoryPointer(1);
    ODirectMemoryPointer directMemoryPointerFour = new ODirectMemoryPointer(1);

    OCachePointer cachePointerOne = new OCachePointer(directMemoryPointerOne, new OLogSequenceNumber(0, 0));
    OCachePointer cachePointerTwo = new OCachePointer(directMemoryPointerTwo, new OLogSequenceNumber(0, 0));
    OCachePointer cachePointerThree = new OCachePointer(directMemoryPointerThree, new OLogSequenceNumber(0, 0));
    OCachePointer cachePointerFour = new OCachePointer(directMemoryPointerFour, new OLogSequenceNumber(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));

    directMemoryPointerOne.free();
    directMemoryPointerTwo.free();
    directMemoryPointerThree.free();
    directMemoryPointerFour.free();
  }
View Full Code Here

  @Test
  public void testAddElevenPutMiddleToTopChangePointer() {
    OCachePointer[] cachePointers = new OCachePointer[11];

    for (int i = 0; i < 11; i++) {
      ODirectMemoryPointer directMemoryPointer = new ODirectMemoryPointer(1);

      cachePointers[i] = new OCachePointer(directMemoryPointer, new OLogSequenceNumber(0, 0));
      lruList.putToMRU(new OCacheEntry(1, i * 10, cachePointers[i], false));
    }

View Full Code Here

    }
  }

  @Test
  public void testAddOneRemoveLRU() {
    ODirectMemoryPointer directMemoryPointer = new ODirectMemoryPointer(1);

    OCachePointer cachePointerOne = new OCachePointer(directMemoryPointer, new OLogSequenceNumber(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());

    directMemoryPointer.free();
  }
View Full Code Here

    directMemoryPointer.free();
  }

  @Test
  public void testRemoveLRUShouldReturnNullIfAllRecordsAreUsed() {
    ODirectMemoryPointer directMemoryPointer = new ODirectMemoryPointer(1);

    OCachePointer cachePointerOne = new OCachePointer(directMemoryPointer, new OLogSequenceNumber(0, 0));
    OCacheEntry cacheEntry = new OCacheEntry(1, 10, cachePointerOne, false);
    lruList.putToMRU(cacheEntry);
    cacheEntry.usagesCount++;

    OCacheEntry removedLRU = lruList.removeLRU();

    Assert.assertNull(removedLRU);

    directMemoryPointer.free();
  }
View Full Code Here

TOP

Related Classes of com.orientechnologies.common.directmemory.ODirectMemoryPointer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.