use of org.bboxdb.network.client.future.TupleListFuture in project bboxdb by jnidzwetzki.
the class TestBBoxDBCluster method testInsertAndBoundingBoxContinousQuery.
/**
* Insert some tuples and start a bounding box query afterwards
* @throws ExecutionException
* @throws InterruptedException
* @throws BBoxDBException
*/
@Test(timeout = 60000)
public void testInsertAndBoundingBoxContinousQuery() throws InterruptedException, ExecutionException, BBoxDBException {
final BBoxDB bboxDBClient = connectToServer();
final String table = DISTRIBUTION_GROUP + "_relation9991";
// Create table
final EmptyResultFuture resultCreateTable = bboxDBClient.createTable(table, new TupleStoreConfiguration());
resultCreateTable.waitForAll();
Assert.assertFalse(resultCreateTable.isFailed());
// Execute query
final TupleListFuture result = bboxDBClient.queryBoundingBoxContinuous(table, new BoundingBox(-1d, 2d, -1d, 2d));
Assert.assertFalse(result.isFailed());
disconnect(bboxDBClient);
}
use of org.bboxdb.network.client.future.TupleListFuture in project bboxdb by jnidzwetzki.
the class DistributedSelftest method queryForExistingTuplesByKey.
/**
* Query for the stored tuples
* @param bboxdbClient
* @param random
* @throws InterruptedException
* @throws ExecutionException
* @throws BBoxDBException
*/
private static void queryForExistingTuplesByKey(final BBoxDBCluster bboxdbClient) throws InterruptedException, ExecutionException, BBoxDBException {
logger.info("Query for tuples");
for (int i = 0; i < NUMBER_OF_OPERATIONS; i++) {
final int nextInt = ThreadLocalRandom.current().nextInt(NUMBER_OF_OPERATIONS);
final String key = Integer.toString(nextInt);
final TupleListFuture queryResult = bboxdbClient.queryKey(TABLE, key);
queryResult.waitForAll();
if (queryResult.isFailed()) {
logger.error("Query {} : Got failed future, when query for: {}", i, key);
logger.error(queryResult.getAllMessages());
System.exit(-1);
}
boolean tupleFound = false;
for (final Tuple tuple : queryResult) {
if (!tuple.getKey().equals(key)) {
logger.error("Query {}: Got tuple with wrong key.", i);
logger.error("Expected: {} but got: {}", i, tuple.getKey());
System.exit(-1);
}
tupleFound = true;
}
if (tupleFound == false) {
logger.error("Query {}: Key {} not found", i, key);
System.exit(-1);
}
}
}
use of org.bboxdb.network.client.future.TupleListFuture in project bboxdb by jnidzwetzki.
the class BenchmarkKeyQueryPerformance method runBenchmark.
@Override
public void runBenchmark() throws InterruptedException, ExecutionException, BBoxDBException {
for (int i = 0; i < 100; i++) {
final long start = System.nanoTime();
final TupleListFuture result = bboxdbClient.queryKey(TABLE, Integer.toString(40));
result.waitForAll();
if (result.isFailed()) {
logger.warn("Query failed: {}", result.getAllMessages());
}
final long end = System.nanoTime();
System.out.println(i + "\t" + (end - start));
Thread.sleep(1000);
}
}
use of org.bboxdb.network.client.future.TupleListFuture in project bboxdb by jnidzwetzki.
the class BBoxDBClient method queryBoundingBox.
/* (non-Javadoc)
* @see org.bboxdb.network.client.BBoxDB#queryBoundingBox(java.lang.String, org.bboxdb.storage.entity.BoundingBox)
*/
@Override
public TupleListFuture queryBoundingBox(final String table, final BoundingBox boundingBox) {
final RoutingHeader routingHeader = RoutingHeaderHelper.getRoutingHeaderForLocalSystemReadNE(table, boundingBox, false, connection.getServerAddress());
final NetworkOperationFuture future = getQueryBoundingBoxFuture(table, boundingBox, routingHeader);
return new TupleListFuture(future, new DoNothingDuplicateResolver(), table);
}
use of org.bboxdb.network.client.future.TupleListFuture in project bboxdb by jnidzwetzki.
the class BBoxDBClient method queryVersionTime.
/* (non-Javadoc)
* @see org.bboxdb.network.client.BBoxDB#queryTime(java.lang.String, long)
*/
@Override
public TupleListFuture queryVersionTime(final String table, final long timestamp) {
final RoutingHeader routingHeader = RoutingHeaderHelper.getRoutingHeaderForLocalSystemReadNE(table, BoundingBox.FULL_SPACE, true, connection.getServerAddress());
final NetworkOperationFuture future = getVersionTimeFuture(table, timestamp, routingHeader);
return new TupleListFuture(future, new DoNothingDuplicateResolver(), table);
}
Aggregations