Search in sources :

Example 56 with Tuple

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());
}
Also used : Memtable(org.bboxdb.storage.memtable.Memtable) Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Test(org.junit.Test)

Example 57 with Tuple

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());
}
Also used : Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Test(org.junit.Test)

Example 58 with Tuple

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);
}
Also used : Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Test(org.junit.Test)

Example 59 with Tuple

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());
}
Also used : Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Test(org.junit.Test)

Example 60 with Tuple

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);
}
Also used : PersonEntity(org.bboxdb.commons.entity.PersonEntity) ObjectSerializer(org.bboxdb.commons.ObjectSerializer) Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Test(org.junit.Test)

Aggregations

Tuple (org.bboxdb.storage.entity.Tuple)198 Test (org.junit.Test)123 DeletedTuple (org.bboxdb.storage.entity.DeletedTuple)104 BoundingBox (org.bboxdb.commons.math.BoundingBox)62 JoinedTuple (org.bboxdb.storage.entity.JoinedTuple)58 ArrayList (java.util.ArrayList)41 TupleStoreConfiguration (org.bboxdb.storage.entity.TupleStoreConfiguration)25 TupleStoreName (org.bboxdb.storage.entity.TupleStoreName)24 TupleListFuture (org.bboxdb.network.client.future.TupleListFuture)18 TupleStoreManager (org.bboxdb.storage.tuplestore.manager.TupleStoreManager)18 ByteBuffer (java.nio.ByteBuffer)17 BBoxDBException (org.bboxdb.misc.BBoxDBException)16 EmptyResultFuture (org.bboxdb.network.client.future.EmptyResultFuture)15 SSTableKeyIndexReader (org.bboxdb.storage.sstable.reader.SSTableKeyIndexReader)13 IOException (java.io.IOException)11 List (java.util.List)11 JoinedTupleListFuture (org.bboxdb.network.client.future.JoinedTupleListFuture)11 InsertTupleRequest (org.bboxdb.network.packages.request.InsertTupleRequest)11 StorageManagerException (org.bboxdb.storage.StorageManagerException)11 TupleBuilder (org.bboxdb.tools.converter.tuple.TupleBuilder)11