本文整理汇总了Java中ch.ethz.globis.phtree.PhTree.query方法的典型用法代码示例。如果您正苦于以下问题:Java PhTree.query方法的具体用法?Java PhTree.query怎么用?Java PhTree.query使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ch.ethz.globis.phtree.PhTree
的用法示例。
在下文中一共展示了PhTree.query方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testNullValues
import ch.ethz.globis.phtree.PhTree; //导入方法依赖的package包/类
@Test
public void testNullValues() {
PhTree<long[]> ind = create(2);
ind.put(new long[]{0, 0}, null);
ind.put(new long[]{1, 1}, new long[]{1, 1});
ind.put(new long[]{2, 2}, null);
//check empty result
Iterator<long[]> it;
//check full result
//it = ind.query(0, 50, 0, 50, 0, 50, 0, 50, 0, 50);
it = ind.query(new long[]{0, 0}, new long[]{50, 50});
assertNull(it.next());
assertNotNull(it.next());
assertNull(it.next());
assertFalse(it.hasNext());
//check extent
it = ind.queryExtent();
assertNull(it.next());
assertNotNull(it.next());
assertNull(it.next());
assertFalse(it.hasNext());
}
示例2: testQuerySingle_Bug1
import ch.ethz.globis.phtree.PhTree; //导入方法依赖的package包/类
@Test
public void testQuerySingle_Bug1() {
final int N = 20;
PhTree<long[]> ind = create(1, 16);
for (int i = 0; i < N; i++) {
long[] v = new long[]{i};
ind.put(v, v);
}
Iterator<long[]> it = ind.query(new long[]{N+1}, new long[]{250});
//This used to fail:
assertFalse(it.hasNext());
}
示例3: testQuerySingleRandomND_Bug1
import ch.ethz.globis.phtree.PhTree; //导入方法依赖的package包/类
/**
* Queries just hang ...
*/
@Test
public void testQuerySingleRandomND_Bug1() {
final int DIM = 5;
final int N = 4;
final int[][] R = {
{1119861723, 920690087, 884700943, 210555024, 328969292},
{1030398242, 594888813, 297670466, 504451821, 610952588},
{2119407664, 1802131665, 808099030, 1524428497, 1920740629},
{1891815476, 1332619371, 1095443318, 286253201, 336482252}
};
for (int d = 0; d < DIM; d++) {
PhTree<long[]> ind = create(DIM, 32);
for (int i = 0; i < N; i++) {
long[] v = new long[DIM];
for (int dd = 0; dd < DIM; dd++) {
v[dd] = Math.abs(R[i][dd]);
}
v[d] = i;
ind.put(v, v);
}
//check empty result
int MAX = Integer.MAX_VALUE;
Iterator<long[]> it = ind.query(new long[]{N+1, 0, 0, 0, 0},
new long[]{250, MAX, MAX, MAX, MAX});
assertFalse(it.hasNext());
}
}
示例4: testQueryHighD64Neg_6_1
import ch.ethz.globis.phtree.PhTree; //导入方法依赖的package包/类
@Test
public void testQueryHighD64Neg_6_1() {
final int N = 1;
final int DEPTH = 64;
final int DIM = 6;
Random R = new Random(0);
PhTree<long[]> ind = create(DIM, DEPTH);
long[] v = new long[DIM];
for (int j = 0; j < DIM; j++) {
v[j] = R.nextLong();
}
assertNull(Bits.toBinary(v, DEPTH), ind.put(v, v));
//check empty result
Iterator<long[]> it;
int n = 0;
long[] min = new long[DIM];
long[] max = new long[DIM];
//check full result
for (int i = 0; i < DIM; i++) {
min[i] = Long.MIN_VALUE;
max[i] = Long.MAX_VALUE;
}
it = ind.query(min, max);
for (int i = 0; i < N; i++) {
n++;
assertTrue("DIM=" + DIM + " i=" + i, it.hasNext());
long[] v2 = it.next();
assertNotNull(v2);
}
assertFalse(it.hasNext());
assertEquals(N, n);
}
示例5: testBugKeyNotFound
import ch.ethz.globis.phtree.PhTree; //导入方法依赖的package包/类
/**
* This used to return an empty result set.
*/
@Test
public void testBugKeyNotFound() {
long[][] data = {
{23, 35, 47, 85, 65, },
{39, 62, 7, 93, 96, },
{13, 99, 94, 31, 90, },
{47, 94, 89, 49, 68, },
{26, 38, 93, 16, 7, },
{57, 14, 93, 3, 42, },
{88, 14, 42, 76, 86, },
{86, 52, 28, 90, 98, },
{69, 74, 20, 58, 73, },
{79, 93, 58, 12, 73, },
// {15, 4, 34, 13, 9, },
};
final int DIM = data[0].length;
final int N = data.length;
PhTree<Object> ind = TestUtil.newTree(DIM, 16);
for (int i = 0; i < N; i++) {
ind.put(data[i], null);
}
ind.put(new long[]{15, 4, 34, 13, 9, }, null);
// long[] min = {8, -23, -1, -16, -18};
// long[] max = {55, 23, 45, 30, 28};
long[] min = {15, 4, 34, 13, 9};
long[] max = {15, 4, 34, 13, 9};
PhIterator<?> it = ind.query(min, max);
assertTrue(it.hasNext());
}
示例6: testQueryND64RandomPos
import ch.ethz.globis.phtree.PhTree; //导入方法依赖的package包/类
/**
* Testing only positive 64 bit values (effectively 63 bit).
*/
@Test
public void testQueryND64RandomPos() {
final int DIM = 5;
final int N = 100;
final Random R = new Random();
for (int d = 0; d < DIM; d++) {
PhTree<long[]> ind = create(DIM, 64);
for (int i = 0; i < N; i++) {
long[] v = new long[DIM];
for (int j = 0; j < DIM; j++) {
v[j] = Math.abs(R.nextLong());
}
ind.put(v, v);
}
//check empty result
Iterator<long[]> it;
//it = ind.query(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
it = ind.query(new long[]{0, 0, 0, 0, 0}, new long[]{0, 0, 0, 0, 0});
assertFalse(it.hasNext());
//check full result
// it = ind.query(0, Long.MAX_VALUE,
// 0, Long.MAX_VALUE,
// 0, Long.MAX_VALUE,
// 0, Long.MAX_VALUE,
// 0, Long.MAX_VALUE);
Long M = Long.MAX_VALUE;
it = ind.query(new long[]{0, 0, 0, 0, 0}, new long[]{M, M, M, M, M});
for (int i = 0; i < N; i++) {
it.next();
//System.out.println("v=" + Bits.toBinary(v, 64));
}
assertFalse(it.hasNext());
//check partial result
int n = 0;
// it = ind.query(0, Long.MAX_VALUE,
// 0, Long.MAX_VALUE,
// 0, Long.MAX_VALUE,
// 0, Long.MAX_VALUE,
// 0, Long.MAX_VALUE);
it = ind.query(new long[]{0, 0, 0, 0, 0}, new long[]{M, M, M, M, M});
while (it.hasNext()) {
n++;
it.next();
}
assertTrue("n=" + n, n > N/10.);
}
}
示例7: testPrecision
import ch.ethz.globis.phtree.PhTree; //导入方法依赖的package包/类
@Test
public void testPrecision() {
PhTree<long[]> ind = create(2, 8);
ind.put(new long[]{2,2}, new long[]{2,2});
ind.put(new long[]{1,1}, new long[]{1,1});
ind.put(new long[]{1,3}, new long[]{1,3});
ind.put(new long[]{3,1}, new long[]{3,1});
Iterator<long[]> it;
//check point with hit
it = ind.query(new long[]{2, 2}, new long[]{2, 2});
long[] v = it.next();
check(8, v, 2, 2);
assertFalse(it.hasNext());
it = ind.query(new long[]{2, 2}, new long[]{20, 20});
v = it.next();
check(8, v, 2, 2);
assertFalse(it.hasNext());
//check point without hit
it = ind.query(new long[]{3, 3}, new long[]{3, 3});
assertFalse(it.hasNext());
//check point without hit
it = ind.query(new long[]{3, 3}, new long[]{30, 30});
assertFalse(it.hasNext());
//check point without hit
it = ind.query(new long[]{3, 3}, new long[]{3, 3});
assertFalse(it.hasNext());
//check full result
it = ind.query(new long[]{1, 1}, new long[]{3, 3});
for (int i = 0; i < 4; i++) {
v = it.next();
//System.out.println("v=" + Bits.toBinary(v, 64));
assertNotNull(v);
}
assertFalse(it.hasNext());
}
示例8: testPrecisionDouble
import ch.ethz.globis.phtree.PhTree; //导入方法依赖的package包/类
@Test
public void testPrecisionDouble() {
PhTree<long[]> ind = create(2, 64);
ind.put( d2l(2,2), d2l(2,2) );
assertTrue(ind.contains(d2l(2,2)));
ind.put( d2l(1,1), d2l(1,1) );
assertTrue(ind.contains(d2l(2,2)));
assertTrue(ind.contains(d2l(1,1)));
ind.put( d2l(1,3), d2l(1,3) );
assertTrue(ind.contains(d2l(2,2)));
assertTrue(ind.contains(d2l(1,1)));
assertTrue(ind.contains(d2l(1,3)));
ind.put( d2l(3,1), d2l(3,1) );
assertTrue(ind.contains(d2l(2,2)));
assertTrue(ind.contains(d2l(1,1)));
assertTrue(ind.contains(d2l(1,3)));
assertTrue(ind.contains(d2l(3,1)));
Iterator<long[]> it;
//check point with hit
it = ind.query( d2l(2, 2), d2l(2, 2) );
long[] v = it.next();
check(64, v, d2l(2, 2) );
assertFalse(it.hasNext());
it = ind.query( d2l(2, 2), d2l(20, 20) );
v = it.next();
check(64, v, d2l(2, 2) );
assertFalse(it.hasNext());
//check point without hit
it = ind.query( d2l(3, 3), d2l(3, 3) );
assertFalse(it.hasNext());
//check point without hit
it = ind.query( d2l(3, 3), d2l(30, 30) );
assertFalse(it.hasNext());
//check full result
it = ind.query( d2l(1, 1), d2l(3, 3) );
for (int i = 0; i < 4; i++) {
v = it.next();
//System.out.println("v=" + Bits.toBinary(v, 64));
assertNotNull(v);
}
assertFalse(it.hasNext());
}
示例9: testPrecisionDoubleNeg
import ch.ethz.globis.phtree.PhTree; //导入方法依赖的package包/类
@Test
public void testPrecisionDoubleNeg() {
PhTree<long[]> ind = create(2, 64);
ind.put( d2l(2,2), d2l(2,2) );
ind.put( d2l(-1,-1), d2l(-1,-1) );
ind.put( d2l(-1,3), d2l(-1,3) );
ind.put( d2l(3,-1), d2l(3,-1) );
Iterator<long[]> it;
//check point with hit
it = ind.query( d2l(-1, -1), d2l(-1, -1) );
long[] v = it.next();
check(64, v, d2l(-1, -1) );
assertFalse(it.hasNext());
it = ind.query( d2l(-2, -2), d2l(-0.5, -0.5) );
v = it.next();
check(64, v, d2l(-1, -1) );
assertFalse(it.hasNext());
//check point without hit
it = ind.query( d2l(-3, -3), d2l(-3, -3) );
assertFalse(it.hasNext());
//check point without hit
it = ind.query( d2l(-0.5, -0.5), d2l(0, 0) );
assertFalse(it.hasNext());
//check partial result
it = ind.query( d2l(-1, -1), d2l(3, 1) );
for (int i = 0; i < 2; i++) {
v = it.next();
//System.out.println("v=" + Bits.toBinary(v, 64));
assertNotNull(v);
}
assertFalse(it.hasNext());
//check full result
it = ind.query( d2l(-1, -1), d2l(3, 3) );
for (int i = 0; i < 4; i++) {
v = it.next();
//System.out.println("v=" + Bits.toBinary(v, 64));
assertNotNull(v);
}
assertFalse(it.hasNext());
}
示例10: testQueryBugPos
import ch.ethz.globis.phtree.PhTree; //导入方法依赖的package包/类
@Test
public void testQueryBugPos() {
long[][] data = {
{6, 23, 48, 22, 52, },
{46, 73, 83, 30, 48, },
{90, 74, 60, 32, 47, },
{53, 35, 42, 47, 28, },
{81, 79, 54, 74, 2, },
{86, 52, 28, 90, 98, },
{15, 4, 34, 13, 9, },
{82, 86, 44, 51, 36, },
{88, 14, 42, 76, 86, },
{3, 84, 61, 66, 83, },
{23, 35, 47, 85, 65, },
{88, 28, 63, 72, 55, },
{13, 99, 94, 31, 90, },
{2, 29, 93, 40, 9, },
{16, 75, 71, 79, 66, },
{39, 62, 7, 93, 96, },
{95, 90, 68, 16, 26, },
{47, 94, 89, 49, 68, },
{74, 1, 6, 18, 2, },
{86, 73, 73, 56, 92, },
{26, 38, 93, 16, 7, },
{57, 14, 93, 3, 42, },
{42, 85, 17, 61, 34, },
{25, 44, 35, 60, 6, },
{68, 44, 1, 9, 7, },
{79, 93, 58, 12, 73, },
{69, 74, 20, 58, 73, },
{78, 47, 17, 54, 4, },
{32, 27, 80, 93, 5, },
{3, 8, 64, 15, 85, },
};
final int DIM = data[0].length;
final int N = data.length;
PhTree<Object> ind = TestUtil.newTree(DIM, 64);
for (int i = 0; i < N; i++) {
ind.put(data[i], null);
}
long[] exp = {15, 4, 34, 13, 9};
long[] min = {8, -23, -1, -16, -18};
long[] max = {55, 23, 45, 30, 28};
assertTrue(ind.contains(exp));
boolean fail = true;
PhIterator<?> pvi = ind.query(min, max);
while (pvi.hasNext()) {
long[] x = pvi.nextKey();
if (Arrays.equals(exp, x)) {
fail = false;
}
}
if (fail) {
fail();
}
long[] center = {32, 0, 22, 7, 5};
double dist = 30;
exp = rangeQuery(ind, dist, center).get(0);
List<long[]> lst = toList(ind.rangeQuery(dist, center));
long[] nn = lst.get(0);
assertArrayEquals(exp, nn);
assertEquals(1, lst.size());
}
示例11: testQueryBugPos
import ch.ethz.globis.phtree.PhTree; //导入方法依赖的package包/类
@Test
public void testQueryBugPos() {
long[][] data = {
{6, 23, 48, 22, 52, },
{46, 73, 83, 30, 48, },
{90, 74, 60, 32, 47, },
{53, 35, 42, 47, 28, },
{81, 79, 54, 74, 2, },
{86, 52, 28, 90, 98, },
{15, 4, 34, 13, 9, },
{82, 86, 44, 51, 36, },
{88, 14, 42, 76, 86, },
{3, 84, 61, 66, 83, },
{23, 35, 47, 85, 65, },
{88, 28, 63, 72, 55, },
{13, 99, 94, 31, 90, },
{2, 29, 93, 40, 9, },
{16, 75, 71, 79, 66, },
{39, 62, 7, 93, 96, },
{95, 90, 68, 16, 26, },
{47, 94, 89, 49, 68, },
{74, 1, 6, 18, 2, },
{86, 73, 73, 56, 92, },
{26, 38, 93, 16, 7, },
{57, 14, 93, 3, 42, },
{42, 85, 17, 61, 34, },
{25, 44, 35, 60, 6, },
{68, 44, 1, 9, 7, },
{79, 93, 58, 12, 73, },
{69, 74, 20, 58, 73, },
{78, 47, 17, 54, 4, },
{32, 27, 80, 93, 5, },
{3, 8, 64, 15, 85, },
};
final int DIM = data[0].length;
final int N = data.length;
PhTree<Object> ind = TestUtil.newTree(DIM, 64);
for (int i = 0; i < N; i++) {
ind.put(data[i], null);
}
long[] exp = {15, 4, 34, 13, 9};
long[] min = {8, -23, -1, -16, -18};
long[] max = {55, 23, 45, 30, 28};
assertTrue(ind.contains(exp));
boolean fail = true;
PhIterator<?> pvi = ind.query(min, max);
while (pvi.hasNext()) {
long[] x = pvi.nextKey();
if (Arrays.equals(exp, x)) {
fail = false;
}
}
if (fail) {
fail();
}
long[] center = {32, 0, 22, 7, 5};
exp = nearestNeighbor1(ind, center);
List<long[]> lst = toList(ind.nearestNeighbour(1, center));
long[] nn = lst.get(0);
assertArrayEquals(exp, nn);
}