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