use of org.bboxdb.storage.tuplestore.manager.TupleStoreManager in project bboxdb by jnidzwetzki.
the class KeyClientQuery method computeTuples.
/**
* Fetch the tuples for the given key and remove the duplicates
*/
protected void computeTuples() {
try {
final String fullname = requestTable.getDistributionGroup();
final SpacePartitioner spacePartitioner = SpacePartitionerCache.getInstance().getSpacePartitionerForGroupName(fullname);
final DistributionRegionIdMapper regionIdMapper = spacePartitioner.getDistributionRegionIdMapper();
final List<TupleStoreName> localTables = regionIdMapper.getAllLocalTables(requestTable);
for (final TupleStoreName tupleStoreName : localTables) {
final TupleStoreManager storageManager = clientConnectionHandler.getStorageRegistry().getTupleStoreManager(tupleStoreName);
final List<Tuple> tuplesInTable = storageManager.get(key);
tuplesForKey.addAll(tuplesInTable);
}
removeDuplicates(localTables);
} catch (BBoxDBException | StorageManagerException e) {
logger.error("Got an exception while fetching tuples for key " + key, e);
tuplesForKey.clear();
}
}
use of org.bboxdb.storage.tuplestore.manager.TupleStoreManager in project bboxdb by jnidzwetzki.
the class StreamClientQuery method setupNewIterator.
/**
* Setup a new iterator with the next local table
*/
protected boolean setupNewIterator() {
if (activeOperatorIterator != null && !activeOperatorIterator.hasNext()) {
logger.warn("setupNewIterator() called, but old iterator is not exhaustet. Ignoring call");
return false;
}
if (getNumberOfTablesToProcess() == 0) {
logger.warn("setupNewIterator() called, but localTables are empty");
return false;
}
try {
final List<TupleStoreManager> storageManagers = new ArrayList<>();
final TupleStoreManagerRegistry storageRegistry = clientConnectionHandler.getStorageRegistry();
for (final TupleStoreName tupleStoreName : requestTables) {
final TupleStoreName sstableName = localTables.get(tupleStoreName).remove(0);
final TupleStoreManager storageManager = QueryHelper.getTupleStoreManager(storageRegistry, sstableName);
storageManagers.add(storageManager);
}
activeOperator = operatorTreeBuilder.buildOperatorTree(storageManagers);
activeOperatorIterator = activeOperator.iterator();
return true;
} catch (StorageManagerException | ZookeeperException e) {
logger.warn("Got exception while fetching tuples", e);
}
return false;
}
use of org.bboxdb.storage.tuplestore.manager.TupleStoreManager 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));
}
use of org.bboxdb.storage.tuplestore.manager.TupleStoreManager 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));
}
use of org.bboxdb.storage.tuplestore.manager.TupleStoreManager 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));
}
Aggregations