Search in sources :

Example 1 with RejectedException

use of org.bboxdb.commons.RejectedException in project bboxdb by jnidzwetzki.

the class TestQueryProcessing method testBBoxQuery3.

/**
 * Simple BBox query - across multiple tables on disk
 * @throws StorageManagerException
 * @throws InterruptedException
 * @throws RejectedException
 * @throws IOException
 */
@Test(timeout = 60000)
public void testBBoxQuery3() throws StorageManagerException, InterruptedException, RejectedException, IOException {
    final TupleStoreManager storageManager = storageRegistry.getTupleStoreManager(TABLE_1);
    final Tuple tuple1 = new Tuple("1", new BoundingBox(1.0, 2.0, 1.0, 2.0), "value".getBytes());
    final Tuple tuple2 = new Tuple("2", new BoundingBox(1.5, 2.5, 1.5, 2.5), "value2".getBytes());
    final Tuple tuple3 = new Tuple("1", new BoundingBox(1.0, 2.0, 1.0, 2.0), "value1".getBytes());
    storageManager.put(tuple1);
    storageManager.flush();
    storageManager.put(tuple2);
    storageManager.flush();
    storageManager.put(tuple3);
    storageManager.flush();
    final BoundingBox queryBoundingBox = new BoundingBox(0.0, 5.0, 0.0, 5.0);
    final Operator spatialIndexReadOperator = new FullTablescanOperator(storageManager);
    final Operator queryPlan = new BoundingBoxSelectOperator(queryBoundingBox, spatialIndexReadOperator);
    final Iterator<JoinedTuple> iterator = queryPlan.iterator();
    final List<JoinedTuple> resultList = Lists.newArrayList(iterator);
    final List<Tuple> resultTupleList = resultList.stream().map(t -> t.convertToSingleTupleIfPossible()).collect(Collectors.toList());
    queryPlan.close();
    Assert.assertEquals(2, resultList.size());
    Assert.assertFalse(resultTupleList.contains(tuple1));
    Assert.assertTrue(resultTupleList.contains(tuple2));
    Assert.assertTrue(resultTupleList.contains(tuple3));
}
Also used : FullTablescanOperator(org.bboxdb.storage.queryprocessor.operator.FullTablescanOperator) IndexedSpatialJoinOperator(org.bboxdb.storage.queryprocessor.operator.IndexedSpatialJoinOperator) Operator(org.bboxdb.storage.queryprocessor.operator.Operator) SpatialIndexReadOperator(org.bboxdb.storage.queryprocessor.operator.SpatialIndexReadOperator) BoundingBoxSelectOperator(org.bboxdb.storage.queryprocessor.operator.BoundingBoxSelectOperator) AfterClass(org.junit.AfterClass) Iterator(java.util.Iterator) BeforeClass(org.junit.BeforeClass) RejectedException(org.bboxdb.commons.RejectedException) FullTablescanOperator(org.bboxdb.storage.queryprocessor.operator.FullTablescanOperator) Tuple(org.bboxdb.storage.entity.Tuple) IOException(java.io.IOException) Test(org.junit.Test) Collectors(java.util.stream.Collectors) BoundingBox(org.bboxdb.commons.math.BoundingBox) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) TupleStoreManagerRegistry(org.bboxdb.storage.tuplestore.manager.TupleStoreManagerRegistry) List(java.util.List) JoinedTuple(org.bboxdb.storage.entity.JoinedTuple) TupleStoreManager(org.bboxdb.storage.tuplestore.manager.TupleStoreManager) IndexedSpatialJoinOperator(org.bboxdb.storage.queryprocessor.operator.IndexedSpatialJoinOperator) Lists(com.google.common.collect.Lists) Operator(org.bboxdb.storage.queryprocessor.operator.Operator) BBoxDBException(org.bboxdb.misc.BBoxDBException) TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) Assert(org.junit.Assert) SpatialIndexReadOperator(org.bboxdb.storage.queryprocessor.operator.SpatialIndexReadOperator) BoundingBoxSelectOperator(org.bboxdb.storage.queryprocessor.operator.BoundingBoxSelectOperator) Before(org.junit.Before) BoundingBoxSelectOperator(org.bboxdb.storage.queryprocessor.operator.BoundingBoxSelectOperator) BoundingBox(org.bboxdb.commons.math.BoundingBox) FullTablescanOperator(org.bboxdb.storage.queryprocessor.operator.FullTablescanOperator) JoinedTuple(org.bboxdb.storage.entity.JoinedTuple) Tuple(org.bboxdb.storage.entity.Tuple) JoinedTuple(org.bboxdb.storage.entity.JoinedTuple) TupleStoreManager(org.bboxdb.storage.tuplestore.manager.TupleStoreManager) Test(org.junit.Test)

Example 2 with RejectedException

use of org.bboxdb.commons.RejectedException in project bboxdb by jnidzwetzki.

the class TestQueryProcessing method testBBoxQuery1.

/**
 * Simple BBox query
 * @throws StorageManagerException
 * @throws RejectedException
 * @throws IOException
 */
@Test(timeout = 60000)
public void testBBoxQuery1() throws StorageManagerException, RejectedException, IOException {
    final TupleStoreManager storageManager = storageRegistry.getTupleStoreManager(TABLE_1);
    final Tuple tuple1 = new Tuple("1", new BoundingBox(1.0, 2.0, 1.0, 2.0), "value".getBytes());
    final Tuple tuple2 = new Tuple("2", new BoundingBox(1.5, 2.5, 1.5, 2.5), "value2".getBytes());
    final Tuple tuple3 = new Tuple("1", new BoundingBox(1.0, 2.0, 1.0, 2.0), "value1".getBytes());
    storageManager.put(tuple1);
    storageManager.put(tuple2);
    storageManager.put(tuple3);
    final BoundingBox queryBoundingBox = new BoundingBox(0.0, 5.0, 0.0, 5.0);
    final Operator spatialIndexReadOperator = new FullTablescanOperator(storageManager);
    final Operator queryPlan = new BoundingBoxSelectOperator(queryBoundingBox, spatialIndexReadOperator);
    final Iterator<JoinedTuple> iterator = queryPlan.iterator();
    final List<JoinedTuple> resultList = Lists.newArrayList(iterator);
    final List<Tuple> resultTupleList = resultList.stream().map(t -> t.convertToSingleTupleIfPossible()).collect(Collectors.toList());
    queryPlan.close();
    Assert.assertEquals(2, resultList.size());
    Assert.assertFalse(resultTupleList.contains(tuple1));
    Assert.assertTrue(resultTupleList.contains(tuple2));
    Assert.assertTrue(resultTupleList.contains(tuple3));
    // Reopen
    final Iterator<JoinedTuple> iterator2 = queryPlan.iterator();
    final List<JoinedTuple> resultList2 = Lists.newArrayList(iterator2);
    final List<Tuple> resultTupleList2 = resultList2.stream().map(t -> t.convertToSingleTupleIfPossible()).collect(Collectors.toList());
    queryPlan.close();
    Assert.assertEquals(2, resultList2.size());
    Assert.assertFalse(resultTupleList2.contains(tuple1));
    Assert.assertTrue(resultTupleList2.contains(tuple2));
    Assert.assertTrue(resultTupleList2.contains(tuple3));
}
Also used : FullTablescanOperator(org.bboxdb.storage.queryprocessor.operator.FullTablescanOperator) IndexedSpatialJoinOperator(org.bboxdb.storage.queryprocessor.operator.IndexedSpatialJoinOperator) Operator(org.bboxdb.storage.queryprocessor.operator.Operator) SpatialIndexReadOperator(org.bboxdb.storage.queryprocessor.operator.SpatialIndexReadOperator) BoundingBoxSelectOperator(org.bboxdb.storage.queryprocessor.operator.BoundingBoxSelectOperator) AfterClass(org.junit.AfterClass) Iterator(java.util.Iterator) BeforeClass(org.junit.BeforeClass) RejectedException(org.bboxdb.commons.RejectedException) FullTablescanOperator(org.bboxdb.storage.queryprocessor.operator.FullTablescanOperator) Tuple(org.bboxdb.storage.entity.Tuple) IOException(java.io.IOException) Test(org.junit.Test) Collectors(java.util.stream.Collectors) BoundingBox(org.bboxdb.commons.math.BoundingBox) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) TupleStoreManagerRegistry(org.bboxdb.storage.tuplestore.manager.TupleStoreManagerRegistry) List(java.util.List) JoinedTuple(org.bboxdb.storage.entity.JoinedTuple) TupleStoreManager(org.bboxdb.storage.tuplestore.manager.TupleStoreManager) IndexedSpatialJoinOperator(org.bboxdb.storage.queryprocessor.operator.IndexedSpatialJoinOperator) Lists(com.google.common.collect.Lists) Operator(org.bboxdb.storage.queryprocessor.operator.Operator) BBoxDBException(org.bboxdb.misc.BBoxDBException) TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) Assert(org.junit.Assert) SpatialIndexReadOperator(org.bboxdb.storage.queryprocessor.operator.SpatialIndexReadOperator) BoundingBoxSelectOperator(org.bboxdb.storage.queryprocessor.operator.BoundingBoxSelectOperator) Before(org.junit.Before) BoundingBoxSelectOperator(org.bboxdb.storage.queryprocessor.operator.BoundingBoxSelectOperator) BoundingBox(org.bboxdb.commons.math.BoundingBox) FullTablescanOperator(org.bboxdb.storage.queryprocessor.operator.FullTablescanOperator) JoinedTuple(org.bboxdb.storage.entity.JoinedTuple) Tuple(org.bboxdb.storage.entity.Tuple) JoinedTuple(org.bboxdb.storage.entity.JoinedTuple) TupleStoreManager(org.bboxdb.storage.tuplestore.manager.TupleStoreManager) Test(org.junit.Test)

Example 3 with RejectedException

use of org.bboxdb.commons.RejectedException in project bboxdb by jnidzwetzki.

the class TestQueryProcessing method testBBoxQuery2.

/**
 * Simple BBox query - across multiple tables
 * @throws StorageManagerException
 * @throws RejectedException
 * @throws IOException
 */
@Test(timeout = 60000)
public void testBBoxQuery2() throws StorageManagerException, RejectedException, IOException {
    final TupleStoreManager storageManager = storageRegistry.getTupleStoreManager(TABLE_1);
    final Tuple tuple1 = new Tuple("1", new BoundingBox(1.0, 2.0, 1.0, 2.0), "value".getBytes());
    final Tuple tuple2 = new Tuple("2", new BoundingBox(1.5, 2.5, 1.5, 2.5), "value2".getBytes());
    final Tuple tuple3 = new Tuple("1", new BoundingBox(1.0, 2.0, 1.0, 2.0), "value1".getBytes());
    storageManager.put(tuple1);
    storageManager.initNewMemtable();
    storageManager.put(tuple2);
    storageManager.initNewMemtable();
    storageManager.put(tuple3);
    storageManager.initNewMemtable();
    final BoundingBox queryBoundingBox = new BoundingBox(0.0, 5.0, 0.0, 5.0);
    final Operator spatialIndexReadOperator = new FullTablescanOperator(storageManager);
    final Operator queryPlan = new BoundingBoxSelectOperator(queryBoundingBox, spatialIndexReadOperator);
    final Iterator<JoinedTuple> iterator = queryPlan.iterator();
    final List<JoinedTuple> resultList = Lists.newArrayList(iterator);
    final List<Tuple> resultTupleList = resultList.stream().map(t -> t.convertToSingleTupleIfPossible()).collect(Collectors.toList());
    queryPlan.close();
    Assert.assertEquals(2, resultList.size());
    Assert.assertFalse(resultTupleList.contains(tuple1));
    Assert.assertTrue(resultTupleList.contains(tuple2));
    Assert.assertTrue(resultTupleList.contains(tuple3));
}
Also used : FullTablescanOperator(org.bboxdb.storage.queryprocessor.operator.FullTablescanOperator) IndexedSpatialJoinOperator(org.bboxdb.storage.queryprocessor.operator.IndexedSpatialJoinOperator) Operator(org.bboxdb.storage.queryprocessor.operator.Operator) SpatialIndexReadOperator(org.bboxdb.storage.queryprocessor.operator.SpatialIndexReadOperator) BoundingBoxSelectOperator(org.bboxdb.storage.queryprocessor.operator.BoundingBoxSelectOperator) AfterClass(org.junit.AfterClass) Iterator(java.util.Iterator) BeforeClass(org.junit.BeforeClass) RejectedException(org.bboxdb.commons.RejectedException) FullTablescanOperator(org.bboxdb.storage.queryprocessor.operator.FullTablescanOperator) Tuple(org.bboxdb.storage.entity.Tuple) IOException(java.io.IOException) Test(org.junit.Test) Collectors(java.util.stream.Collectors) BoundingBox(org.bboxdb.commons.math.BoundingBox) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) TupleStoreManagerRegistry(org.bboxdb.storage.tuplestore.manager.TupleStoreManagerRegistry) List(java.util.List) JoinedTuple(org.bboxdb.storage.entity.JoinedTuple) TupleStoreManager(org.bboxdb.storage.tuplestore.manager.TupleStoreManager) IndexedSpatialJoinOperator(org.bboxdb.storage.queryprocessor.operator.IndexedSpatialJoinOperator) Lists(com.google.common.collect.Lists) Operator(org.bboxdb.storage.queryprocessor.operator.Operator) BBoxDBException(org.bboxdb.misc.BBoxDBException) TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) Assert(org.junit.Assert) SpatialIndexReadOperator(org.bboxdb.storage.queryprocessor.operator.SpatialIndexReadOperator) BoundingBoxSelectOperator(org.bboxdb.storage.queryprocessor.operator.BoundingBoxSelectOperator) Before(org.junit.Before) BoundingBoxSelectOperator(org.bboxdb.storage.queryprocessor.operator.BoundingBoxSelectOperator) BoundingBox(org.bboxdb.commons.math.BoundingBox) FullTablescanOperator(org.bboxdb.storage.queryprocessor.operator.FullTablescanOperator) JoinedTuple(org.bboxdb.storage.entity.JoinedTuple) Tuple(org.bboxdb.storage.entity.Tuple) JoinedTuple(org.bboxdb.storage.entity.JoinedTuple) TupleStoreManager(org.bboxdb.storage.tuplestore.manager.TupleStoreManager) Test(org.junit.Test)

Example 4 with RejectedException

use of org.bboxdb.commons.RejectedException 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 5 with RejectedException

use of org.bboxdb.commons.RejectedException in project bboxdb by jnidzwetzki.

the class SSTableServiceRunnable method registerNewFacadeAndDeleteOldInstances.

/**
 * Register a new sstable facade and delete the old ones
 * @param oldFacades
 * @param directory
 * @param name
 * @param tablenumber
 * @throws StorageManagerException
 */
private void registerNewFacadeAndDeleteOldInstances(final TupleStoreManager sstableManager, final List<SSTableFacade> oldFacades, final List<SSTableWriter> newTableWriter) throws StorageManagerException {
    final List<SSTableFacade> newFacades = new ArrayList<>();
    // Open new facades
    openFacades(newTableWriter, newFacades);
    // Manager has switched to read only
    if (sstableManager.getSstableManagerState() == TupleStoreManagerState.READ_ONLY) {
        logger.info("Manager is in read only mode, cancel compact run");
        handleCompactException(newFacades);
        return;
    }
    try {
        for (final SSTableFacade facade : newFacades) {
            facade.init();
        }
        // Switch facades in registry
        sstableManager.replaceCompactedSStables(newFacades, oldFacades);
        // Schedule facades for deletion
        oldFacades.forEach(f -> f.deleteOnClose());
    } catch (BBoxDBException | RejectedException e) {
        handleCompactException(newFacades);
        throw new StorageManagerException(e);
    } catch (InterruptedException e) {
        handleCompactException(newFacades);
        Thread.currentThread().interrupt();
        throw new StorageManagerException(e);
    }
}
Also used : RejectedException(org.bboxdb.commons.RejectedException) ArrayList(java.util.ArrayList) SSTableFacade(org.bboxdb.storage.sstable.reader.SSTableFacade) StorageManagerException(org.bboxdb.storage.StorageManagerException) BBoxDBException(org.bboxdb.misc.BBoxDBException)

Aggregations

RejectedException (org.bboxdb.commons.RejectedException)10 BBoxDBException (org.bboxdb.misc.BBoxDBException)7 TupleStoreName (org.bboxdb.storage.entity.TupleStoreName)7 TupleStoreManager (org.bboxdb.storage.tuplestore.manager.TupleStoreManager)6 Test (org.junit.Test)6 Lists (com.google.common.collect.Lists)5 Iterator (java.util.Iterator)5 List (java.util.List)5 Collectors (java.util.stream.Collectors)5 BoundingBox (org.bboxdb.commons.math.BoundingBox)5 Tuple (org.bboxdb.storage.entity.Tuple)5 TupleStoreConfiguration (org.bboxdb.storage.entity.TupleStoreConfiguration)5 TupleStoreManagerRegistry (org.bboxdb.storage.tuplestore.manager.TupleStoreManagerRegistry)5 AfterClass (org.junit.AfterClass)5 Assert (org.junit.Assert)5 Before (org.junit.Before)5 BeforeClass (org.junit.BeforeClass)5 IOException (java.io.IOException)4 JoinedTuple (org.bboxdb.storage.entity.JoinedTuple)4 BoundingBoxSelectOperator (org.bboxdb.storage.queryprocessor.operator.BoundingBoxSelectOperator)4