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;
}
}
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);
}
Aggregations