Search in sources :

Example 6 with TupleStoreManager

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());
}
Also used : SpatialIndexReadOperator(org.bboxdb.storage.queryprocessor.operator.SpatialIndexReadOperator) BoundingBox(org.bboxdb.commons.math.BoundingBox) JoinedTuple(org.bboxdb.storage.entity.JoinedTuple) IndexedSpatialJoinOperator(org.bboxdb.storage.queryprocessor.operator.IndexedSpatialJoinOperator) Tuple(org.bboxdb.storage.entity.Tuple) JoinedTuple(org.bboxdb.storage.entity.JoinedTuple) TupleStoreManager(org.bboxdb.storage.tuplestore.manager.TupleStoreManager) Test(org.junit.Test)

Example 7 with TupleStoreManager

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);
}
Also used : TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) Tuple(org.bboxdb.storage.entity.Tuple) TupleStoreManager(org.bboxdb.storage.tuplestore.manager.TupleStoreManager) Test(org.junit.Test)

Example 8 with TupleStoreManager

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;
}
Also used : SSTableReader(org.bboxdb.storage.sstable.reader.SSTableReader) SSTableKeyIndexReader(org.bboxdb.storage.sstable.reader.SSTableKeyIndexReader) TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) SSTableWriter(org.bboxdb.storage.sstable.SSTableWriter) TupleStoreManager(org.bboxdb.storage.tuplestore.manager.TupleStoreManager) SSTableCompactor(org.bboxdb.storage.sstable.compact.SSTableCompactor)

Example 9 with TupleStoreManager

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);
}
Also used : Arrays(java.util.Arrays) SSTableWriter(org.bboxdb.storage.sstable.SSTableWriter) SSTableReader(org.bboxdb.storage.sstable.reader.SSTableReader) BeforeClass(org.junit.BeforeClass) RejectedException(org.bboxdb.commons.RejectedException) Tuple(org.bboxdb.storage.entity.Tuple) SSTableServiceRunnable(org.bboxdb.storage.sstable.compact.SSTableServiceRunnable) SSTableHelper(org.bboxdb.storage.sstable.SSTableHelper) SSTableFacade(org.bboxdb.storage.sstable.reader.SSTableFacade) BoundingBox(org.bboxdb.commons.math.BoundingBox) ArrayList(java.util.ArrayList) ReadOnlyTupleStore(org.bboxdb.storage.tuplestore.ReadOnlyTupleStore) TupleStoreManager(org.bboxdb.storage.tuplestore.manager.TupleStoreManager) Lists(com.google.common.collect.Lists) SSTableCompactor(org.bboxdb.storage.sstable.compact.SSTableCompactor) SSTableKeyIndexReader(org.bboxdb.storage.sstable.reader.SSTableKeyIndexReader) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) BBoxDBConfigurationManager(org.bboxdb.misc.BBoxDBConfigurationManager) DiskStorage(org.bboxdb.storage.tuplestore.DiskStorage) Before(org.junit.Before) AfterClass(org.junit.AfterClass) Iterator(java.util.Iterator) Test(org.junit.Test) Collectors(java.util.stream.Collectors) File(java.io.File) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) TupleStoreManagerRegistry(org.bboxdb.storage.tuplestore.manager.TupleStoreManagerRegistry) List(java.util.List) BBoxDBException(org.bboxdb.misc.BBoxDBException) TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) Assert(org.junit.Assert) Collections(java.util.Collections) TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) SSTableFacade(org.bboxdb.storage.sstable.reader.SSTableFacade) SSTableServiceRunnable(org.bboxdb.storage.sstable.compact.SSTableServiceRunnable) ReadOnlyTupleStore(org.bboxdb.storage.tuplestore.ReadOnlyTupleStore) DiskStorage(org.bboxdb.storage.tuplestore.DiskStorage) Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) TupleStoreManager(org.bboxdb.storage.tuplestore.manager.TupleStoreManager) Test(org.junit.Test)

Example 10 with TupleStoreManager

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)));
    }
}
Also used : DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) BoundingBox(org.bboxdb.commons.math.BoundingBox) Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) TupleStoreManager(org.bboxdb.storage.tuplestore.manager.TupleStoreManager)

Aggregations

TupleStoreManager (org.bboxdb.storage.tuplestore.manager.TupleStoreManager)32 Tuple (org.bboxdb.storage.entity.Tuple)17 TupleStoreName (org.bboxdb.storage.entity.TupleStoreName)17 Test (org.junit.Test)12 TupleStoreConfiguration (org.bboxdb.storage.entity.TupleStoreConfiguration)11 BoundingBox (org.bboxdb.commons.math.BoundingBox)10 BBoxDBException (org.bboxdb.misc.BBoxDBException)10 JoinedTuple (org.bboxdb.storage.entity.JoinedTuple)10 TupleStoreManagerRegistry (org.bboxdb.storage.tuplestore.manager.TupleStoreManagerRegistry)9 StorageManagerException (org.bboxdb.storage.StorageManagerException)8 IndexedSpatialJoinOperator (org.bboxdb.storage.queryprocessor.operator.IndexedSpatialJoinOperator)8 SpatialIndexReadOperator (org.bboxdb.storage.queryprocessor.operator.SpatialIndexReadOperator)8 ArrayList (java.util.ArrayList)7 List (java.util.List)6 RejectedException (org.bboxdb.commons.RejectedException)6 Lists (com.google.common.collect.Lists)5 Iterator (java.util.Iterator)5 Collectors (java.util.stream.Collectors)5 AfterClass (org.junit.AfterClass)5 IOException (java.io.IOException)4