Search in sources :

Example 6 with EmptyResultFuture

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

the class NetworkQueryHelper method testBoundingBoxQuery.

/**
 * Test a bounding box query
 * @param bboxDBConnection
 * @return
 * @throws BBoxDBException
 * @throws InterruptedException
 */
public static TupleListFuture testBoundingBoxQuery(final BBoxDB bboxDBClient, final String distributionGroup, final boolean withTupes) throws BBoxDBException, InterruptedException {
    System.out.println("=== Running testInsertAndBoundingBoxQuery");
    final String table = distributionGroup + "_relation9991";
    // Create table
    final EmptyResultFuture resultCreateTable = bboxDBClient.createTable(table, new TupleStoreConfiguration());
    resultCreateTable.waitForAll();
    Assert.assertFalse(resultCreateTable.isFailed());
    // Inside our bbox query
    final Tuple tuple1 = new Tuple("abc", new BoundingBox(0d, 1d, 0d, 1d), "abc".getBytes());
    final Tuple tuple2 = new Tuple("def", new BoundingBox(0d, 0.5d, 0d, 0.5d), "def".getBytes());
    final Tuple tuple3 = new Tuple("geh", new BoundingBox(0.5d, 1.5d, 0.5d, 1.5d), "geh".getBytes());
    // Outside our bbox query
    final Tuple tuple4 = new Tuple("ijk", new BoundingBox(-10d, -9d, -10d, -9d), "ijk".getBytes());
    final Tuple tuple5 = new Tuple("lmn", new BoundingBox(1000d, 1001d, 1000d, 1001d), "lmn".getBytes());
    if (withTupes) {
        final EmptyResultFuture result1 = bboxDBClient.insertTuple(table, tuple1);
        final EmptyResultFuture result2 = bboxDBClient.insertTuple(table, tuple2);
        final EmptyResultFuture result3 = bboxDBClient.insertTuple(table, tuple3);
        final EmptyResultFuture result4 = bboxDBClient.insertTuple(table, tuple4);
        final EmptyResultFuture result5 = bboxDBClient.insertTuple(table, tuple5);
        result1.waitForAll();
        result2.waitForAll();
        result3.waitForAll();
        result4.waitForAll();
        result5.waitForAll();
    }
    System.out.println("=== Executing query");
    final TupleListFuture future = bboxDBClient.queryBoundingBox(table, new BoundingBox(-1d, 2d, -1d, 2d));
    future.waitForAll();
    System.out.println("=== Query DONE");
    Assert.assertFalse(future.isFailed());
    final List<Tuple> resultList = Lists.newArrayList(future.iterator());
    if (!withTupes) {
        Assert.assertEquals(0, resultList.size());
    } else {
        Assert.assertEquals(3, resultList.size());
        Assert.assertTrue(resultList.contains(tuple1));
        Assert.assertTrue(resultList.contains(tuple2));
        Assert.assertTrue(resultList.contains(tuple3));
        Assert.assertFalse(resultList.contains(tuple4));
        Assert.assertFalse(resultList.contains(tuple5));
    }
    System.out.println("=== End testInsertAndBoundingBoxQuery");
    return future;
}
Also used : TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) BoundingBox(org.bboxdb.commons.math.BoundingBox) TupleListFuture(org.bboxdb.network.client.future.TupleListFuture) JoinedTupleListFuture(org.bboxdb.network.client.future.JoinedTupleListFuture) Tuple(org.bboxdb.storage.entity.Tuple) JoinedTuple(org.bboxdb.storage.entity.JoinedTuple) EmptyResultFuture(org.bboxdb.network.client.future.EmptyResultFuture)

Example 7 with EmptyResultFuture

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

the class NetworkQueryHelper method testInsertedTimeQuery.

/**
 * Test the version time query
 * @param bboxDBConnection
 * @param distributionGroup
 * @throws InterruptedException
 * @throws BBoxDBException
 */
public static void testInsertedTimeQuery(final BBoxDB bboxDBClient, final String distributionGroup) throws InterruptedException, BBoxDBException {
    final String table = distributionGroup + "_relationit";
    final String key = "key12";
    System.out.println("== Executing testInsertedTimeQuery");
    // Create table
    final EmptyResultFuture resultCreateTable = bboxDBClient.createTable(table, new TupleStoreConfiguration());
    resultCreateTable.waitForAll();
    Assert.assertFalse(resultCreateTable.isFailed());
    final Tuple tuple = new Tuple(key, BoundingBox.FULL_SPACE, "abc".getBytes());
    final EmptyResultFuture insertResult = bboxDBClient.insertTuple(table, tuple);
    insertResult.waitForAll();
    Assert.assertFalse(insertResult.isFailed());
    Assert.assertTrue(insertResult.isDone());
    System.out.println("Query all versions");
    final TupleListFuture getResult1 = bboxDBClient.queryInsertedTime(table, 0);
    getResult1.waitForAll();
    final List<Tuple> resultList1 = Lists.newArrayList(getResult1.iterator());
    Assert.assertEquals(1, resultList1.size());
    Assert.assertEquals(tuple, resultList1.get(0));
    System.out.println("Query newest versions");
    final TupleListFuture getResult2 = bboxDBClient.queryInsertedTime(table, Long.MAX_VALUE);
    getResult2.waitForAll();
    final List<Tuple> resultList2 = Lists.newArrayList(getResult2.iterator());
    Assert.assertTrue(resultList2.isEmpty());
}
Also used : TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) TupleListFuture(org.bboxdb.network.client.future.TupleListFuture) JoinedTupleListFuture(org.bboxdb.network.client.future.JoinedTupleListFuture) Tuple(org.bboxdb.storage.entity.Tuple) JoinedTuple(org.bboxdb.storage.entity.JoinedTuple) EmptyResultFuture(org.bboxdb.network.client.future.EmptyResultFuture)

Example 8 with EmptyResultFuture

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

the class NetworkQueryHelper method testVersionTimeQuery.

/**
 * Test the version time query
 * @param bboxDBConnection
 * @param distributionGroup
 * @throws InterruptedException
 * @throws BBoxDBException
 */
public static void testVersionTimeQuery(final BBoxDB bboxDBClient, final String distributionGroup) throws InterruptedException, BBoxDBException {
    final String table = distributionGroup + "_relationqt";
    final String key = "key12";
    System.out.println("== Executing testVersionTimeQuery");
    // Create table
    final EmptyResultFuture resultCreateTable = bboxDBClient.createTable(table, new TupleStoreConfiguration());
    resultCreateTable.waitForAll();
    Assert.assertFalse(resultCreateTable.isFailed());
    final Tuple tuple = new Tuple(key, BoundingBox.FULL_SPACE, "abc".getBytes());
    final EmptyResultFuture insertResult = bboxDBClient.insertTuple(table, tuple);
    insertResult.waitForAll();
    Assert.assertFalse(insertResult.isFailed());
    Assert.assertTrue(insertResult.isDone());
    System.out.println("Query all versions");
    final TupleListFuture getResult1 = bboxDBClient.queryVersionTime(table, 0);
    getResult1.waitForAll();
    final List<Tuple> resultList1 = Lists.newArrayList(getResult1.iterator());
    Assert.assertEquals(1, resultList1.size());
    Assert.assertEquals(tuple, resultList1.get(0));
    System.out.println("Query newest versions");
    final TupleListFuture getResult2 = bboxDBClient.queryVersionTime(table, Long.MAX_VALUE);
    getResult2.waitForAll();
    final List<Tuple> resultList2 = Lists.newArrayList(getResult2.iterator());
    Assert.assertTrue(resultList2.isEmpty());
}
Also used : TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) TupleListFuture(org.bboxdb.network.client.future.TupleListFuture) JoinedTupleListFuture(org.bboxdb.network.client.future.JoinedTupleListFuture) Tuple(org.bboxdb.storage.entity.Tuple) JoinedTuple(org.bboxdb.storage.entity.JoinedTuple) EmptyResultFuture(org.bboxdb.network.client.future.EmptyResultFuture)

Example 9 with EmptyResultFuture

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

the class NetworkQueryHelper method testInsertAndDeleteTuple.

/**
 * Insert and delete tuple
 * @param bboxDBConnection
 * @throws BBoxDBException
 * @throws InterruptedException
 */
public static void testInsertAndDeleteTuple(final BBoxDB bboxDBClient, final String distributionGroup) throws BBoxDBException, InterruptedException {
    System.out.println("=== Running testInsertAndDelete");
    final String table = distributionGroup + "_relation4";
    final String key = "key12";
    // Create table
    final EmptyResultFuture resultCreateTable = bboxDBClient.createTable(table, new TupleStoreConfiguration());
    resultCreateTable.waitForAll();
    Assert.assertFalse(resultCreateTable.isFailed());
    System.out.println("Delete tuple");
    final EmptyResultFuture deleteResult1 = bboxDBClient.deleteTuple(table, key);
    deleteResult1.waitForAll();
    Assert.assertFalse(deleteResult1.isFailed());
    Assert.assertTrue(deleteResult1.isDone());
    System.out.println("Query key");
    final TupleListFuture getResult = bboxDBClient.queryKey(table, key);
    getResult.waitForAll();
    Assert.assertFalse(getResult.isFailed());
    Assert.assertTrue(getResult.isDone());
    System.out.println("Insert tuple");
    final Tuple tuple = new Tuple(key, BoundingBox.FULL_SPACE, "abc".getBytes());
    final EmptyResultFuture insertResult = bboxDBClient.insertTuple(table, tuple);
    insertResult.waitForAll();
    Assert.assertFalse(insertResult.isFailed());
    Assert.assertTrue(insertResult.isDone());
    System.out.println("Query key 2");
    final TupleListFuture getResult2 = bboxDBClient.queryKey(table, key);
    getResult2.waitForAll();
    final List<Tuple> resultList = Lists.newArrayList(getResult2.iterator());
    Assert.assertEquals(tuple, resultList.get(0));
    System.out.println("Delete tuple 2");
    final EmptyResultFuture deleteResult2 = bboxDBClient.deleteTuple(table, key, System.currentTimeMillis());
    deleteResult2.waitForAll();
    Assert.assertFalse(deleteResult2.isFailed());
    Assert.assertTrue(deleteResult2.isDone());
    System.out.println("Query key 3");
    final TupleListFuture getResult3 = bboxDBClient.queryKey(table, key);
    getResult3.waitForAll();
    Assert.assertFalse(getResult3.isFailed());
    Assert.assertTrue(getResult3.isDone());
    bboxDBClient.disconnect();
    System.out.println("=== End testInsertAndDelete");
}
Also used : TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) TupleListFuture(org.bboxdb.network.client.future.TupleListFuture) JoinedTupleListFuture(org.bboxdb.network.client.future.JoinedTupleListFuture) Tuple(org.bboxdb.storage.entity.Tuple) JoinedTuple(org.bboxdb.storage.entity.JoinedTuple) EmptyResultFuture(org.bboxdb.network.client.future.EmptyResultFuture)

Example 10 with EmptyResultFuture

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

the class NetworkQueryHelper method testBoundingBoxQueryContinous.

/**
 * Test a bounding box query
 * @param bboxDBConnection
 * @throws BBoxDBException
 * @throws InterruptedException
 */
public static void testBoundingBoxQueryContinous(final BBoxDBClient bboxDBClient, final String distributionGroup) throws BBoxDBException, InterruptedException {
    System.out.println("=== Running testBoundingBoxQueryContinous");
    final String table = distributionGroup + "_relation9991";
    // Create table
    final EmptyResultFuture resultCreateTable = bboxDBClient.createTable(table, new TupleStoreConfiguration());
    resultCreateTable.waitForAll();
    Assert.assertFalse(resultCreateTable.isFailed());
    final TupleListFuture future = bboxDBClient.queryBoundingBoxContinuous(table, new BoundingBox(-1d, 2d, -1d, 2d));
    Thread.sleep(1000);
    System.out.println("=== Tuples per page is: " + bboxDBClient.getTuplesPerPage());
    if (bboxDBClient.getTuplesPerPage() > 0) {
        for (int i = 0; i <= bboxDBClient.getTuplesPerPage(); i++) {
            bboxDBClient.insertTuple(table, new Tuple("1", new BoundingBox(0d, 1d, 0d, 1d), "".getBytes()));
        }
    }
    System.out.println("=== Wait for query result");
    future.waitForAll();
    Assert.assertTrue(future.iterator().hasNext());
    final short queryId = future.getRequestId(0);
    System.out.println("Canceling query: " + queryId);
    final EmptyResultFuture cancelResult = bboxDBClient.cancelQuery(queryId);
    cancelResult.waitForAll();
    Assert.assertTrue(cancelResult.isDone());
    Assert.assertFalse(cancelResult.isFailed());
    System.out.println("=== End testBoundingBoxQueryContinous");
}
Also used : TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) TupleListFuture(org.bboxdb.network.client.future.TupleListFuture) JoinedTupleListFuture(org.bboxdb.network.client.future.JoinedTupleListFuture) BoundingBox(org.bboxdb.commons.math.BoundingBox) Tuple(org.bboxdb.storage.entity.Tuple) JoinedTuple(org.bboxdb.storage.entity.JoinedTuple) EmptyResultFuture(org.bboxdb.network.client.future.EmptyResultFuture)

Aggregations

EmptyResultFuture (org.bboxdb.network.client.future.EmptyResultFuture)43 Tuple (org.bboxdb.storage.entity.Tuple)17 TupleStoreConfiguration (org.bboxdb.storage.entity.TupleStoreConfiguration)15 BoundingBox (org.bboxdb.commons.math.BoundingBox)11 BBoxDBException (org.bboxdb.misc.BBoxDBException)11 Test (org.junit.Test)11 TupleListFuture (org.bboxdb.network.client.future.TupleListFuture)10 DistributionGroupConfiguration (org.bboxdb.storage.entity.DistributionGroupConfiguration)9 BBoxDBClient (org.bboxdb.network.client.BBoxDBClient)8 BBoxDBConnection (org.bboxdb.network.client.BBoxDBConnection)8 JoinedTuple (org.bboxdb.storage.entity.JoinedTuple)8 JoinedTupleListFuture (org.bboxdb.network.client.future.JoinedTupleListFuture)7 NetworkOperationFuture (org.bboxdb.network.client.future.NetworkOperationFuture)5 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 BBoxDBInstance (org.bboxdb.distribution.membership.BBoxDBInstance)3 FixedSizeFutureStore (org.bboxdb.network.client.tools.FixedSizeFutureStore)3 RoutingHeader (org.bboxdb.network.routing.RoutingHeader)3 List (java.util.List)2