Search in sources :

Example 1 with SamplingBasedSplitStrategy

use of org.bboxdb.distribution.partitioner.regionsplit.SamplingBasedSplitStrategy 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);
    }
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) SamplingBasedSplitStrategy(org.bboxdb.distribution.partitioner.regionsplit.SamplingBasedSplitStrategy) BBoxDBException(org.bboxdb.misc.BBoxDBException) ZookeeperNotFoundException(org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException) ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) ResourceAllocationException(org.bboxdb.distribution.placement.ResourceAllocationException) BBoxDBException(org.bboxdb.misc.BBoxDBException) SplitpointStrategy(org.bboxdb.distribution.partitioner.regionsplit.SplitpointStrategy)

Example 2 with SamplingBasedSplitStrategy

use of org.bboxdb.distribution.partitioner.regionsplit.SamplingBasedSplitStrategy 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));
}
Also used : DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) BoundingBox(org.bboxdb.commons.math.BoundingBox) SamplingBasedSplitStrategy(org.bboxdb.distribution.partitioner.regionsplit.SamplingBasedSplitStrategy) SplitpointStrategy(org.bboxdb.distribution.partitioner.regionsplit.SplitpointStrategy) Test(org.junit.Test)

Example 3 with SamplingBasedSplitStrategy

use of org.bboxdb.distribution.partitioner.regionsplit.SamplingBasedSplitStrategy 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));
}
Also used : DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) BoundingBox(org.bboxdb.commons.math.BoundingBox) SamplingBasedSplitStrategy(org.bboxdb.distribution.partitioner.regionsplit.SamplingBasedSplitStrategy) SplitpointStrategy(org.bboxdb.distribution.partitioner.regionsplit.SplitpointStrategy) Test(org.junit.Test)

Example 4 with SamplingBasedSplitStrategy

use of org.bboxdb.distribution.partitioner.regionsplit.SamplingBasedSplitStrategy 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);
    }
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) SamplingBasedSplitStrategy(org.bboxdb.distribution.partitioner.regionsplit.SamplingBasedSplitStrategy) BBoxDBException(org.bboxdb.misc.BBoxDBException) ZookeeperNotFoundException(org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException) ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) InputParseException(org.bboxdb.commons.InputParseException) ResourceAllocationException(org.bboxdb.distribution.placement.ResourceAllocationException) BBoxDBException(org.bboxdb.misc.BBoxDBException) SplitpointStrategy(org.bboxdb.distribution.partitioner.regionsplit.SplitpointStrategy)

Aggregations

BoundingBox (org.bboxdb.commons.math.BoundingBox)4 SamplingBasedSplitStrategy (org.bboxdb.distribution.partitioner.regionsplit.SamplingBasedSplitStrategy)4 SplitpointStrategy (org.bboxdb.distribution.partitioner.regionsplit.SplitpointStrategy)4 ResourceAllocationException (org.bboxdb.distribution.placement.ResourceAllocationException)2 DistributionRegion (org.bboxdb.distribution.region.DistributionRegion)2 ZookeeperException (org.bboxdb.distribution.zookeeper.ZookeeperException)2 ZookeeperNotFoundException (org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException)2 BBoxDBException (org.bboxdb.misc.BBoxDBException)2 Test (org.junit.Test)2 InputParseException (org.bboxdb.commons.InputParseException)1