Ejemplo n.º 1
0
  @Test
  public void test_index_stores_record_size() throws IOException {

    final long recid = engine.put(1, Serializer.INTEGER_SERIALIZER);
    engine.commit();
    assertEquals(
        4, engine.index.getUnsignedShort(recid * 8 + StorageDirect.INDEX_OFFSET_START * 8));
    assertEquals(Integer.valueOf(1), engine.get(recid, Serializer.INTEGER_SERIALIZER));

    engine.update(recid, 1L, Serializer.LONG_SERIALIZER);
    engine.commit();
    assertEquals(
        8, engine.index.getUnsignedShort(recid * 8 + StorageDirect.INDEX_OFFSET_START * 8));
    assertEquals(Long.valueOf(1), engine.get(recid, Serializer.LONG_SERIALIZER));
  }
Ejemplo n.º 2
0
 @Test
 public void in_memory_test() {
   StorageDirect engine = new StorageDirect(Volume.memoryFactory(false));
   Map<Long, Integer> recids = new HashMap<Long, Integer>();
   for (int i = 0; i < 1000; i++) {
     long recid = engine.put(i, Serializer.BASIC_SERIALIZER);
     recids.put(recid, i);
   }
   for (Long recid : recids.keySet()) {
     assertEquals(recids.get(recid), engine.get(recid, Serializer.BASIC_SERIALIZER));
   }
 }
Ejemplo n.º 3
0
  @Test
  public void compact() {
    Map<Long, Long> recids = new HashMap<Long, Long>();
    for (Long l = 0L; l < 1000; l++) {
      recids.put(l, engine.put(l, Serializer.LONG_SERIALIZER));
    }

    engine.commit();
    engine.compact();

    for (Map.Entry<Long, Long> e : recids.entrySet()) {
      Long recid = e.getValue();
      Long value = e.getKey();
      assertEquals(value, engine.get(recid, Serializer.LONG_SERIALIZER));
    }
  }