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;
}
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)));
}
}
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());
}
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());
}
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());
}
Aggregations