Search in sources :

Example 21 with TupleStoreManager

use of org.bboxdb.storage.tuplestore.manager.TupleStoreManager in project bboxdb by jnidzwetzki.

the class TestQueryProcessing method testBBoxQuery4.

/**
 * Simple BBox query - across multiple tables on disk - after compact
 * @throws StorageManagerException
 * @throws InterruptedException
 * @throws RejectedException
 * @throws IOException
 */
@Test(timeout = 60000)
public void testBBoxQuery4() 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 22 with TupleStoreManager

use of org.bboxdb.storage.tuplestore.manager.TupleStoreManager in project bboxdb by jnidzwetzki.

the class TestQueryProcessing method testJoin3.

/**
 * Simple Join
 * @throws StorageManagerException
 * @throws RejectedException
 */
@Test(timeout = 60000)
public void testJoin3() 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());
    final Tuple tuple3 = new Tuple("1b", new BoundingBox(1.5, 2.5, 1.5, 2.5), "value3".getBytes());
    final Tuple tuple4 = new Tuple("2b", 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 BoundingBox queryBox = new BoundingBox(3.0, 10.0, 3.0, 10.0);
    final SpatialIndexReadOperator operator1 = new SpatialIndexReadOperator(storageManager1, queryBox);
    final SpatialIndexReadOperator operator2 = new SpatialIndexReadOperator(storageManager2, queryBox);
    final IndexedSpatialJoinOperator joinQueryProcessor = new IndexedSpatialJoinOperator(operator1, operator2);
    final Iterator<JoinedTuple> iterator = joinQueryProcessor.iterator();
    final List<JoinedTuple> resultList = Lists.newArrayList(iterator);
    joinQueryProcessor.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 23 with TupleStoreManager

use of org.bboxdb.storage.tuplestore.manager.TupleStoreManager in project bboxdb by jnidzwetzki.

the class TestQueryProcessing method testDoubleJoin1.

/**
 * Simple Join
 * @throws StorageManagerException
 * @throws RejectedException
 */
@Test(timeout = 60000)
public void testDoubleJoin1() throws StorageManagerException, RejectedException {
    final TupleStoreManager storageManager1 = storageRegistry.getTupleStoreManager(TABLE_1);
    final TupleStoreManager storageManager2 = storageRegistry.getTupleStoreManager(TABLE_2);
    final TupleStoreManager storageManager3 = storageRegistry.getTupleStoreManager(TABLE_3);
    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());
    final Tuple tuple3 = new Tuple("1b", new BoundingBox(1.5, 2.5, 1.5, 2.5), "value3".getBytes());
    final Tuple tuple4 = new Tuple("2b", new BoundingBox(2.5, 5.5, 2.5, 5.5), "value4".getBytes());
    final Tuple tuple5 = new Tuple("1c", 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);
    // Table3
    storageManager3.put(tuple5);
    final SpatialIndexReadOperator operator1 = new SpatialIndexReadOperator(storageManager1, BoundingBox.FULL_SPACE);
    final SpatialIndexReadOperator operator2 = new SpatialIndexReadOperator(storageManager2, BoundingBox.FULL_SPACE);
    final SpatialIndexReadOperator operator3 = new SpatialIndexReadOperator(storageManager3, BoundingBox.FULL_SPACE);
    final IndexedSpatialJoinOperator joinQueryProcessor1 = new IndexedSpatialJoinOperator(operator1, operator2);
    final IndexedSpatialJoinOperator joinQueryProcessor2 = new IndexedSpatialJoinOperator(joinQueryProcessor1, operator3);
    final Iterator<JoinedTuple> iterator = joinQueryProcessor2.iterator();
    final List<JoinedTuple> resultList = Lists.newArrayList(iterator);
    joinQueryProcessor2.close();
    Assert.assertEquals(1, resultList.size());
    Assert.assertEquals(3, 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 24 with TupleStoreManager

use of org.bboxdb.storage.tuplestore.manager.TupleStoreManager in project bboxdb by jnidzwetzki.

the class TestQueryProcessing method testJoin1.

/**
 * Simple Join
 * @throws StorageManagerException
 * @throws RejectedException
 */
@Test(timeout = 60000)
public void testJoin1() throws StorageManagerException, RejectedException {
    final TupleStoreManager storageManager1 = storageRegistry.getTupleStoreManager(TABLE_1);
    final TupleStoreManager storageManager2 = storageRegistry.getTupleStoreManager(TABLE_2);
    final SpatialIndexReadOperator operator1 = new SpatialIndexReadOperator(storageManager1, BoundingBox.FULL_SPACE);
    final SpatialIndexReadOperator operator2 = new SpatialIndexReadOperator(storageManager2, BoundingBox.FULL_SPACE);
    final IndexedSpatialJoinOperator joinQueryProcessor = new IndexedSpatialJoinOperator(operator1, operator2);
    final Iterator<JoinedTuple> iterator = joinQueryProcessor.iterator();
    final List<JoinedTuple> resultList = Lists.newArrayList(iterator);
    joinQueryProcessor.close();
    Assert.assertEquals(0, resultList.size());
}
Also used : SpatialIndexReadOperator(org.bboxdb.storage.queryprocessor.operator.SpatialIndexReadOperator) JoinedTuple(org.bboxdb.storage.entity.JoinedTuple) IndexedSpatialJoinOperator(org.bboxdb.storage.queryprocessor.operator.IndexedSpatialJoinOperator) TupleStoreManager(org.bboxdb.storage.tuplestore.manager.TupleStoreManager) Test(org.junit.Test)

Example 25 with TupleStoreManager

use of org.bboxdb.storage.tuplestore.manager.TupleStoreManager in project bboxdb by jnidzwetzki.

the class TestStorageRegistry method testDeleteTable.

/**
 * Test delete table
 * @throws StorageManagerException
 * @throws InterruptedException
 * @throws RejectedException
 */
@Test(timeout = 60000)
public void testDeleteTable() 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();
    storageRegistry.deleteTable(RELATION_NAME, true);
    Assert.assertTrue(storageManager.isShutdownComplete());
    // Check the removal of the directory
    final BBoxDBConfiguration configuration = BBoxDBConfigurationManager.getConfiguration();
    final String storageDirectory = configuration.getStorageDirectories().get(0);
    final String pathname = SSTableHelper.getSSTableDir(storageDirectory, RELATION_NAME);
    final File directory = new File(pathname);
    System.out.println("Check for " + directory);
    Assert.assertFalse(directory.exists());
}
Also used : TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) BBoxDBConfiguration(org.bboxdb.misc.BBoxDBConfiguration) File(java.io.File) Tuple(org.bboxdb.storage.entity.Tuple) TupleStoreManager(org.bboxdb.storage.tuplestore.manager.TupleStoreManager) Test(org.junit.Test)

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