Search in sources :

Example 71 with Tuple

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

the class DistributedSelftest method insertNewTuples.

/**
 * Insert new tuples
 * @param bboxdbClient
 * @throws InterruptedException
 * @throws ExecutionException
 * @throws BBoxDBException
 */
private static void insertNewTuples(final BBoxDBCluster bboxdbClient) throws InterruptedException, ExecutionException, BBoxDBException {
    logger.info("Inserting new tuples");
    for (int i = 0; i < NUMBER_OF_OPERATIONS; i++) {
        final String key = Integer.toString(i);
        final Tuple myTuple = new Tuple(key, new BoundingBox(1.0d, 2.0d, 1.0d, 2.0d), "test".getBytes());
        final EmptyResultFuture insertResult = bboxdbClient.insertTuple(TABLE, myTuple);
        insertResult.waitForAll();
        if (insertResult.isFailed()) {
            logger.error("Got an error during tuple insert: ", insertResult.getAllMessages());
            System.exit(-1);
        }
    }
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) Tuple(org.bboxdb.storage.entity.Tuple) EmptyResultFuture(org.bboxdb.network.client.future.EmptyResultFuture)

Example 72 with Tuple

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

the class SSTableExaminer method internalScan.

/**
 * Perform a scan with the internal method of the sstable rader
 * @param ssTableReader
 * @throws StorageManagerException
 */
protected void internalScan(final SSTableReader ssTableReader) throws StorageManagerException {
    System.out.println("Step 2: Scan for tuple with key: " + examineKey);
    final Tuple scanTuple = ssTableReader.scanForTuple(examineKey);
    System.out.println(scanTuple);
}
Also used : Tuple(org.bboxdb.storage.entity.Tuple)

Example 73 with Tuple

use of org.bboxdb.storage.entity.Tuple 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 74 with Tuple

use of org.bboxdb.storage.entity.Tuple 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 75 with Tuple

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

the class TestTupleHelper method encodeAndDecodeTuple2.

/**
 * Encode and decode a tuple
 * @throws IOException
 */
@Test(timeout = 60000)
public void encodeAndDecodeTuple2() throws IOException {
    final Tuple tuple = new DeletedTuple("abc");
    // Read from stream
    final byte[] bytes = TupleHelper.tupleToBytes(tuple);
    final ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
    final Tuple readTuple = TupleHelper.decodeTuple(inputStream);
    Assert.assertEquals(tuple, readTuple);
    // Read from byte buffer
    final ByteBuffer bb = ByteBuffer.wrap(bytes);
    final Tuple readTuple2 = TupleHelper.decodeTuple(bb);
    Assert.assertEquals(tuple, readTuple2);
}
Also used : DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteBuffer(java.nio.ByteBuffer) Tuple(org.bboxdb.storage.entity.Tuple) JoinedTuple(org.bboxdb.storage.entity.JoinedTuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Test(org.junit.Test)

Aggregations

Tuple (org.bboxdb.storage.entity.Tuple)198 Test (org.junit.Test)123 DeletedTuple (org.bboxdb.storage.entity.DeletedTuple)104 BoundingBox (org.bboxdb.commons.math.BoundingBox)62 JoinedTuple (org.bboxdb.storage.entity.JoinedTuple)58 ArrayList (java.util.ArrayList)41 TupleStoreConfiguration (org.bboxdb.storage.entity.TupleStoreConfiguration)25 TupleStoreName (org.bboxdb.storage.entity.TupleStoreName)24 TupleListFuture (org.bboxdb.network.client.future.TupleListFuture)18 TupleStoreManager (org.bboxdb.storage.tuplestore.manager.TupleStoreManager)18 ByteBuffer (java.nio.ByteBuffer)17 BBoxDBException (org.bboxdb.misc.BBoxDBException)16 EmptyResultFuture (org.bboxdb.network.client.future.EmptyResultFuture)15 SSTableKeyIndexReader (org.bboxdb.storage.sstable.reader.SSTableKeyIndexReader)13 IOException (java.io.IOException)11 List (java.util.List)11 JoinedTupleListFuture (org.bboxdb.network.client.future.JoinedTupleListFuture)11 InsertTupleRequest (org.bboxdb.network.packages.request.InsertTupleRequest)11 StorageManagerException (org.bboxdb.storage.StorageManagerException)11 TupleBuilder (org.bboxdb.tools.converter.tuple.TupleBuilder)11