use of org.bboxdb.storage.tuplestore.manager.TupleStoreManager in project bboxdb by jnidzwetzki.
the class TestQueryProcessing method testJoinWithChangedTuple1.
/**
* Simple Join
* @throws StorageManagerException
* @throws RejectedException
*/
@Test(timeout = 60000)
public void testJoinWithChangedTuple1() throws StorageManagerException, RejectedException {
final TupleStoreManager storageManager1 = storageRegistry.getTupleStoreManager(TABLE_1);
final TupleStoreManager storageManager2 = storageRegistry.getTupleStoreManager(TABLE_2);
final Tuple tuple1 = new Tuple("1a", new BoundingBox(1.0, 2.0, 1.0, 2.0), "value1".getBytes());
final Tuple tuple2 = new Tuple("2a", new BoundingBox(4.0, 5.0, 4.0, 5.0), "value2".getBytes());
// Tuple 3 and tuple 4 have the same key
final Tuple tuple3 = new Tuple("1b", new BoundingBox(1.5, 2.5, 1.5, 2.5), "value3".getBytes());
final Tuple tuple4 = new Tuple("1b", new BoundingBox(2.5, 5.5, 2.5, 5.5), "value4".getBytes());
// Table1
storageManager1.put(tuple1);
storageManager1.put(tuple2);
// Table2
storageManager2.put(tuple3);
storageManager2.put(tuple4);
final SpatialIndexReadOperator operator1 = new SpatialIndexReadOperator(storageManager1, BoundingBox.FULL_SPACE);
final SpatialIndexReadOperator operator2 = new SpatialIndexReadOperator(storageManager2, BoundingBox.FULL_SPACE);
final IndexedSpatialJoinOperator joinQueryProcessor1 = new IndexedSpatialJoinOperator(operator1, operator2);
final Iterator<JoinedTuple> iterator = joinQueryProcessor1.iterator();
final List<JoinedTuple> resultList = Lists.newArrayList(iterator);
joinQueryProcessor1.close();
Assert.assertEquals(1, resultList.size());
Assert.assertEquals(2, resultList.get(0).getNumberOfTuples());
Assert.assertEquals(2, resultList.get(0).getBoundingBox().getDimension());
Assert.assertEquals(new BoundingBox(4.0d, 5.0d, 4.0d, 5.0d), resultList.get(0).getBoundingBox());
}
use of org.bboxdb.storage.tuplestore.manager.TupleStoreManager 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.tuplestore.manager.TupleStoreManager in project bboxdb by jnidzwetzki.
the class TestTableCompactor method exectuteCompactAndGetReader.
/**
* Execute a compactification and return the reader for the resulting table
*
* @param reader1
* @param reader2
* @param writer
* @param major
* @return
* @throws StorageManagerException
*/
protected SSTableKeyIndexReader exectuteCompactAndGetReader(final SSTableKeyIndexReader reader1, final SSTableKeyIndexReader reader2, final boolean majorCompaction) throws StorageManagerException {
storageRegistry.deleteTable(TEST_RELATION, true);
storageRegistry.createTable(TEST_RELATION, new TupleStoreConfiguration());
final TupleStoreManager storageManager = storageRegistry.getTupleStoreManager(TEST_RELATION);
final SSTableCompactor compactor = new SSTableCompactor(storageManager, Arrays.asList(reader1, reader2));
compactor.setMajorCompaction(majorCompaction);
compactor.executeCompactation();
final List<SSTableWriter> resultWriter = compactor.getResultList();
Assert.assertEquals(1, resultWriter.size());
final SSTableWriter writer = resultWriter.get(0);
final SSTableReader reader = new SSTableReader(STORAGE_DIRECTORY, TEST_RELATION, writer.getTablenumber());
reader.init();
final SSTableKeyIndexReader ssTableIndexReader = new SSTableKeyIndexReader(reader);
ssTableIndexReader.init();
return ssTableIndexReader;
}
use of org.bboxdb.storage.tuplestore.manager.TupleStoreManager 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);
}
use of org.bboxdb.storage.tuplestore.manager.TupleStoreManager in project bboxdb by jnidzwetzki.
the class TestSampling method createDummyTable.
/**
* Create a dummy table
* @throws StorageManagerException
* @throws RejectedException
*/
private void createDummyTable() throws StorageManagerException, RejectedException {
final TupleStoreManager table = storageRegistry.createTable(TEST_RELATION, new TupleStoreConfiguration());
for (int i = 0; i < 100; i++) {
table.put(new Tuple(Integer.toString(i), new BoundingBox(1d, 2d, 1d, 20d), "".getBytes()));
table.put(new DeletedTuple(Integer.toString(i + 10000)));
}
}
Aggregations