Search in sources :

Example 36 with BoundingBox

use of org.bboxdb.commons.math.BoundingBox in project bboxdb by jnidzwetzki.

the class CLI method actionInsertTuple.

/**
 * Insert a new tuple
 * @param line
 */
protected void actionInsertTuple(final CommandLine line) {
    final List<String> requiredArgs = Arrays.asList(CLIParameter.TABLE, CLIParameter.KEY, CLIParameter.BOUNDING_BOX, CLIParameter.VALUE);
    checkRequiredArgs(requiredArgs);
    final String table = line.getOptionValue(CLIParameter.TABLE);
    final String key = line.getOptionValue(CLIParameter.KEY);
    final String value = line.getOptionValue(CLIParameter.VALUE);
    final BoundingBox boundingBox = getBoundingBoxFromArgs(line);
    final Tuple tuple = new Tuple(key, boundingBox, value.getBytes());
    System.out.println("Insert new tuple into table: " + table);
    try {
        final EmptyResultFuture future = bboxDbConnection.insertTuple(table, tuple);
        pendingFutures.put(future);
        pendingFutures.waitForCompletion();
    } catch (BBoxDBException e) {
        System.err.println("Got an error during insert: " + e);
        System.exit(-1);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        return;
    }
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) BBoxDBException(org.bboxdb.misc.BBoxDBException) Tuple(org.bboxdb.storage.entity.Tuple) JoinedTuple(org.bboxdb.storage.entity.JoinedTuple) EmptyResultFuture(org.bboxdb.network.client.future.EmptyResultFuture)

Example 37 with BoundingBox

use of org.bboxdb.commons.math.BoundingBox in project bboxdb by jnidzwetzki.

the class CLI method buildQueryFuture.

/**
 * Build the query future
 * @param line
 * @return
 * @throws BBoxDBException
 */
protected TupleListFuture buildQueryFuture(final CommandLine line) throws BBoxDBException {
    final String table = line.getOptionValue(CLIParameter.TABLE);
    if (line.hasOption(CLIParameter.KEY)) {
        System.out.println("Executing key query..");
        final String key = line.getOptionValue(CLIParameter.KEY);
        return bboxDbConnection.queryKey(table, key);
    } else if (line.hasOption(CLIParameter.BOUNDING_BOX) && line.hasOption(CLIParameter.TIMESTAMP)) {
        System.out.println("Executing bounding box and time query...");
        final BoundingBox boundingBox = getBoundingBoxFromArgs(line);
        final long timestamp = getTimestampFromArgs();
        return bboxDbConnection.queryBoundingBoxAndTime(table, boundingBox, timestamp);
    } else if (line.hasOption(CLIParameter.BOUNDING_BOX)) {
        System.out.println("Executing bounding box query...");
        final BoundingBox boundingBox = getBoundingBoxFromArgs(line);
        return bboxDbConnection.queryBoundingBox(table, boundingBox);
    } else if (line.hasOption(CLIParameter.TIMESTAMP)) {
        System.out.println("Executing time query...");
        final long timestamp = getTimestampFromArgs();
        return bboxDbConnection.queryVersionTime(table, timestamp);
    } else {
        System.err.println("Unable to execute query with the specified parameter");
        printHelpAndExit();
        // Unreachable code
        return null;
    }
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox)

Example 38 with BoundingBox

use of org.bboxdb.commons.math.BoundingBox in project bboxdb by jnidzwetzki.

the class TestTupleHelper method testCreateWithDifferentSizes.

/**
 * Test the creation with different sizes
 */
@Test(expected = IllegalArgumentException.class)
public void testCreateWithDifferentSizes() {
    final Tuple tuple1 = new Tuple("abc", new BoundingBox(1d, 2d), "".getBytes());
    final Tuple tuple2 = new Tuple("def", new BoundingBox(1d, 2d), "".getBytes());
    new JoinedTuple(Arrays.asList(tuple1, tuple2), Arrays.asList("abc"));
}
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)

Example 39 with BoundingBox

use of org.bboxdb.commons.math.BoundingBox in project bboxdb by jnidzwetzki.

the class TestTupleHelper method testConvertMultiTuple.

/**
 * Test the convert method of multiple tuples
 */
@Test(expected = IllegalArgumentException.class)
public void testConvertMultiTuple() {
    final Tuple tuple1 = new Tuple("abc", new BoundingBox(1d, 2d), "".getBytes());
    final Tuple tuple2 = new Tuple("def", new BoundingBox(1d, 2d), "".getBytes());
    final JoinedTuple joinedTuple1 = new JoinedTuple(Arrays.asList(tuple1, tuple2), Arrays.asList("abc", "def"));
    joinedTuple1.convertToSingleTupleIfPossible();
}
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)

Example 40 with BoundingBox

use of org.bboxdb.commons.math.BoundingBox in project bboxdb by jnidzwetzki.

the class RTreeTestHelper method getEntryList.

/**
 * Generate a list of tuples
 * @return
 */
public static List<SpatialIndexEntry> getEntryList() {
    final List<SpatialIndexEntry> entryList = new ArrayList<SpatialIndexEntry>();
    entryList.add(new SpatialIndexEntry(new BoundingBox(0d, 1d, 0d, 1d), 1));
    entryList.add(new SpatialIndexEntry(new BoundingBox(1d, 2d, 1d, 3d), 2));
    entryList.add(new SpatialIndexEntry(new BoundingBox(2d, 3d, 0d, 1d), 3));
    entryList.add(new SpatialIndexEntry(new BoundingBox(3d, 4d, 3d, 7d), 4));
    entryList.add(new SpatialIndexEntry(new BoundingBox(1.2d, 2.2d, 0d, 1d), 5));
    entryList.add(new SpatialIndexEntry(new BoundingBox(4.6d, 5.6d, 0d, 1d), 6));
    entryList.add(new SpatialIndexEntry(new BoundingBox(5.2d, 6.2d, 4d, 5d), 7));
    entryList.add(new SpatialIndexEntry(new BoundingBox(5.1d, 6.1d, 0d, 1d), 8));
    entryList.add(new SpatialIndexEntry(new BoundingBox(6.1d, 7.1d, 0d, 1d), 9));
    entryList.add(new SpatialIndexEntry(new BoundingBox(8.1d, 9.1d, 2d, 5d), 10));
    return entryList;
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) ArrayList(java.util.ArrayList) SpatialIndexEntry(org.bboxdb.storage.sstable.spatialindex.SpatialIndexEntry)

Aggregations

BoundingBox (org.bboxdb.commons.math.BoundingBox)194 Test (org.junit.Test)113 Tuple (org.bboxdb.storage.entity.Tuple)61 ArrayList (java.util.ArrayList)25 JoinedTuple (org.bboxdb.storage.entity.JoinedTuple)24 DeletedTuple (org.bboxdb.storage.entity.DeletedTuple)23 BBoxDBException (org.bboxdb.misc.BBoxDBException)22 DistributionRegion (org.bboxdb.distribution.region.DistributionRegion)20 TupleStoreName (org.bboxdb.storage.entity.TupleStoreName)16 List (java.util.List)15 DistributionRegionIdMapper (org.bboxdb.distribution.region.DistributionRegionIdMapper)13 ZookeeperException (org.bboxdb.distribution.zookeeper.ZookeeperException)13 TupleStoreConfiguration (org.bboxdb.storage.entity.TupleStoreConfiguration)13 TupleListFuture (org.bboxdb.network.client.future.TupleListFuture)12 ZookeeperNotFoundException (org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException)11 EmptyResultFuture (org.bboxdb.network.client.future.EmptyResultFuture)11 IOException (java.io.IOException)10 Date (java.util.Date)10 DoubleInterval (org.bboxdb.commons.math.DoubleInterval)10 SpatialIndexReadOperator (org.bboxdb.storage.queryprocessor.operator.SpatialIndexReadOperator)10