Search in sources :

Example 21 with BoundingBox

use of org.bboxdb.commons.math.BoundingBox in project bboxdb by jnidzwetzki.

the class TestRegionSyncer method createSplittedRoot.

/**
 * Create a splitted root
 * @param distributionRegionSyncer
 * @param root
 * @return
 * @throws ZookeeperException
 * @throws InterruptedException
 */
private String createSplittedRoot(final DistributionRegionSyncer distributionRegionSyncer, final DistributionRegion root) throws ZookeeperException, InterruptedException {
    final BoundingBox leftBoundingBox = root.getConveringBox().splitAndGetLeft(0, 0, true);
    final BoundingBox rightBoundingBox = root.getConveringBox().splitAndGetRight(0, 0, true);
    final String regionPath = distributionRegionAdapter.getZookeeperPathForDistributionRegion(root);
    final CountDownLatch latchLevel0 = new CountDownLatch(1);
    final DistributionRegionCallback level0Callback = (e, r) -> {
        if (root.getDirectChildren().size() == 2) {
            latchLevel0.countDown();
        }
    };
    distributionRegionSyncer.registerCallback(level0Callback);
    distributionRegionAdapter.createNewChild(regionPath, 0, leftBoundingBox, GROUP);
    distributionRegionAdapter.createNewChild(regionPath, 1, rightBoundingBox, GROUP);
    latchLevel0.await();
    distributionRegionSyncer.unregisterCallback(level0Callback);
    Assert.assertEquals(2, root.getDirectChildren().size());
    Assert.assertTrue(root.getChildNumber(0) != null);
    Assert.assertTrue(root.getChildNumber(1) != null);
    return GROUP;
}
Also used : DistributionRegionIdMapper(org.bboxdb.distribution.region.DistributionRegionIdMapper) ZookeeperClientFactory(org.bboxdb.distribution.zookeeper.ZookeeperClientFactory) SpacePartitionerContext(org.bboxdb.distribution.partitioner.SpacePartitionerContext) DistributionRegionCallback(org.bboxdb.distribution.region.DistributionRegionCallback) Set(java.util.Set) DistributionGroupConfigurationBuilder(org.bboxdb.storage.entity.DistributionGroupConfigurationBuilder) Test(org.junit.Test) DistributionRegionState(org.bboxdb.distribution.partitioner.DistributionRegionState) CopyOnWriteArraySet(java.util.concurrent.CopyOnWriteArraySet) BoundingBox(org.bboxdb.commons.math.BoundingBox) CountDownLatch(java.util.concurrent.CountDownLatch) ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) DistributionRegionEvent(org.bboxdb.distribution.region.DistributionRegionEvent) BBoxDBException(org.bboxdb.misc.BBoxDBException) DistributionGroupAdapter(org.bboxdb.distribution.zookeeper.DistributionGroupAdapter) DistributionRegionSyncer(org.bboxdb.distribution.region.DistributionRegionSyncer) DistributionRegionAdapter(org.bboxdb.distribution.zookeeper.DistributionRegionAdapter) DistributionGroupConfiguration(org.bboxdb.storage.entity.DistributionGroupConfiguration) Assert(org.junit.Assert) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) Before(org.junit.Before) DistributionRegionCallback(org.bboxdb.distribution.region.DistributionRegionCallback) BoundingBox(org.bboxdb.commons.math.BoundingBox) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 22 with BoundingBox

use of org.bboxdb.commons.math.BoundingBox 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 23 with BoundingBox

use of org.bboxdb.commons.math.BoundingBox in project bboxdb by jnidzwetzki.

the class TestSampling method testSampling2.

/**
 * Test the sampling (without tuples)
 * @throws RejectedException
 * @throws StorageManagerException
 * @throws BBoxDBException
 */
@Test(timeout = 60000)
public void testSampling2() throws StorageManagerException, RejectedException, BBoxDBException {
    storageRegistry.createTable(TEST_RELATION, new TupleStoreConfiguration());
    final DistributionRegion rootNode = SpacePartitionerCache.getInstance().getSpacePartitionerForGroupName(TEST_GROUP).getRootNode();
    final Collection<BoundingBox> samples = SamplingHelper.getSamplesForRegion(rootNode, storageRegistry);
    Assert.assertTrue(samples.isEmpty());
}
Also used : DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) BoundingBox(org.bboxdb.commons.math.BoundingBox) Test(org.junit.Test)

Example 24 with BoundingBox

use of org.bboxdb.commons.math.BoundingBox 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 25 with BoundingBox

use of org.bboxdb.commons.math.BoundingBox in project bboxdb by jnidzwetzki.

the class TestNetworkClasses method testDecodeBoundingBoxQuery.

/**
 * Test decode bounding box query
 * @throws IOException
 * @throws PackageEncodeException
 */
@Test(timeout = 60000)
public void testDecodeBoundingBoxQuery() throws IOException, PackageEncodeException {
    final String table = "table1";
    final BoundingBox boundingBox = new BoundingBox(10d, 20d);
    final short sequenceNumber = sequenceNumberGenerator.getNextSequenceNummber();
    final QueryBoundingBoxRequest queryRequest = new QueryBoundingBoxRequest(sequenceNumber, ROUTING_HEADER_ROUTED, table, boundingBox, false, (short) 10);
    byte[] encodedPackage = networkPackageToByte(queryRequest);
    Assert.assertNotNull(encodedPackage);
    final ByteBuffer bb = NetworkPackageDecoder.encapsulateBytes(encodedPackage);
    boolean result = NetworkPackageDecoder.validateRequestPackageHeader(bb, NetworkConst.REQUEST_TYPE_QUERY);
    Assert.assertTrue(result);
    final QueryBoundingBoxRequest decodedPackage = QueryBoundingBoxRequest.decodeTuple(bb);
    Assert.assertEquals(queryRequest.getBoundingBox(), decodedPackage.getBoundingBox());
    Assert.assertEquals(queryRequest.getTable(), decodedPackage.getTable());
    Assert.assertEquals(queryRequest.isPagingEnabled(), decodedPackage.isPagingEnabled());
    Assert.assertEquals(queryRequest.getTuplesPerPage(), decodedPackage.getTuplesPerPage());
    Assert.assertEquals(NetworkConst.REQUEST_QUERY_BBOX, NetworkPackageDecoder.getQueryTypeFromRequest(bb));
    Assert.assertEquals(queryRequest.toString(), decodedPackage.toString());
}
Also used : QueryBoundingBoxRequest(org.bboxdb.network.packages.request.QueryBoundingBoxRequest) BoundingBox(org.bboxdb.commons.math.BoundingBox) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Aggregations

BoundingBox (org.bboxdb.commons.math.BoundingBox)194 Test (org.junit.Test)113 Tuple (org.bboxdb.storage.entity.Tuple)61 ArrayList (java.util.ArrayList)25 JoinedTuple (org.bboxdb.storage.entity.JoinedTuple)24 DeletedTuple (org.bboxdb.storage.entity.DeletedTuple)23 BBoxDBException (org.bboxdb.misc.BBoxDBException)22 DistributionRegion (org.bboxdb.distribution.region.DistributionRegion)20 TupleStoreName (org.bboxdb.storage.entity.TupleStoreName)16 List (java.util.List)15 DistributionRegionIdMapper (org.bboxdb.distribution.region.DistributionRegionIdMapper)13 ZookeeperException (org.bboxdb.distribution.zookeeper.ZookeeperException)13 TupleStoreConfiguration (org.bboxdb.storage.entity.TupleStoreConfiguration)13 TupleListFuture (org.bboxdb.network.client.future.TupleListFuture)12 ZookeeperNotFoundException (org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException)11 EmptyResultFuture (org.bboxdb.network.client.future.EmptyResultFuture)11 IOException (java.io.IOException)10 Date (java.util.Date)10 DoubleInterval (org.bboxdb.commons.math.DoubleInterval)10 SpatialIndexReadOperator (org.bboxdb.storage.queryprocessor.operator.SpatialIndexReadOperator)10