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);
}
}
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);
}
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));
}
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));
}
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);
}
Aggregations