예제 #1
0
  @Test
  public void test_freePhysRecSize2FreeSlot_asserts() {
    try {
      engine.freePhysRecSize2FreeSlot(StorageDirect.MAX_RECORD_SIZE + 1);
      fail();
    } catch (IllegalArgumentException e) {
      // expected
    }

    try {
      engine.freePhysRecSize2FreeSlot(-1);
      fail();
    } catch (IllegalArgumentException e) {
      // expected
    }
  }
예제 #2
0
 @Test
 public void test_freePhysRecSize2FreeSlot_incremental() {
   int oldSlot = -1;
   for (int size = 1; size <= StorageDirect.MAX_RECORD_SIZE; size++) {
     int slot = engine.freePhysRecSize2FreeSlot(size);
     assertTrue(slot >= 0);
     assertTrue(oldSlot <= slot);
     assertTrue(slot - oldSlot <= 1);
     oldSlot = slot;
   }
   assertEquals(StorageDirect.NUMBER_OF_PHYS_FREE_SLOT - 1, oldSlot);
 }
예제 #3
0
  @Test
  public void test_freePhys_PutAndTake() throws IOException {
    engine.lock.writeLock().lock();

    final long offset = 1111000;
    final int size = 344;
    final long indexVal = (((long) size) << 48) | offset;

    engine.freePhysRecPut(indexVal);

    assertEquals(indexVal, engine.freePhysRecTake(size));
    assertEquals(
        arrayList(),
        getLongStack(
            StorageDirect.RECID_FREE_PHYS_RECORDS_START + engine.freePhysRecSize2FreeSlot(size)));
  }
예제 #4
0
 @Test
 public void test_freePhysRecSize2FreeSlot_max_size_has_unique_slot() {
   int slotMax = engine.freePhysRecSize2FreeSlot(StorageDirect.MAX_RECORD_SIZE);
   int slotMaxMinus1 = engine.freePhysRecSize2FreeSlot(StorageDirect.MAX_RECORD_SIZE - 1);
   assertEquals(slotMax, slotMaxMinus1 + 1);
 }