use of org.apache.druid.collections.spatial.split.LinearGutmanSplitStrategy in project druid by druid-io.
the class RTreeTest method setUp.
@Before
public void setUp() {
BitmapFactory bf = new ConciseBitmapFactory();
tree = new RTree(2, new LinearGutmanSplitStrategy(0, 50, bf), bf);
BitmapFactory rbf = new RoaringBitmapFactory();
roaringtree = new RTree(2, new LinearGutmanSplitStrategy(0, 50, rbf), rbf);
}
use of org.apache.druid.collections.spatial.split.LinearGutmanSplitStrategy in project druid by druid-io.
the class ImmutableRTreeTest method testEmptyConciseSet.
@Test
public void testEmptyConciseSet() {
BitmapFactory bf = new ConciseBitmapFactory();
RTree tree = new RTree(2, new LinearGutmanSplitStrategy(0, 50, bf), bf);
tree.insert(new float[] { 0.0f, 0.0f }, bf.makeEmptyMutableBitmap());
ImmutableRTree searchTree = ImmutableRTree.newImmutableFromMutable(tree);
Iterable<ImmutableBitmap> points = searchTree.search(new RadiusBound(new float[] { 0.0f, 0.0f }, 5));
ImmutableBitmap finalSet = bf.union(points);
Assert.assertEquals(finalSet.size(), 0);
}
use of org.apache.druid.collections.spatial.split.LinearGutmanSplitStrategy in project druid by druid-io.
the class ImmutableRTreeTest method testEmptyRoaringBitmap.
@Test
public void testEmptyRoaringBitmap() {
BitmapFactory bf = new RoaringBitmapFactory();
RTree tree = new RTree(2, new LinearGutmanSplitStrategy(0, 50, bf), bf);
tree.insert(new float[] { 0.0f, 0.0f }, bf.makeEmptyMutableBitmap());
ImmutableRTree searchTree = ImmutableRTree.newImmutableFromMutable(tree);
Iterable<ImmutableBitmap> points = searchTree.search(new RadiusBound(new float[] { 0.0f, 0.0f }, 5));
ImmutableBitmap finalSet = bf.union(points);
Assert.assertEquals(finalSet.size(), 0);
Assert.assertTrue(finalSet.isEmpty());
}
use of org.apache.druid.collections.spatial.split.LinearGutmanSplitStrategy in project druid by druid-io.
the class ImmutableRTreeTest method testSearchWithSplit4.
@Test
public void testSearchWithSplit4() {
BitmapFactory bf = new ConciseBitmapFactory();
RTree tree = new RTree(2, new LinearGutmanSplitStrategy(0, 50, bf), bf);
Random rand = ThreadLocalRandom.current();
int outPolygon = 0, inPolygon = 0;
for (; inPolygon < 500; ) {
double abscissa = rand.nextDouble() * 5;
double ordinate = rand.nextDouble() * 4;
if (abscissa < 1 || abscissa > 4 || ordinate < 1 || ordinate > 3 || abscissa < 2 && ordinate > 2) {
tree.insert(new float[] { (float) abscissa, (float) ordinate }, outPolygon + 500);
outPolygon++;
} else if (abscissa > 1 && abscissa < 4 && ordinate > 1 && ordinate < 2 || abscissa > 2 && abscissa < 4 && ordinate >= 2 && ordinate < 3) {
tree.insert(new float[] { (float) abscissa, (float) ordinate }, inPolygon);
inPolygon++;
}
}
ImmutableRTree searchTree = ImmutableRTree.newImmutableFromMutable(tree);
Iterable<ImmutableBitmap> points = searchTree.search(PolygonBound.from(new float[] { 1.0f, 1.0f, 2.0f, 2.0f, 4.0f, 4.0f }, new float[] { 1.0f, 2.0f, 2.0f, 3.0f, 3.0f, 1.0f }));
ImmutableBitmap finalSet = bf.union(points);
Assert.assertTrue(finalSet.size() == 500);
Set<Integer> expected = new HashSet<>();
for (int i = 0; i < 500; i++) {
expected.add(i);
}
IntIterator iter = finalSet.iterator();
while (iter.hasNext()) {
Assert.assertTrue(expected.contains(iter.next()));
}
}
use of org.apache.druid.collections.spatial.split.LinearGutmanSplitStrategy in project druid by druid-io.
the class ImmutableRTreeTest method testSearchWithSplitLimitedBound.
@Test
public void testSearchWithSplitLimitedBound() {
BitmapFactory bf = new ConciseBitmapFactory();
RTree tree = new RTree(2, new LinearGutmanSplitStrategy(0, 50, bf), bf);
tree.insert(new float[] { 0, 0 }, 1);
tree.insert(new float[] { 1, 3 }, 2);
tree.insert(new float[] { 4, 2 }, 3);
tree.insert(new float[] { 5, 0 }, 4);
tree.insert(new float[] { -4, -3 }, 5);
Random rand = ThreadLocalRandom.current();
for (int i = 0; i < 4995; i++) {
tree.insert(new float[] { (float) (rand.nextDouble() * 10 + 10.0), (float) (rand.nextDouble() * 10 + 10.0) }, i);
}
ImmutableRTree searchTree = ImmutableRTree.newImmutableFromMutable(tree);
Iterable<ImmutableBitmap> points = searchTree.search(new RadiusBound(new float[] { 0, 0 }, 5, 2));
ImmutableBitmap finalSet = bf.union(points);
Assert.assertTrue(finalSet.size() >= 5);
Set<Integer> expected = Sets.newHashSet(1, 2, 3, 4, 5);
IntIterator iter = finalSet.iterator();
while (iter.hasNext()) {
Assert.assertTrue(expected.contains(iter.next()));
}
}
Aggregations