use of org.bboxdb.storage.entity.Tuple in project bboxdb by jnidzwetzki.
the class TestMemtable method testAquire1.
/**
* Test the aquire
* @throws StorageManagerException
*/
@Test(timeout = 60000)
public void testAquire1() throws StorageManagerException {
final Memtable memtable = new Memtable(MEMTABLE_TABLE_NAME, MEMTABLE_MAX_ENTRIES, MEMTABLE_MAX_SIZE);
memtable.init();
Assert.assertTrue(memtable.acquire());
final Tuple createdTuple1 = new Tuple("1", null, "abc".getBytes(), 60);
memtable.put(createdTuple1);
memtable.deleteOnClose();
Assert.assertFalse(memtable.acquire());
Assert.assertEquals(1, memtable.get("1").size());
memtable.release();
Assert.assertEquals(0, memtable.getSize());
}
use of org.bboxdb.storage.entity.Tuple in project bboxdb by jnidzwetzki.
the class TestMemtable method testNumberOfTuples.
/**
* Test the number of tuples
* @throws StorageManagerException
*/
@Test(timeout = 60000)
public void testNumberOfTuples() throws StorageManagerException {
Assert.assertEquals(0, memtable.getNumberOfTuples());
final Tuple createdTuple1 = new Tuple("1", null, "abc".getBytes(), 60);
memtable.put(createdTuple1);
Assert.assertEquals(1, memtable.getNumberOfTuples());
}
use of org.bboxdb.storage.entity.Tuple in project bboxdb by jnidzwetzki.
the class TestMemtable method testSortedList3.
/**
* Test the sorted tuple list
* @throws StorageManagerException
*/
@Test(timeout = 60000)
public void testSortedList3() throws StorageManagerException {
// Insert key 1
final Tuple createdTuple1 = new Tuple("1", null, "abc".getBytes());
memtable.put(createdTuple1);
Assert.assertEquals(memtable.getSortedTupleList().size(), 1);
// Delete Key 1
memtable.delete("1", System.currentTimeMillis());
Assert.assertEquals(memtable.getSortedTupleList().size(), 2);
}
use of org.bboxdb.storage.entity.Tuple in project bboxdb by jnidzwetzki.
the class TestMemtable method testEmptyCall.
/**
* Test memtable empty
* @throws StorageManagerException
*/
@Test(timeout = 60000)
public void testEmptyCall() throws StorageManagerException {
Assert.assertTrue(memtable.isEmpty());
memtable.clear();
Assert.assertTrue(memtable.isEmpty());
final Tuple createdTuple = new Tuple("3", null, "abc".getBytes());
memtable.put(createdTuple);
Assert.assertFalse(memtable.isEmpty());
memtable.clear();
Assert.assertTrue(memtable.isEmpty());
}
use of org.bboxdb.storage.entity.Tuple in project bboxdb by jnidzwetzki.
the class TestMemtable method testInsertAndReadPerson.
/**
* Test insert2
* @throws Exception
*/
@Test(timeout = 60000)
public void testInsertAndReadPerson() throws Exception {
final PersonEntity person1 = new PersonEntity("Jan", "Jansen", 30);
final ObjectSerializer<PersonEntity> serializer = new ObjectSerializer<PersonEntity>();
final Tuple createdTuple = new Tuple("1", null, serializer.serialize(person1));
memtable.put(createdTuple);
final List<Tuple> readTupleList = memtable.get("1");
Assert.assertTrue(readTupleList.size() == 1);
final Tuple readTuple = readTupleList.get(0);
final PersonEntity readPerson1 = serializer.deserialize(readTuple.getDataBytes());
Assert.assertEquals(person1, readPerson1);
}
Aggregations