Search in sources :

Example 26 with Tuple

use of org.bboxdb.storage.entity.Tuple in project bboxdb by jnidzwetzki.

the class TestStorageManager method testDeleteTuple3.

/**
 * Test the mass deletion of tuples
 * @throws StorageManagerException
 * @throws InterruptedException
 * @throws RejectedException
 */
@Test(timeout = 60000)
public void testDeleteTuple3() throws StorageManagerException, InterruptedException, RejectedException {
    int MAX_TUPLES = getNumberOfTuplesForBigInsert();
    System.out.println("Inserting tuples...");
    for (int i = 0; i < MAX_TUPLES; i++) {
        final Tuple createdTuple = new Tuple(Integer.toString(i), BoundingBox.FULL_SPACE, Integer.toString(i).getBytes());
        storageManager.put(createdTuple);
    }
    storageManager.flush();
    System.out.println("Deleting tuples...");
    for (int i = 0; i < MAX_TUPLES; i++) {
        storageManager.delete(Integer.toString(i), MicroSecondTimestampProvider.getNewTimestamp());
    }
    storageManager.flush();
    System.out.println("Reading tuples...");
    // Fetch the deleted tuples
    for (int i = 0; i < MAX_TUPLES; i++) {
        final List<Tuple> readTuples = storageManager.get(Integer.toString(i));
        Assert.assertEquals(1, readTuples.size());
        Assert.assertTrue(readTuples.get(0) instanceof DeletedTuple);
    }
}
Also used : DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Test(org.junit.Test)

Example 27 with Tuple

use of org.bboxdb.storage.entity.Tuple in project bboxdb by jnidzwetzki.

the class TestStorageManager method testDeleteTuple2.

@Test(timeout = 60000)
public void testDeleteTuple2() throws StorageManagerException, InterruptedException, RejectedException {
    int MAX_TUPLES = 100000;
    int SPECIAL_TUPLE = MAX_TUPLES / 2;
    int DELETE_AFTER = (int) (MAX_TUPLES * 0.75);
    // Ensure that the tuple is not contained in the storage manager
    final List<Tuple> readTuples = storageManager.get(Integer.toString(SPECIAL_TUPLE));
    Assert.assertTrue(readTuples.isEmpty());
    for (int i = 0; i < MAX_TUPLES; i++) {
        final Tuple createdTuple = new Tuple(Integer.toString(i), BoundingBox.FULL_SPACE, Integer.toString(i).getBytes());
        storageManager.put(createdTuple);
        if (i == DELETE_AFTER) {
            storageManager.delete(Integer.toString(SPECIAL_TUPLE), MicroSecondTimestampProvider.getNewTimestamp());
        }
    }
    // Let the storage manager swap the memtables out
    storageManager.flush();
    // Fetch the deleted tuple
    final List<Tuple> readTuples2 = storageManager.get(Integer.toString(SPECIAL_TUPLE));
    Assert.assertEquals(1, readTuples2.size());
    Assert.assertTrue(readTuples2.get(0) instanceof DeletedTuple);
}
Also used : DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Test(org.junit.Test)

Example 28 with Tuple

use of org.bboxdb.storage.entity.Tuple in project bboxdb by jnidzwetzki.

the class TestStorageManager method testWithDuplicates.

/**
 * Test the storage manager with duplicates
 * @throws StorageManagerException
 * @throws RejectedException
 */
@Test(timeout = 60000)
public void testWithDuplicates() throws StorageManagerException, RejectedException {
    // Delete the old table
    storageRegistry.deleteTable(TEST_RELATION, true);
    // Create a new table
    final TupleStoreConfiguration tupleStoreConfiguration = TupleStoreConfigurationBuilder.create().allowDuplicates(true).build();
    storageRegistry.createTable(TEST_RELATION, tupleStoreConfiguration);
    // Assure table is created successfully
    storageManager = storageRegistry.getTupleStoreManager(TEST_RELATION);
    Assert.assertTrue(storageManager.getServiceState().isInRunningState());
    final Tuple tuple1 = new Tuple("abc", BoundingBox.FULL_SPACE, "abc1".getBytes());
    storageManager.put(tuple1);
    final Tuple tuple2 = new Tuple("abc", BoundingBox.FULL_SPACE, "abc2".getBytes());
    storageManager.put(tuple2);
    final Tuple tuple3 = new Tuple("abc", BoundingBox.FULL_SPACE, "abc3".getBytes());
    storageManager.put(tuple3);
    final Tuple tuple4 = new Tuple("abc", BoundingBox.FULL_SPACE, "abc4".getBytes());
    storageManager.put(tuple4);
    final Tuple tuple5 = new Tuple("abc", BoundingBox.FULL_SPACE, "abc5".getBytes());
    storageManager.put(tuple5);
    final List<Tuple> readTuples = storageManager.get("abc");
    Assert.assertEquals(5, readTuples.size());
    Assert.assertTrue(readTuples.contains(tuple1));
    Assert.assertTrue(readTuples.contains(tuple2));
    Assert.assertTrue(readTuples.contains(tuple3));
    Assert.assertTrue(readTuples.contains(tuple4));
    Assert.assertTrue(readTuples.contains(tuple5));
}
Also used : TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Test(org.junit.Test)

Example 29 with Tuple

use of org.bboxdb.storage.entity.Tuple in project bboxdb by jnidzwetzki.

the class TestStorageManager method testInsertElements2.

@Test(timeout = 60000)
public void testInsertElements2() throws Exception {
    final Tuple tuple1 = new Tuple("1", BoundingBox.FULL_SPACE, "abc".getBytes());
    final Tuple tuple2 = new Tuple("1", BoundingBox.FULL_SPACE, "def".getBytes());
    storageManager.put(tuple1);
    storageManager.put(tuple2);
    Assert.assertEquals(tuple2, storageManager.get("1").get(0));
}
Also used : Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Test(org.junit.Test)

Example 30 with Tuple

use of org.bboxdb.storage.entity.Tuple in project bboxdb by jnidzwetzki.

the class TestStorageManager method testDeleteTuple.

@Test(timeout = 60000)
public void testDeleteTuple() throws StorageManagerException, InterruptedException, RejectedException {
    int MAX_TUPLES = 100000;
    int SPECIAL_TUPLE = MAX_TUPLES / 2;
    for (int i = 0; i < MAX_TUPLES; i++) {
        final Tuple createdTuple = new Tuple(Integer.toString(i), BoundingBox.FULL_SPACE, Integer.toString(i).getBytes());
        storageManager.put(createdTuple);
        if (i == SPECIAL_TUPLE) {
            storageManager.delete(Integer.toString(SPECIAL_TUPLE), createdTuple.getVersionTimestamp() + 1);
        }
    }
    storageManager.flush();
    final List<Tuple> readTuples = storageManager.get(Integer.toString(SPECIAL_TUPLE));
    Assert.assertEquals(1, readTuples.size());
    Assert.assertTrue(readTuples.get(0) instanceof DeletedTuple);
}
Also used : DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) 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