use of org.bboxdb.distribution.partitioner.regionsplit.SplitpointStrategy in project bboxdb by jnidzwetzki.
the class KDtreeSpacePartitioner method splitRegion.
/**
* Split the node at the given position
* @param regionToSplit
* @param splitPosition
* @throws ZookeeperException
* @throws ResourceAllocationException
* @throws ZookeeperNotFoundException
*/
@Override
public List<DistributionRegion> splitRegion(final DistributionRegion regionToSplit, final Collection<BoundingBox> samples) throws BBoxDBException {
try {
final SplitpointStrategy splitpointStrategy = new SamplingBasedSplitStrategy(samples);
final int splitDimension = getSplitDimension(regionToSplit);
final BoundingBox regionBox = regionToSplit.getConveringBox();
final double splitPosition = splitpointStrategy.getSplitPoint(splitDimension, regionBox);
splitNode(regionToSplit, splitPosition);
return regionToSplit.getDirectChildren();
} catch (Exception e) {
throw new BBoxDBException(e);
}
}
use of org.bboxdb.distribution.partitioner.regionsplit.SplitpointStrategy in project bboxdb by jnidzwetzki.
the class TestSampling method testSamplingBasedSplitStrategy1.
/**
* Test the sampling
* @throws RejectedException
* @throws StorageManagerException
* @throws BBoxDBException
*/
@Test(timeout = 60000)
public void testSamplingBasedSplitStrategy1() throws StorageManagerException, RejectedException, BBoxDBException {
createDummyTable();
final DistributionRegion rootNode = SpacePartitionerCache.getInstance().getSpacePartitionerForGroupName(TEST_GROUP).getRootNode();
final Collection<BoundingBox> samples = SamplingHelper.getSamplesForRegion(rootNode, storageRegistry);
Assert.assertFalse(samples.isEmpty());
final SplitpointStrategy splitpointStrategy = new SamplingBasedSplitStrategy(samples);
final BoundingBox coveringBox1 = new BoundingBox(1d, 2d, -1d, 20d);
final double splitPoint0 = splitpointStrategy.getSplitPoint(0, coveringBox1);
final double splitPoint1 = splitpointStrategy.getSplitPoint(1, coveringBox1);
Assert.assertTrue(coveringBox1.isCoveringPointInDimension(splitPoint0, 0));
Assert.assertTrue(coveringBox1.isCoveringPointInDimension(splitPoint1, 1));
final BoundingBox coveringBox2 = new BoundingBox(1.5d, 2d, -1d, 20d);
final double splitPoint02 = splitpointStrategy.getSplitPoint(0, coveringBox2);
final double splitPoint12 = splitpointStrategy.getSplitPoint(1, coveringBox2);
Assert.assertTrue(coveringBox1.isCoveringPointInDimension(splitPoint02, 0));
Assert.assertTrue(coveringBox1.isCoveringPointInDimension(splitPoint12, 1));
final BoundingBox coveringBox3 = new BoundingBox(-1.5d, 2d, -1d, 20d);
final double splitPoint03 = splitpointStrategy.getSplitPoint(0, coveringBox3);
final double splitPoint13 = splitpointStrategy.getSplitPoint(1, coveringBox3);
Assert.assertTrue(coveringBox1.isCoveringPointInDimension(splitPoint03, 0));
Assert.assertTrue(coveringBox1.isCoveringPointInDimension(splitPoint13, 1));
}
use of org.bboxdb.distribution.partitioner.regionsplit.SplitpointStrategy in project bboxdb by jnidzwetzki.
the class TestSampling method testSimpleSplitpointStrategy1.
/**
* Test the simple splitpoint strategy
* @throws StorageManagerException
*/
@Test(timeout = 60000)
public void testSimpleSplitpointStrategy1() throws StorageManagerException {
final SplitpointStrategy splitpointStrategy = new SimpleSplitStrategy();
final BoundingBox coveringBox = new BoundingBox(1d, 2d, -1d, 20d);
final double splitPoint0 = splitpointStrategy.getSplitPoint(0, coveringBox);
final double splitPoint1 = splitpointStrategy.getSplitPoint(1, coveringBox);
Assert.assertTrue(coveringBox.isCoveringPointInDimension(splitPoint0, 0));
Assert.assertTrue(coveringBox.isCoveringPointInDimension(splitPoint1, 1));
}
use of org.bboxdb.distribution.partitioner.regionsplit.SplitpointStrategy in project bboxdb by jnidzwetzki.
the class TestSampling method testSamplingBasedSplitStrategy2.
/**
* Test the sampling
* @throws RejectedException
* @throws StorageManagerException
* @throws BBoxDBException
*/
@Test(expected = StorageManagerException.class)
public void testSamplingBasedSplitStrategy2() throws StorageManagerException, RejectedException, BBoxDBException {
createDummyTable();
final DistributionRegion rootNode = SpacePartitionerCache.getInstance().getSpacePartitionerForGroupName(TEST_GROUP).getRootNode();
final Collection<BoundingBox> samples = SamplingHelper.getSamplesForRegion(rootNode, storageRegistry);
Assert.assertFalse(samples.isEmpty());
final SplitpointStrategy splitpointStrategy = new SamplingBasedSplitStrategy(samples);
final BoundingBox coveringBox = new BoundingBox(10d, 20d, -1d, 20d);
final double splitPoint0 = splitpointStrategy.getSplitPoint(0, coveringBox);
final double splitPoint1 = splitpointStrategy.getSplitPoint(1, coveringBox);
System.out.println("Split point0: " + splitPoint0);
System.out.println("Split point1: " + splitPoint1);
Assert.assertTrue(coveringBox.isCoveringPointInDimension(splitPoint0, 0));
Assert.assertTrue(coveringBox.isCoveringPointInDimension(splitPoint1, 1));
}
use of org.bboxdb.distribution.partitioner.regionsplit.SplitpointStrategy in project bboxdb by jnidzwetzki.
the class DynamicgridSpacePartitioner method splitRegion.
@Override
public List<DistributionRegion> splitRegion(final DistributionRegion regionToSplit, final Collection<BoundingBox> samples) throws BBoxDBException {
try {
final SplitpointStrategy splitpointStrategy = new SamplingBasedSplitStrategy(samples);
final BoundingBox regionBox = regionToSplit.getConveringBox();
final double splitPosition = splitpointStrategy.getSplitPoint(0, regionBox);
splitNode(regionToSplit, splitPosition);
return regionToSplit.getDirectChildren();
} catch (Exception e) {
throw new BBoxDBException(e);
}
}
Aggregations