use of org.bboxdb.storage.entity.TupleStoreConfiguration in project bboxdb by jnidzwetzki.
the class NetworkQueryHelper method testVersionTimeQuery.
/**
* Test the version time query
* @param bboxDBConnection
* @param distributionGroup
* @throws InterruptedException
* @throws BBoxDBException
*/
public static void testVersionTimeQuery(final BBoxDB bboxDBClient, final String distributionGroup) throws InterruptedException, BBoxDBException {
final String table = distributionGroup + "_relationqt";
final String key = "key12";
System.out.println("== Executing testVersionTimeQuery");
// Create table
final EmptyResultFuture resultCreateTable = bboxDBClient.createTable(table, new TupleStoreConfiguration());
resultCreateTable.waitForAll();
Assert.assertFalse(resultCreateTable.isFailed());
final Tuple tuple = new Tuple(key, BoundingBox.FULL_SPACE, "abc".getBytes());
final EmptyResultFuture insertResult = bboxDBClient.insertTuple(table, tuple);
insertResult.waitForAll();
Assert.assertFalse(insertResult.isFailed());
Assert.assertTrue(insertResult.isDone());
System.out.println("Query all versions");
final TupleListFuture getResult1 = bboxDBClient.queryVersionTime(table, 0);
getResult1.waitForAll();
final List<Tuple> resultList1 = Lists.newArrayList(getResult1.iterator());
Assert.assertEquals(1, resultList1.size());
Assert.assertEquals(tuple, resultList1.get(0));
System.out.println("Query newest versions");
final TupleListFuture getResult2 = bboxDBClient.queryVersionTime(table, Long.MAX_VALUE);
getResult2.waitForAll();
final List<Tuple> resultList2 = Lists.newArrayList(getResult2.iterator());
Assert.assertTrue(resultList2.isEmpty());
}
use of org.bboxdb.storage.entity.TupleStoreConfiguration in project bboxdb by jnidzwetzki.
the class NetworkQueryHelper method testInsertAndDeleteTuple.
/**
* Insert and delete tuple
* @param bboxDBConnection
* @throws BBoxDBException
* @throws InterruptedException
*/
public static void testInsertAndDeleteTuple(final BBoxDB bboxDBClient, final String distributionGroup) throws BBoxDBException, InterruptedException {
System.out.println("=== Running testInsertAndDelete");
final String table = distributionGroup + "_relation4";
final String key = "key12";
// Create table
final EmptyResultFuture resultCreateTable = bboxDBClient.createTable(table, new TupleStoreConfiguration());
resultCreateTable.waitForAll();
Assert.assertFalse(resultCreateTable.isFailed());
System.out.println("Delete tuple");
final EmptyResultFuture deleteResult1 = bboxDBClient.deleteTuple(table, key);
deleteResult1.waitForAll();
Assert.assertFalse(deleteResult1.isFailed());
Assert.assertTrue(deleteResult1.isDone());
System.out.println("Query key");
final TupleListFuture getResult = bboxDBClient.queryKey(table, key);
getResult.waitForAll();
Assert.assertFalse(getResult.isFailed());
Assert.assertTrue(getResult.isDone());
System.out.println("Insert tuple");
final Tuple tuple = new Tuple(key, BoundingBox.FULL_SPACE, "abc".getBytes());
final EmptyResultFuture insertResult = bboxDBClient.insertTuple(table, tuple);
insertResult.waitForAll();
Assert.assertFalse(insertResult.isFailed());
Assert.assertTrue(insertResult.isDone());
System.out.println("Query key 2");
final TupleListFuture getResult2 = bboxDBClient.queryKey(table, key);
getResult2.waitForAll();
final List<Tuple> resultList = Lists.newArrayList(getResult2.iterator());
Assert.assertEquals(tuple, resultList.get(0));
System.out.println("Delete tuple 2");
final EmptyResultFuture deleteResult2 = bboxDBClient.deleteTuple(table, key, System.currentTimeMillis());
deleteResult2.waitForAll();
Assert.assertFalse(deleteResult2.isFailed());
Assert.assertTrue(deleteResult2.isDone());
System.out.println("Query key 3");
final TupleListFuture getResult3 = bboxDBClient.queryKey(table, key);
getResult3.waitForAll();
Assert.assertFalse(getResult3.isFailed());
Assert.assertTrue(getResult3.isDone());
bboxDBClient.disconnect();
System.out.println("=== End testInsertAndDelete");
}
use of org.bboxdb.storage.entity.TupleStoreConfiguration in project bboxdb by jnidzwetzki.
the class NetworkQueryHelper method testBoundingBoxQueryContinous.
/**
* Test a bounding box query
* @param bboxDBConnection
* @throws BBoxDBException
* @throws InterruptedException
*/
public static void testBoundingBoxQueryContinous(final BBoxDBClient bboxDBClient, final String distributionGroup) throws BBoxDBException, InterruptedException {
System.out.println("=== Running testBoundingBoxQueryContinous");
final String table = distributionGroup + "_relation9991";
// Create table
final EmptyResultFuture resultCreateTable = bboxDBClient.createTable(table, new TupleStoreConfiguration());
resultCreateTable.waitForAll();
Assert.assertFalse(resultCreateTable.isFailed());
final TupleListFuture future = bboxDBClient.queryBoundingBoxContinuous(table, new BoundingBox(-1d, 2d, -1d, 2d));
Thread.sleep(1000);
System.out.println("=== Tuples per page is: " + bboxDBClient.getTuplesPerPage());
if (bboxDBClient.getTuplesPerPage() > 0) {
for (int i = 0; i <= bboxDBClient.getTuplesPerPage(); i++) {
bboxDBClient.insertTuple(table, new Tuple("1", new BoundingBox(0d, 1d, 0d, 1d), "".getBytes()));
}
}
System.out.println("=== Wait for query result");
future.waitForAll();
Assert.assertTrue(future.iterator().hasNext());
final short queryId = future.getRequestId(0);
System.out.println("Canceling query: " + queryId);
final EmptyResultFuture cancelResult = bboxDBClient.cancelQuery(queryId);
cancelResult.waitForAll();
Assert.assertTrue(cancelResult.isDone());
Assert.assertFalse(cancelResult.isFailed());
System.out.println("=== End testBoundingBoxQueryContinous");
}
use of org.bboxdb.storage.entity.TupleStoreConfiguration in project bboxdb by jnidzwetzki.
the class TestBBoxDBCluster method testInsertAndBoundingBoxContinousQuery.
/**
* Insert some tuples and start a bounding box query afterwards
* @throws ExecutionException
* @throws InterruptedException
* @throws BBoxDBException
*/
@Test(timeout = 60000)
public void testInsertAndBoundingBoxContinousQuery() throws InterruptedException, ExecutionException, BBoxDBException {
final BBoxDB bboxDBClient = connectToServer();
final String table = DISTRIBUTION_GROUP + "_relation9991";
// Create table
final EmptyResultFuture resultCreateTable = bboxDBClient.createTable(table, new TupleStoreConfiguration());
resultCreateTable.waitForAll();
Assert.assertFalse(resultCreateTable.isFailed());
// Execute query
final TupleListFuture result = bboxDBClient.queryBoundingBoxContinuous(table, new BoundingBox(-1d, 2d, -1d, 2d));
Assert.assertFalse(result.isFailed());
disconnect(bboxDBClient);
}
use of org.bboxdb.storage.entity.TupleStoreConfiguration in project bboxdb by jnidzwetzki.
the class TupleStoreManager method getVersionsForTuple.
/**
* Get the most recent version of the tuple
* e.g. Memtables can contain multiple versions of the key
* The iterator can return an outdated version
*
* @param tuple
* @return
* @throws StorageManagerException
*/
public List<Tuple> getVersionsForTuple(final String key) throws StorageManagerException {
final List<Tuple> resultTuples = getAllTupleVersionsForKey(key);
final TupleStoreConfiguration tupleStoreConfiguration = getTupleStoreConfiguration();
final DuplicateResolver<Tuple> resolver = TupleDuplicateResolverFactory.build(tupleStoreConfiguration);
// Removed unwanted tuples for key
resolver.removeDuplicates(resultTuples);
return resultTuples;
}
Aggregations