Search in sources :

Example 11 with TupleListFuture

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);
}
Also used : BBoxDB(org.bboxdb.network.client.BBoxDB) TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) TupleListFuture(org.bboxdb.network.client.future.TupleListFuture) BoundingBox(org.bboxdb.commons.math.BoundingBox) EmptyResultFuture(org.bboxdb.network.client.future.EmptyResultFuture) Test(org.junit.Test)

Example 12 with TupleListFuture

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);
        }
    }
}
Also used : TupleListFuture(org.bboxdb.network.client.future.TupleListFuture) Tuple(org.bboxdb.storage.entity.Tuple)

Example 13 with TupleListFuture

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);
    }
}
Also used : TupleListFuture(org.bboxdb.network.client.future.TupleListFuture)

Example 14 with TupleListFuture

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);
}
Also used : TupleListFuture(org.bboxdb.network.client.future.TupleListFuture) JoinedTupleListFuture(org.bboxdb.network.client.future.JoinedTupleListFuture) NetworkOperationFuture(org.bboxdb.network.client.future.NetworkOperationFuture) RoutingHeader(org.bboxdb.network.routing.RoutingHeader) DoNothingDuplicateResolver(org.bboxdb.storage.sstable.duplicateresolver.DoNothingDuplicateResolver)

Example 15 with TupleListFuture

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);
}
Also used : TupleListFuture(org.bboxdb.network.client.future.TupleListFuture) JoinedTupleListFuture(org.bboxdb.network.client.future.JoinedTupleListFuture) NetworkOperationFuture(org.bboxdb.network.client.future.NetworkOperationFuture) RoutingHeader(org.bboxdb.network.routing.RoutingHeader) DoNothingDuplicateResolver(org.bboxdb.storage.sstable.duplicateresolver.DoNothingDuplicateResolver)

Aggregations

TupleListFuture (org.bboxdb.network.client.future.TupleListFuture)32 JoinedTupleListFuture (org.bboxdb.network.client.future.JoinedTupleListFuture)18 Tuple (org.bboxdb.storage.entity.Tuple)18 BoundingBox (org.bboxdb.commons.math.BoundingBox)11 NetworkOperationFuture (org.bboxdb.network.client.future.NetworkOperationFuture)11 EmptyResultFuture (org.bboxdb.network.client.future.EmptyResultFuture)10 RoutingHeader (org.bboxdb.network.routing.RoutingHeader)10 TupleStoreConfiguration (org.bboxdb.storage.entity.TupleStoreConfiguration)10 DoNothingDuplicateResolver (org.bboxdb.storage.sstable.duplicateresolver.DoNothingDuplicateResolver)9 JoinedTuple (org.bboxdb.storage.entity.JoinedTuple)8 ArrayList (java.util.ArrayList)6 BBoxDBInstance (org.bboxdb.distribution.membership.BBoxDBInstance)6 List (java.util.List)5 DistributionRegion (org.bboxdb.distribution.region.DistributionRegion)5 BBoxDBException (org.bboxdb.misc.BBoxDBException)5 BBoxDBConnection (org.bboxdb.network.client.BBoxDBConnection)5 RoutingHop (org.bboxdb.network.routing.RoutingHop)5 Test (org.junit.Test)5 BBoxDBClient (org.bboxdb.network.client.BBoxDBClient)4 BBoxDB (org.bboxdb.network.client.BBoxDB)2