Search in sources :

Example 21 with JoinedTuple

use of org.bboxdb.storage.entity.JoinedTuple in project bboxdb by jnidzwetzki.

the class CLI method actionExecuteJoin.

/**
 * Execute the given query
 * @param line
 */
protected void actionExecuteJoin(final CommandLine line) {
    if (!line.hasOption(CLIParameter.TABLE)) {
        System.err.println("Query should be performed, but no table was specified");
        printHelpAndExit();
    }
    if (!line.hasOption(CLIParameter.BOUNDING_BOX)) {
        System.err.println("Bounding box is not given");
        System.exit(-1);
    }
    try {
        final String tables = line.getOptionValue(CLIParameter.TABLE);
        final List<String> tableList = Arrays.asList(tables.split(":"));
        System.out.println("Executing join query...");
        final BoundingBox boundingBox = getBoundingBoxFromArgs(line);
        final JoinedTupleListFuture resultFuture = bboxDbConnection.queryJoin(tableList, 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 JoinedTuple tuple : resultFuture) {
            printJoinedTuple(tuple);
        }
        System.out.println("Join 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 : JoinedTupleListFuture(org.bboxdb.network.client.future.JoinedTupleListFuture) BoundingBox(org.bboxdb.commons.math.BoundingBox) JoinedTuple(org.bboxdb.storage.entity.JoinedTuple) BBoxDBException(org.bboxdb.misc.BBoxDBException)

Example 22 with JoinedTuple

use of org.bboxdb.storage.entity.JoinedTuple in project bboxdb by jnidzwetzki.

the class TestTupleHelper method testJoinedTupleMisc.

/**
 * Test misc function of the joined tuple
 */
@Test(timeout = 60000)
public void testJoinedTupleMisc() {
    final Tuple tuple1 = new Tuple("abc", new BoundingBox(1d, 2d), "".getBytes());
    final Tuple tuple2 = new Tuple("def", new BoundingBox(1d, 2d), "".getBytes());
    final Tuple tuple3 = new Tuple("yjk", new BoundingBox(1d, 2d), "".getBytes());
    final JoinedTuple joinedTuple1 = new JoinedTuple(Arrays.asList(tuple1, tuple2), Arrays.asList("abc", "def"));
    final JoinedTuple joinedTuple2 = new JoinedTuple(Arrays.asList(tuple2, tuple3), Arrays.asList("abc", "def"));
    final JoinedTuple joinedTuple3 = new JoinedTuple(Arrays.asList(tuple2), Arrays.asList("abc"));
    Assert.assertEquals(joinedTuple1, joinedTuple1);
    Assert.assertEquals(joinedTuple1.hashCode(), joinedTuple1.hashCode());
    Assert.assertEquals(joinedTuple2, joinedTuple2);
    Assert.assertEquals(joinedTuple2.hashCode(), joinedTuple2.hashCode());
    Assert.assertTrue(joinedTuple1.compareTo(joinedTuple2) < 0);
    Assert.assertTrue(joinedTuple2.compareTo(joinedTuple1) > 0);
    Assert.assertTrue(joinedTuple1.compareTo(joinedTuple1) == 0);
    Assert.assertTrue(joinedTuple1.compareTo(joinedTuple3) < 0);
    Assert.assertTrue(joinedTuple1.getFormatedString().length() > 10);
    Assert.assertTrue(joinedTuple2.getFormatedString().length() > 10);
    Assert.assertTrue(joinedTuple3.getFormatedString().length() > 10);
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) JoinedTuple(org.bboxdb.storage.entity.JoinedTuple) Tuple(org.bboxdb.storage.entity.Tuple) JoinedTuple(org.bboxdb.storage.entity.JoinedTuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Test(org.junit.Test)

Aggregations

JoinedTuple (org.bboxdb.storage.entity.JoinedTuple)22 Tuple (org.bboxdb.storage.entity.Tuple)17 BoundingBox (org.bboxdb.commons.math.BoundingBox)13 Test (org.junit.Test)13 IndexedSpatialJoinOperator (org.bboxdb.storage.queryprocessor.operator.IndexedSpatialJoinOperator)8 SpatialIndexReadOperator (org.bboxdb.storage.queryprocessor.operator.SpatialIndexReadOperator)8 TupleStoreManager (org.bboxdb.storage.tuplestore.manager.TupleStoreManager)8 List (java.util.List)5 BBoxDBException (org.bboxdb.misc.BBoxDBException)5 TupleStoreConfiguration (org.bboxdb.storage.entity.TupleStoreConfiguration)5 Lists (com.google.common.collect.Lists)4 IOException (java.io.IOException)4 Iterator (java.util.Iterator)4 Collectors (java.util.stream.Collectors)4 RejectedException (org.bboxdb.commons.RejectedException)4 DeletedTuple (org.bboxdb.storage.entity.DeletedTuple)4 TupleStoreName (org.bboxdb.storage.entity.TupleStoreName)4 BoundingBoxSelectOperator (org.bboxdb.storage.queryprocessor.operator.BoundingBoxSelectOperator)4 FullTablescanOperator (org.bboxdb.storage.queryprocessor.operator.FullTablescanOperator)4 Operator (org.bboxdb.storage.queryprocessor.operator.Operator)4