use of org.bboxdb.storage.entity.Tuple in project bboxdb by jnidzwetzki.
the class TestStorageManager method testInsertElements1.
@Test(timeout = 60000)
public void testInsertElements1() throws Exception {
final Tuple tuple = new Tuple("1", BoundingBox.FULL_SPACE, "abc".getBytes());
storageManager.put(tuple);
Assert.assertEquals(tuple, storageManager.get("1").get(0));
}
use of org.bboxdb.storage.entity.Tuple in project bboxdb by jnidzwetzki.
the class TestStorageRegistry method testCalculateSize.
/**
* Calculate the size of a distribution group
* @throws StorageManagerException
* @throws InterruptedException
* @throws RejectedException
*/
@Test(timeout = 60000)
public void testCalculateSize() throws StorageManagerException, InterruptedException, RejectedException {
storageRegistry.deleteTable(RELATION_NAME, true);
Assert.assertFalse(storageRegistry.isStorageManagerActive(RELATION_NAME));
storageRegistry.createTable(RELATION_NAME, new TupleStoreConfiguration());
final TupleStoreManager storageManager = storageRegistry.getTupleStoreManager(RELATION_NAME);
for (int i = 0; i < 50000; i++) {
final Tuple createdTuple = new Tuple(Integer.toString(i), BoundingBox.FULL_SPACE, Integer.toString(i).getBytes());
storageManager.put(createdTuple);
}
// Wait for requests to settle
storageManager.flush();
final List<TupleStoreName> tablesBeforeDelete = storageRegistry.getAllTables();
System.out.println(tablesBeforeDelete);
Assert.assertTrue(tablesBeforeDelete.contains(RELATION_NAME));
final long size1 = TupleStoreUtil.getSizeOfDistributionGroupAndRegionId(storageRegistry, RELATION_NAME.getDistributionGroup(), 2);
Assert.assertTrue(size1 > 0);
storageRegistry.deleteTable(RELATION_NAME, true);
final List<TupleStoreName> tablesAfterDelete = storageRegistry.getAllTables();
System.out.println(tablesAfterDelete);
Assert.assertFalse(tablesAfterDelete.contains(RELATION_NAME));
final long size2 = TupleStoreUtil.getSizeOfDistributionGroupAndRegionId(storageRegistry, RELATION_NAME.getDistributionGroup(), 2);
Assert.assertTrue(size2 == 0);
}
use of org.bboxdb.storage.entity.Tuple in project bboxdb by jnidzwetzki.
the class TestTableCompactor method testCompactTestFileOneEmptyfile1.
@Test(timeout = 60000)
public void testCompactTestFileOneEmptyfile1() throws StorageManagerException {
final List<Tuple> tupleList1 = new ArrayList<Tuple>();
tupleList1.add(new Tuple("1", BoundingBox.FULL_SPACE, "abc".getBytes()));
final SSTableKeyIndexReader reader1 = addTuplesToFileAndGetReader(tupleList1, 1);
final List<Tuple> tupleList2 = new ArrayList<Tuple>();
final SSTableKeyIndexReader reader2 = addTuplesToFileAndGetReader(tupleList2, 2);
final SSTableKeyIndexReader ssTableIndexReader = exectuteCompactAndGetReader(reader1, reader2, false);
int counter = 0;
for (@SuppressWarnings("unused") final Tuple tuple : ssTableIndexReader) {
counter++;
}
Assert.assertEquals(tupleList1.size() + tupleList2.size(), counter);
}
use of org.bboxdb.storage.entity.Tuple in project bboxdb by jnidzwetzki.
the class TestTableCompactor method testCompactationMajor1.
/**
* Test a major compactation
* @throws StorageManagerException
*/
@Test(timeout = 60000)
public void testCompactationMajor1() throws StorageManagerException {
final List<Tuple> tupleList1 = new ArrayList<Tuple>();
tupleList1.add(new Tuple("1", BoundingBox.FULL_SPACE, "abc".getBytes()));
final SSTableKeyIndexReader reader1 = addTuplesToFileAndGetReader(tupleList1, 1);
final List<Tuple> tupleList2 = new ArrayList<Tuple>();
tupleList2.add(new DeletedTuple("2"));
final SSTableKeyIndexReader reader2 = addTuplesToFileAndGetReader(tupleList2, 2);
final SSTableKeyIndexReader ssTableIndexReader = exectuteCompactAndGetReader(reader1, reader2, true);
boolean containsDeletedTuple = false;
int counter = 0;
for (final Tuple tuple : ssTableIndexReader) {
counter++;
if (tuple instanceof DeletedTuple) {
containsDeletedTuple = true;
}
}
Assert.assertEquals(1, counter);
Assert.assertFalse(containsDeletedTuple);
}
use of org.bboxdb.storage.entity.Tuple in project bboxdb by jnidzwetzki.
the class TestTableCompactor method testCompactorRunnable.
/**
* Test the compactor runnable
* @throws RejectedException
* @throws StorageManagerException
* @throws InterruptedException
* @throws BBoxDBException
*/
@Test(timeout = 60000)
public void testCompactorRunnable() throws StorageManagerException, RejectedException, BBoxDBException, InterruptedException {
storageRegistry.createTable(TEST_RELATION, new TupleStoreConfiguration());
final TupleStoreManager storageManager = storageRegistry.getTupleStoreManager(TEST_RELATION);
Assert.assertTrue(storageManager.getServiceState().isInRunningState());
// Create file 1
for (int i = 0; i < 1000; i++) {
storageManager.put(new Tuple(Integer.toString(i), BoundingBox.FULL_SPACE, "abc".getBytes()));
}
storageManager.flush();
// Create file 2
for (int i = 0; i < 1000; i++) {
storageManager.put(new Tuple(Integer.toString(i), BoundingBox.FULL_SPACE, "abc".getBytes()));
}
storageManager.flush();
final List<DiskStorage> storages = storageRegistry.getAllStorages();
Assert.assertEquals(1, storages.size());
final SSTableServiceRunnable ssTableCompactorRunnable = new SSTableServiceRunnable(storages.get(0));
ssTableCompactorRunnable.forceMajorCompact(storageManager);
// Test exception handler
final List<ReadOnlyTupleStore> writtenStorages = storageManager.aquireStorage();
storageManager.releaseStorage(writtenStorages);
storageManager.shutdown();
final List<SSTableFacade> tupleStorages = writtenStorages.stream().filter(r -> r instanceof SSTableFacade).map(r -> (SSTableFacade) r).collect(Collectors.toList());
Assert.assertFalse(tupleStorages.isEmpty());
ssTableCompactorRunnable.handleCompactException(tupleStorages);
}
Aggregations