Search in sources :

Example 11 with Tuple

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

the class TestMemtable method testIterate3.

/**
 * Test iterator 3
 * @throws Exception
 */
@Test(timeout = 60000)
public void testIterate3() throws Exception {
    final Tuple createdTuple1 = new Tuple("1", null, "abc".getBytes());
    memtable.put(createdTuple1);
    final Tuple createdTuple2 = new Tuple("2", null, "abc".getBytes());
    memtable.put(createdTuple2);
    final Tuple createdTuple3 = new Tuple("3", null, "abc".getBytes());
    memtable.put(createdTuple3);
    int tuples = 0;
    for (@SuppressWarnings("unused") final Tuple tuple : memtable) {
        tuples++;
    }
    Assert.assertEquals(3, tuples);
}
Also used : Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Test(org.junit.Test)

Example 12 with Tuple

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

the class TestMemtable method testTimeQuery.

/**
 * The the time query
 * @throws StorageManagerException
 */
@Test(timeout = 60000)
public void testTimeQuery() throws StorageManagerException {
    final Tuple createdTuple1 = new Tuple("1", null, "abc".getBytes(), 1);
    memtable.put(createdTuple1);
    final Tuple createdTuple2 = new Tuple("2", null, "abc".getBytes(), 2);
    memtable.put(createdTuple2);
    final Tuple createdTuple3 = new Tuple("3", null, "abc".getBytes(), 3);
    memtable.put(createdTuple3);
    // Query the memtable
    Assert.assertEquals(3, countTuplesForPredicate(new NewerAsVersionTimePredicate(0)));
    Assert.assertEquals(0, countTuplesForPredicate(new NewerAsVersionTimePredicate(Long.MAX_VALUE)));
    Assert.assertEquals(2, countTuplesForPredicate(new NewerAsVersionTimePredicate(createdTuple1.getVersionTimestamp())));
    Assert.assertEquals(1, countTuplesForPredicate(new NewerAsVersionTimePredicate(createdTuple2.getVersionTimestamp())));
    Assert.assertEquals(0, countTuplesForPredicate(new NewerAsVersionTimePredicate(createdTuple3.getVersionTimestamp())));
}
Also used : NewerAsVersionTimePredicate(org.bboxdb.storage.queryprocessor.predicate.NewerAsVersionTimePredicate) Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Test(org.junit.Test)

Example 13 with Tuple

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

the class TestPredicates method testNewerAsPredicate1.

/**
 * Test the newer as predicate
 * @throws Exception
 */
@Test(timeout = 60000)
public void testNewerAsPredicate1() throws Exception {
    final Tuple tuple1 = new Tuple("1", BoundingBox.FULL_SPACE, "abc".getBytes(), 1);
    final Tuple tuple2 = new Tuple("2", BoundingBox.FULL_SPACE, "def".getBytes(), 2);
    final List<Tuple> tupleList = new ArrayList<>();
    tupleList.add(tuple1);
    tupleList.add(tuple2);
    final Predicate predicate = new NewerAsVersionTimePredicate(0);
    final Collection<Tuple> tuples = getTuplesFromPredicate(tupleList, predicate);
    System.out.println(tuples);
    Assert.assertEquals(2, tuples.size());
    Assert.assertTrue(tuples.contains(tuple1));
    Assert.assertTrue(tuples.contains(tuple2));
}
Also used : NewerAsVersionTimePredicate(org.bboxdb.storage.queryprocessor.predicate.NewerAsVersionTimePredicate) ArrayList(java.util.ArrayList) Tuple(org.bboxdb.storage.entity.Tuple) Predicate(org.bboxdb.storage.queryprocessor.predicate.Predicate) AndPredicate(org.bboxdb.storage.queryprocessor.predicate.AndPredicate) NewerAsVersionTimePredicate(org.bboxdb.storage.queryprocessor.predicate.NewerAsVersionTimePredicate) OverlapsBoundingBoxPredicate(org.bboxdb.storage.queryprocessor.predicate.OverlapsBoundingBoxPredicate) Test(org.junit.Test)

Example 14 with Tuple

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

the class TestPredicates method testNewerAsPredicate2.

/**
 * Test the newer as predicate
 * @throws Exception
 */
@Test(timeout = 60000)
public void testNewerAsPredicate2() throws Exception {
    final Tuple tuple1 = new Tuple("1", BoundingBox.FULL_SPACE, "abc".getBytes(), 50);
    final Tuple tuple2 = new Tuple("2", BoundingBox.FULL_SPACE, "def".getBytes(), 1234);
    final List<Tuple> tupleList = new ArrayList<>();
    tupleList.add(tuple1);
    tupleList.add(tuple2);
    final Predicate predicate = new NewerAsVersionTimePredicate(51);
    final Collection<Tuple> tuples = getTuplesFromPredicate(tupleList, predicate);
    Assert.assertEquals(1, tuples.size());
    Assert.assertFalse(tuples.contains(tuple1));
    Assert.assertTrue(tuples.contains(tuple2));
}
Also used : NewerAsVersionTimePredicate(org.bboxdb.storage.queryprocessor.predicate.NewerAsVersionTimePredicate) ArrayList(java.util.ArrayList) Tuple(org.bboxdb.storage.entity.Tuple) Predicate(org.bboxdb.storage.queryprocessor.predicate.Predicate) AndPredicate(org.bboxdb.storage.queryprocessor.predicate.AndPredicate) NewerAsVersionTimePredicate(org.bboxdb.storage.queryprocessor.predicate.NewerAsVersionTimePredicate) OverlapsBoundingBoxPredicate(org.bboxdb.storage.queryprocessor.predicate.OverlapsBoundingBoxPredicate) Test(org.junit.Test)

Example 15 with Tuple

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

the class TestPredicates method boundingAndPredicate.

/**
 * Test the and predicate
 * @throws Exception
 */
@Test(timeout = 60000)
public void boundingAndPredicate() {
    final Tuple tuple1 = new Tuple("1", new BoundingBox(1.0, 10.0, 1.0, 10.9), "abc".getBytes(), 50);
    final Tuple tuple2 = new Tuple("2", new BoundingBox(-11.0, 0.0, -11.0, 0.9), "def".getBytes(), 1234);
    final List<Tuple> tupleList = new ArrayList<>();
    tupleList.add(tuple1);
    tupleList.add(tuple2);
    final Predicate predicate1 = new OverlapsBoundingBoxPredicate(new BoundingBox(2.0, 100.0, 2.0, 100.0));
    final Predicate predicate2 = new NewerAsVersionTimePredicate(51);
    final Predicate predicate = new AndPredicate(predicate1, predicate2);
    final Collection<Tuple> tuples = getTuplesFromPredicate(tupleList, predicate);
    Assert.assertTrue(tuples.isEmpty());
}
Also used : NewerAsVersionTimePredicate(org.bboxdb.storage.queryprocessor.predicate.NewerAsVersionTimePredicate) BoundingBox(org.bboxdb.commons.math.BoundingBox) ArrayList(java.util.ArrayList) AndPredicate(org.bboxdb.storage.queryprocessor.predicate.AndPredicate) OverlapsBoundingBoxPredicate(org.bboxdb.storage.queryprocessor.predicate.OverlapsBoundingBoxPredicate) Tuple(org.bboxdb.storage.entity.Tuple) Predicate(org.bboxdb.storage.queryprocessor.predicate.Predicate) AndPredicate(org.bboxdb.storage.queryprocessor.predicate.AndPredicate) NewerAsVersionTimePredicate(org.bboxdb.storage.queryprocessor.predicate.NewerAsVersionTimePredicate) OverlapsBoundingBoxPredicate(org.bboxdb.storage.queryprocessor.predicate.OverlapsBoundingBoxPredicate) 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