Search in sources :

Example 41 with Tuple

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

the class TestSampling method createDummyTable.

/**
 * Create a dummy table
 * @throws StorageManagerException
 * @throws RejectedException
 */
private void createDummyTable() throws StorageManagerException, RejectedException {
    final TupleStoreManager table = storageRegistry.createTable(TEST_RELATION, new TupleStoreConfiguration());
    for (int i = 0; i < 100; i++) {
        table.put(new Tuple(Integer.toString(i), new BoundingBox(1d, 2d, 1d, 20d), "".getBytes()));
        table.put(new DeletedTuple(Integer.toString(i + 10000)));
    }
}
Also used : DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) BoundingBox(org.bboxdb.commons.math.BoundingBox) Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) TupleStoreManager(org.bboxdb.storage.tuplestore.manager.TupleStoreManager)

Example 42 with Tuple

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

the class TestTupleSink method testTupleWithoutRegions.

/**
 * Redistribute a tuple without any registered regions
 * @throws Exception
 */
@Test(expected = StorageManagerException.class)
public void testTupleWithoutRegions() throws Exception {
    final TupleRedistributor tupleRedistributor = createTupleRedistributor();
    final Tuple tuple1 = new Tuple("abc", BoundingBox.FULL_SPACE, "".getBytes());
    tupleRedistributor.redistributeTuple(tuple1);
}
Also used : TupleRedistributor(org.bboxdb.distribution.partitioner.regionsplit.tuplesink.TupleRedistributor) Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Test(org.junit.Test)

Example 43 with Tuple

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

the class TestTupleSink method testTupleRedistribution1.

/**
 * Test the tuple redistribution
 * @throws Exception
 */
@Test(timeout = 60000)
public void testTupleRedistribution1() throws Exception {
    final DistributionRegion distributionRegion1 = new DistributionRegion(TEST_GROUP, DistributionRegion.ROOT_NODE_ROOT_POINTER, new BoundingBox(0.0, 1.0, 0.0, 1.0, 0.0, 1.0), 1);
    final TupleRedistributor tupleRedistributor = createTupleRedistributor();
    final AbstractTupleSink tupleSink1 = Mockito.mock(AbstractTupleSink.class);
    tupleRedistributor.registerRegion(distributionRegion1, Arrays.asList(tupleSink1));
    final Tuple tuple1 = new Tuple("abc", new BoundingBox(0.0, 1.0, 0.0, 1.0, 0.0, 1.0), "".getBytes());
    tupleRedistributor.redistributeTuple(tuple1);
    (Mockito.verify(tupleSink1, Mockito.times(1))).sinkTuple(Mockito.any(Tuple.class));
    tupleRedistributor.redistributeTuple(tuple1);
    (Mockito.verify(tupleSink1, Mockito.times(2))).sinkTuple(Mockito.any(Tuple.class));
    System.out.println(tupleRedistributor.getStatistics());
}
Also used : TupleRedistributor(org.bboxdb.distribution.partitioner.regionsplit.tuplesink.TupleRedistributor) DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) BoundingBox(org.bboxdb.commons.math.BoundingBox) AbstractTupleSink(org.bboxdb.distribution.partitioner.regionsplit.tuplesink.AbstractTupleSink) Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Test(org.junit.Test)

Example 44 with Tuple

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

the class TestTupleSink method testTupleSink.

/**
 * Test the tuple sinks
 * @throws StorageManagerException
 * @throws BBoxDBException
 * @throws ZookeeperException
 * @throws InterruptedException
 */
@Test(timeout = 60000)
public void testTupleSink() throws StorageManagerException, BBoxDBException, ZookeeperException, InterruptedException {
    final DistributionRegion distributionRegion = SpacePartitionerCache.getInstance().getSpacePartitionerForGroupName(TEST_GROUP).getRootNode();
    tupleStoreAdapter.deleteTable(TABLENAME);
    tupleStoreAdapter.writeTuplestoreConfiguration(TABLENAME, new TupleStoreConfiguration());
    final List<BBoxDBInstance> systems = Arrays.asList(new BBoxDBInstance("10.0.0.1:10000"), new BBoxDBInstance("10.0.0.2:10000"), ZookeeperClientFactory.getLocalInstanceName());
    distributionRegion.setSystems(systems);
    final TupleRedistributor tupleRedistributor = createTupleRedistributor();
    tupleRedistributor.registerRegion(distributionRegion);
    final Map<DistributionRegion, List<AbstractTupleSink>> map = tupleRedistributor.getRegionMap();
    Assert.assertEquals(1, map.size());
    final long networkSinks = map.values().stream().flatMap(e -> e.stream()).filter(s -> s instanceof NetworkTupleSink).count();
    Assert.assertEquals(2, networkSinks);
    final long localSinks = map.values().stream().flatMap(e -> e.stream()).filter(s -> s instanceof LocalTupleSink).count();
    Assert.assertEquals(1, localSinks);
}
Also used : TupleRedistributor(org.bboxdb.distribution.partitioner.regionsplit.tuplesink.TupleRedistributor) Arrays(java.util.Arrays) BeforeClass(org.junit.BeforeClass) TupleStoreAdapter(org.bboxdb.distribution.zookeeper.TupleStoreAdapter) LocalTupleSink(org.bboxdb.distribution.partitioner.regionsplit.tuplesink.LocalTupleSink) Tuple(org.bboxdb.storage.entity.Tuple) BoundingBox(org.bboxdb.commons.math.BoundingBox) ArrayList(java.util.ArrayList) ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) Map(java.util.Map) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) StorageManagerException(org.bboxdb.storage.StorageManagerException) DistributionGroupConfiguration(org.bboxdb.storage.entity.DistributionGroupConfiguration) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) ZookeeperClientFactory(org.bboxdb.distribution.zookeeper.ZookeeperClientFactory) NetworkTupleSink(org.bboxdb.distribution.partitioner.regionsplit.tuplesink.NetworkTupleSink) DistributionGroupConfigurationBuilder(org.bboxdb.storage.entity.DistributionGroupConfigurationBuilder) Test(org.junit.Test) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) TupleStoreManagerRegistry(org.bboxdb.storage.tuplestore.manager.TupleStoreManagerRegistry) Mockito(org.mockito.Mockito) List(java.util.List) AbstractTupleSink(org.bboxdb.distribution.partitioner.regionsplit.tuplesink.AbstractTupleSink) BBoxDBException(org.bboxdb.misc.BBoxDBException) TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) DistributionGroupAdapter(org.bboxdb.distribution.zookeeper.DistributionGroupAdapter) SpacePartitionerCache(org.bboxdb.distribution.partitioner.SpacePartitionerCache) TupleRedistributor(org.bboxdb.distribution.partitioner.regionsplit.tuplesink.TupleRedistributor) Assert(org.junit.Assert) DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) LocalTupleSink(org.bboxdb.distribution.partitioner.regionsplit.tuplesink.LocalTupleSink) NetworkTupleSink(org.bboxdb.distribution.partitioner.regionsplit.tuplesink.NetworkTupleSink) ArrayList(java.util.ArrayList) List(java.util.List) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) Test(org.junit.Test)

Example 45 with Tuple

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

the class TestNetworkClasses method encodeAndDecodeDeletedTuple1.

/**
 * The the encoding and decoding of an insert tuple package
 * @throws IOException
 * @throws PackageEncodeException
 */
@Test(timeout = 60000)
public void encodeAndDecodeDeletedTuple1() throws IOException, PackageEncodeException {
    final Tuple tuple = new DeletedTuple("key", 12);
    final short sequenceNumber = sequenceNumberGenerator.getNextSequenceNummber();
    final InsertTupleRequest insertPackage = new InsertTupleRequest(sequenceNumber, ROUTING_HEADER_UNROUTED, new TupleStoreName("test"), tuple);
    byte[] encodedVersion = networkPackageToByte(insertPackage);
    Assert.assertNotNull(encodedVersion);
    final ByteBuffer bb = NetworkPackageDecoder.encapsulateBytes(encodedVersion);
    final InsertTupleRequest decodedPackage = InsertTupleRequest.decodeTuple(bb);
    Assert.assertEquals(insertPackage.getTuple(), decodedPackage.getTuple());
    Assert.assertEquals(insertPackage.getTable(), decodedPackage.getTable());
    Assert.assertEquals(insertPackage.getRoutingHeader(), new RoutingHeader(false));
    Assert.assertEquals(insertPackage, decodedPackage);
    Assert.assertEquals(insertPackage.hashCode(), decodedPackage.hashCode());
    Assert.assertEquals(insertPackage.toString(), decodedPackage.toString());
    Assert.assertTrue(TupleHelper.isDeletedTuple(decodedPackage.getTuple()));
}
Also used : DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) RoutingHeader(org.bboxdb.network.routing.RoutingHeader) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) ByteBuffer(java.nio.ByteBuffer) JoinedTuple(org.bboxdb.storage.entity.JoinedTuple) Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) InsertTupleRequest(org.bboxdb.network.packages.request.InsertTupleRequest) 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