Search in sources :

Example 1 with RTree

use of org.apache.druid.collections.spatial.RTree in project druid by druid-io.

the class LinearGutmanSplitStrategyTest method testNumChildrenSizeRoaring.

@Test
public void testNumChildrenSizeRoaring() {
    BitmapFactory bf = new RoaringBitmapFactory();
    RTree tree = new RTree(2, new LinearGutmanSplitStrategy(0, 50, bf), bf);
    Random rand = ThreadLocalRandom.current();
    for (int i = 0; i < 100; i++) {
        tree.insert(new float[] { rand.nextFloat(), rand.nextFloat() }, i);
    }
    Assert.assertTrue(getNumPoints(tree.getRoot()) >= tree.getSize());
}
Also used : ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) Random(java.util.Random) BitmapFactory(org.apache.druid.collections.bitmap.BitmapFactory) ConciseBitmapFactory(org.apache.druid.collections.bitmap.ConciseBitmapFactory) RoaringBitmapFactory(org.apache.druid.collections.bitmap.RoaringBitmapFactory) RTree(org.apache.druid.collections.spatial.RTree) RoaringBitmapFactory(org.apache.druid.collections.bitmap.RoaringBitmapFactory) Point(org.apache.druid.collections.spatial.Point) Test(org.junit.Test)

Example 2 with RTree

use of org.apache.druid.collections.spatial.RTree in project druid by druid-io.

the class LinearGutmanSplitStrategyTest method testNumChildrenSize.

@Test
public void testNumChildrenSize() {
    BitmapFactory bf = new ConciseBitmapFactory();
    RTree tree = new RTree(2, new LinearGutmanSplitStrategy(0, 50, bf), bf);
    Random rand = ThreadLocalRandom.current();
    for (int i = 0; i < 100; i++) {
        tree.insert(new float[] { rand.nextFloat(), rand.nextFloat() }, i);
    }
    Assert.assertTrue(getNumPoints(tree.getRoot()) >= tree.getSize());
}
Also used : ConciseBitmapFactory(org.apache.druid.collections.bitmap.ConciseBitmapFactory) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) Random(java.util.Random) BitmapFactory(org.apache.druid.collections.bitmap.BitmapFactory) ConciseBitmapFactory(org.apache.druid.collections.bitmap.ConciseBitmapFactory) RoaringBitmapFactory(org.apache.druid.collections.bitmap.RoaringBitmapFactory) RTree(org.apache.druid.collections.spatial.RTree) Point(org.apache.druid.collections.spatial.Point) Test(org.junit.Test)

Aggregations

Random (java.util.Random)2 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)2 BitmapFactory (org.apache.druid.collections.bitmap.BitmapFactory)2 ConciseBitmapFactory (org.apache.druid.collections.bitmap.ConciseBitmapFactory)2 RoaringBitmapFactory (org.apache.druid.collections.bitmap.RoaringBitmapFactory)2 Point (org.apache.druid.collections.spatial.Point)2 RTree (org.apache.druid.collections.spatial.RTree)2 Test (org.junit.Test)2