Exemplo n.º 1
0
 @Test
 public void test_index_record_delete() {
   long recid = engine.put(1000L, Serializer.LONG_SERIALIZER);
   engine.commit();
   assertEquals(1, countIndexRecords());
   engine.delete(recid, Serializer.LONG_SERIALIZER);
   engine.commit();
   assertEquals(0, countIndexRecords());
 }
Exemplo n.º 2
0
  @Test
  public void test_phys_record_reused() {
    final long recid = engine.put(1L, Serializer.LONG_SERIALIZER);
    final long physRecid = engine.index.getLong(recid * 8 + StorageDirect.INDEX_OFFSET_START * 8);
    engine.delete(recid, Serializer.LONG_SERIALIZER);
    final long recid2 = engine.put(1L, Serializer.LONG_SERIALIZER);

    assertEquals(recid, recid2);
    assertEquals(physRecid, engine.index.getLong(recid * 8 + StorageDirect.INDEX_OFFSET_START * 8));
  }
Exemplo n.º 3
0
 @Test
 public void test_index_record_delete_and_reusef() {
   long recid = engine.put(1000L, Serializer.LONG_SERIALIZER);
   engine.commit();
   assertEquals(1, countIndexRecords());
   assertEquals(Engine.LAST_RESERVED_RECID + 1, recid);
   engine.delete(recid, Serializer.LONG_SERIALIZER);
   engine.commit();
   assertEquals(0, countIndexRecords());
   long recid2 = engine.put(1000L, Serializer.LONG_SERIALIZER);
   engine.commit();
   // test that previously deleted index slot was reused
   assertEquals(recid, recid2);
   assertEquals(1, countIndexRecords());
   assertNotEquals(0, engine.index.getLong(recid * 8 + StorageDirect.INDEX_OFFSET_START * 8));
 }
Exemplo n.º 4
0
  @Test
  public void test_index_record_delete_and_reuse_large() {
    final long MAX = 10;

    List<Long> recids = new ArrayList<Long>();
    for (int i = 0; i < MAX; i++) {
      recids.add(engine.put(0L, Serializer.LONG_SERIALIZER));
    }

    for (long recid : recids) {
      engine.delete(recid, Serializer.LONG_SERIALIZER);
    }

    // now allocate again second recid list
    List<Long> recids2 = new ArrayList<Long>();
    for (int i = 0; i < MAX; i++) {
      recids2.add(engine.put(0L, Serializer.LONG_SERIALIZER));
    }

    // second list should be reverse of first, as Linked Offset List is LIFO
    Collections.reverse(recids);
    assertEquals(recids, recids2);
  }