Search in sources :

Example 26 with TupleListFuture

use of org.bboxdb.network.client.future.TupleListFuture in project bboxdb by jnidzwetzki.

the class DistributedSelftest method queryForNonExistingTuples.

/**
 * Query for non existing tuples and exit, as soon as a tuple is found
 * @param bboxdbClient
 * @throws BBoxDBException
 * @throws InterruptedException
 * @throws ExecutionException
 */
private static void queryForNonExistingTuples(final BBoxDBCluster bboxdbClient) throws BBoxDBException, InterruptedException, ExecutionException {
    logger.info("Query for non existing tuples");
    for (int i = 0; i < NUMBER_OF_OPERATIONS; i++) {
        final String key = Integer.toString(i);
        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);
        }
        for (final Tuple tuple : queryResult) {
            logger.error("Found a tuple which should not exist: {} / {}", i, tuple);
            System.exit(-1);
        }
    }
}
Also used : TupleListFuture(org.bboxdb.network.client.future.TupleListFuture) Tuple(org.bboxdb.storage.entity.Tuple)

Example 27 with TupleListFuture

use of org.bboxdb.network.client.future.TupleListFuture in project bboxdb by jnidzwetzki.

the class CLI method actionExecuteQuery.

/**
 * Execute the given query
 * @param line
 */
protected void actionExecuteQuery(final CommandLine line) {
    if (!line.hasOption(CLIParameter.TABLE)) {
        System.err.println("Query should be performed, but no table was specified");
        printHelpAndExit();
    }
    try {
        final TupleListFuture resultFuture = buildQueryFuture(line);
        if (resultFuture == null) {
            System.err.println("Unable to get query");
            System.exit(-1);
        }
        resultFuture.waitForAll();
        if (resultFuture.isFailed()) {
            System.err.println("Unable to execute query: " + resultFuture.getAllMessages());
            System.exit(-1);
        }
        for (final Tuple tuple : resultFuture) {
            printTuple(tuple);
        }
        System.out.println("Query done");
    } catch (BBoxDBException e) {
        System.err.println("Got an exception while performing query: " + e);
        System.exit(-1);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        return;
    }
}
Also used : TupleListFuture(org.bboxdb.network.client.future.TupleListFuture) JoinedTupleListFuture(org.bboxdb.network.client.future.JoinedTupleListFuture) BBoxDBException(org.bboxdb.misc.BBoxDBException) Tuple(org.bboxdb.storage.entity.Tuple) JoinedTuple(org.bboxdb.storage.entity.JoinedTuple)

Example 28 with TupleListFuture

use of org.bboxdb.network.client.future.TupleListFuture in project bboxdb by jnidzwetzki.

the class CLI method actionExecuteContinuousQuery.

/**
 * Execute a continuous bounding box query
 * @param line
 */
protected void actionExecuteContinuousQuery(final CommandLine line) {
    if (!line.hasOption(CLIParameter.TABLE)) {
        System.err.println("Query should be performed, but no table was specified");
        printHelpAndExit();
    }
    try {
        System.out.println("Executing continuous bounding box query...");
        final String table = line.getOptionValue(CLIParameter.TABLE);
        if (!line.hasOption(CLIParameter.BOUNDING_BOX)) {
            System.err.println("Bounding box is not given");
            System.exit(-1);
        }
        final BoundingBox boundingBox = getBoundingBoxFromArgs(line);
        final TupleListFuture resultFuture = bboxDbConnection.queryBoundingBoxContinuous(table, boundingBox);
        if (resultFuture == null) {
            System.err.println("Unable to get query");
            System.exit(-1);
        }
        resultFuture.waitForAll();
        if (resultFuture.isFailed()) {
            System.err.println("Unable to execute query: " + resultFuture.getAllMessages());
            System.exit(-1);
        }
        for (final Tuple tuple : resultFuture) {
            printTuple(tuple);
        }
        System.out.println("Query done");
    } catch (BBoxDBException e) {
        System.err.println("Got an exception while performing query: " + e);
        System.exit(-1);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        return;
    }
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) TupleListFuture(org.bboxdb.network.client.future.TupleListFuture) JoinedTupleListFuture(org.bboxdb.network.client.future.JoinedTupleListFuture) BBoxDBException(org.bboxdb.misc.BBoxDBException) Tuple(org.bboxdb.storage.entity.Tuple) JoinedTuple(org.bboxdb.storage.entity.JoinedTuple)

Example 29 with TupleListFuture

use of org.bboxdb.network.client.future.TupleListFuture in project bboxdb by jnidzwetzki.

the class TestTupleListFuture method testRejectedExeption.

@Test(expected = RejectedException.class)
public void testRejectedExeption() throws InterruptedException, RejectedException {
    final TupleListFutureStore tupleListFutureStore = new TupleListFutureStore();
    tupleListFutureStore.shutdown();
    final BBoxDBConnection connection = Mockito.mock(BBoxDBConnection.class);
    final Supplier<NetworkRequestPackage> supplier = () -> (null);
    final NetworkOperationFuture networkOperationFuture = new NetworkOperationFuture(connection, supplier);
    tupleListFutureStore.put(new TupleListFuture(networkOperationFuture, new DoNothingDuplicateResolver(), ""));
}
Also used : NetworkRequestPackage(org.bboxdb.network.packages.NetworkRequestPackage) TupleListFuture(org.bboxdb.network.client.future.TupleListFuture) NetworkOperationFuture(org.bboxdb.network.client.future.NetworkOperationFuture) DoNothingDuplicateResolver(org.bboxdb.storage.sstable.duplicateresolver.DoNothingDuplicateResolver) BBoxDBConnection(org.bboxdb.network.client.BBoxDBConnection) TupleListFutureStore(org.bboxdb.network.client.tools.TupleListFutureStore) Test(org.junit.Test)

Example 30 with TupleListFuture

use of org.bboxdb.network.client.future.TupleListFuture in project bboxdb by jnidzwetzki.

the class TestBoundingBoxQuery method executeQueries.

/**
 * Execute the bounding box queries
 * @param maxDimensionSize
 * @param boundingBox
 * @param bboxDBConnection
 * @throws BBoxDBException
 * @throws InterruptedException
 * @throws RejectedException
 */
protected void executeQueries(final double maxDimensionSize, final BoundingBox boundingBox, final BBoxDB bboxDBConnection) throws BBoxDBException, InterruptedException, RejectedException {
    for (int i = 0; i < QUERIES; i++) {
        final List<DoubleInterval> bboxIntervals = new ArrayList<>();
        // Determine query bounding box
        for (int dimension = 0; dimension < boundingBox.getDimension(); dimension++) {
            final double dataExtent = boundingBox.getExtent(dimension);
            final double bboxOffset = (random.nextDouble() % 1) * dataExtent;
            final double coordinateLow = boundingBox.getCoordinateLow(dimension);
            final double coordinateHigh = boundingBox.getCoordinateHigh(dimension);
            final double bboxStartPos = coordinateLow + bboxOffset;
            final double bboxEndPos = Math.min(bboxStartPos + dataExtent * maxDimensionSize, coordinateHigh);
            final DoubleInterval doubleInterval = new DoubleInterval(bboxStartPos, bboxEndPos);
            bboxIntervals.add(doubleInterval);
        }
        final BoundingBox queryBox = new BoundingBox(bboxIntervals);
        final TupleListFuture future = bboxDBConnection.queryBoundingBox(tablename, queryBox);
        pendingFutures.put(future);
    }
    pendingFutures.waitForCompletion();
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) TupleListFuture(org.bboxdb.network.client.future.TupleListFuture) ArrayList(java.util.ArrayList) DoubleInterval(org.bboxdb.commons.math.DoubleInterval)

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