Search in sources :

Example 21 with TupleStoreConfiguration

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());
}
Also used : TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) TupleListFuture(org.bboxdb.network.client.future.TupleListFuture) JoinedTupleListFuture(org.bboxdb.network.client.future.JoinedTupleListFuture) Tuple(org.bboxdb.storage.entity.Tuple) JoinedTuple(org.bboxdb.storage.entity.JoinedTuple) EmptyResultFuture(org.bboxdb.network.client.future.EmptyResultFuture)

Example 22 with TupleStoreConfiguration

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");
}
Also used : TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) TupleListFuture(org.bboxdb.network.client.future.TupleListFuture) JoinedTupleListFuture(org.bboxdb.network.client.future.JoinedTupleListFuture) Tuple(org.bboxdb.storage.entity.Tuple) JoinedTuple(org.bboxdb.storage.entity.JoinedTuple) EmptyResultFuture(org.bboxdb.network.client.future.EmptyResultFuture)

Example 23 with TupleStoreConfiguration

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");
}
Also used : TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) TupleListFuture(org.bboxdb.network.client.future.TupleListFuture) JoinedTupleListFuture(org.bboxdb.network.client.future.JoinedTupleListFuture) BoundingBox(org.bboxdb.commons.math.BoundingBox) Tuple(org.bboxdb.storage.entity.Tuple) JoinedTuple(org.bboxdb.storage.entity.JoinedTuple) EmptyResultFuture(org.bboxdb.network.client.future.EmptyResultFuture)

Example 24 with TupleStoreConfiguration

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);
}
Also used : BBoxDB(org.bboxdb.network.client.BBoxDB) TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) TupleListFuture(org.bboxdb.network.client.future.TupleListFuture) BoundingBox(org.bboxdb.commons.math.BoundingBox) EmptyResultFuture(org.bboxdb.network.client.future.EmptyResultFuture) Test(org.junit.Test)

Example 25 with TupleStoreConfiguration

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;
}
Also used : TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) Tuple(org.bboxdb.storage.entity.Tuple)

Aggregations

TupleStoreConfiguration (org.bboxdb.storage.entity.TupleStoreConfiguration)44 Test (org.junit.Test)23 Tuple (org.bboxdb.storage.entity.Tuple)21 EmptyResultFuture (org.bboxdb.network.client.future.EmptyResultFuture)15 TupleStoreName (org.bboxdb.storage.entity.TupleStoreName)13 BoundingBox (org.bboxdb.commons.math.BoundingBox)12 TupleListFuture (org.bboxdb.network.client.future.TupleListFuture)10 TupleStoreAdapter (org.bboxdb.distribution.zookeeper.TupleStoreAdapter)7 JoinedTupleListFuture (org.bboxdb.network.client.future.JoinedTupleListFuture)7 DeletedTuple (org.bboxdb.storage.entity.DeletedTuple)7 JoinedTuple (org.bboxdb.storage.entity.JoinedTuple)7 TupleStoreManager (org.bboxdb.storage.tuplestore.manager.TupleStoreManager)7 BBoxDBConnection (org.bboxdb.network.client.BBoxDBConnection)5 ArrayList (java.util.ArrayList)4 BBoxDBException (org.bboxdb.misc.BBoxDBException)4 BBoxDBClient (org.bboxdb.network.client.BBoxDBClient)4 DistributionRegion (org.bboxdb.distribution.region.DistributionRegion)3 DistributionGroupConfiguration (org.bboxdb.storage.entity.DistributionGroupConfiguration)3 SSTableWriter (org.bboxdb.storage.sstable.SSTableWriter)3 SSTableCompactor (org.bboxdb.storage.sstable.compact.SSTableCompactor)3