当前位置: 首页>>代码示例>>Java>>正文


Java PhTree.put方法代码示例

本文整理汇总了Java中ch.ethz.globis.phtree.PhTree.put方法的典型用法代码示例。如果您正苦于以下问题:Java PhTree.put方法的具体用法?Java PhTree.put怎么用?Java PhTree.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ch.ethz.globis.phtree.PhTree的用法示例。


在下文中一共展示了PhTree.put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
 
开发者ID:tzaeschke,项目名称:phtree,代码行数:26,代码来源:TestIndexQueries.java

示例2: testNN1EmptyResultError

import ch.ethz.globis.phtree.PhTree; //导入方法依赖的package包/类
/**
 * This used to return an empty result set.
 */
@Test
public void testNN1EmptyResultError() {
	long[][] data = {
			{47, 15, 53, },
			{54, 77, 77, },
			{73, 62, 95, },
	};

	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], data[i]);
	}

	long[] v={44, 84, 75};
	double dist = 20;
	long[] exp = rangeQuery(ind, dist, v).get(0);
	List<long[]> nnList = toList(ind.rangeQuery(dist, v));
	assertTrue(!nnList.isEmpty());
	long[] nn = nnList.get(0);
	check(v, exp, nn);
}
 
开发者ID:tzaeschke,项目名称:phtree,代码行数:27,代码来源:TestRangeQuery.java

示例3: testNN1EmptyResultError

import ch.ethz.globis.phtree.PhTree; //导入方法依赖的package包/类
/**
 * This used to return an empty result set.
 */
@Test
public void testNN1EmptyResultError() {
	long[][] data = {
			{47, 15, 53, },
			{54, 77, 77, },
			{73, 62, 95, },
	};

	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], data[i]);
	}
	
	long[] v={44, 84, 75};
	long[] exp = nearestNeighbor1(ind, v);
	List<long[]> nnList = toList(ind.nearestNeighbour(1, v));
	assertTrue(!nnList.isEmpty());
	long[] nn = nnList.get(0);
	check(v, exp, nn);
}
 
开发者ID:tzaeschke,项目名称:phtree,代码行数:26,代码来源:TestNearestNeighbour.java

示例4: performMeasurement

import ch.ethz.globis.phtree.PhTree; //导入方法依赖的package包/类
public static void performMeasurement(PhTree<Object> index, List<long[]> entries) {
    long start = System.currentTimeMillis();

    for (long[] entry :  entries) {
        index.put(entry, null);
    }
    long end = System.currentTimeMillis();

    long duration = end - start;
    double durationInSeconds = duration / 1000.0;
    int nrEntries = entries.size();

    System.out.println("Inserted " + nrEntries + " entries in " + durationInSeconds + " seconds." );
}
 
开发者ID:tzaeschke,项目名称:distributed-phtree,代码行数:15,代码来源:InsertionBenchmark.java

示例5: testNeighbour1of4

import ch.ethz.globis.phtree.PhTree; //导入方法依赖的package包/类
@Test
public void testNeighbour1of4() {
	PhTree<long[]> idx = TestUtil.newTree(2, 8);
	idx.put(new long[]{2,2}, new long[]{2,2});
	idx.put(new long[]{1,1}, new long[]{1,1});
	idx.put(new long[]{1,3}, new long[]{1,3});
	idx.put(new long[]{3,1}, new long[]{3,1});
	
	List<long[]> result = toList(idx.nearestNeighbour(1, 3, 3));
	check(8, result.get(0), 2, 2);
	assertEquals(1, result.size());
}
 
开发者ID:tzaeschke,项目名称:phtree,代码行数:13,代码来源:TestNearestNeighbour.java

示例6: createTree

import ch.ethz.globis.phtree.PhTree; //导入方法依赖的package包/类
private static <V> PhTree<long[]> createTree(int dim, PhKnnQuery<V> entries) {
	PhTree<long[]> tree = PhTree.create(dim);
	while (entries.hasNext()) {
		long[] key = entries.nextKey();
		tree.put(key, key);
	}
	return tree;
}
 
开发者ID:tzaeschke,项目名称:distributed-phtree,代码行数:9,代码来源:MultidimUtil.java

示例7: testDirectHit

import ch.ethz.globis.phtree.PhTree; //导入方法依赖的package包/类
@Test
public void testDirectHit() {
	PhTree<long[]> idx = TestUtil.newTree(2, 8);
	idx.put(new long[]{2,2}, new long[]{2,2});
	idx.put(new long[]{1,1}, new long[]{1,1});
	idx.put(new long[]{1,3}, new long[]{1,3});
	idx.put(new long[]{3,1}, new long[]{3,1});

	List<long[]> result = toList(idx.rangeQuery(0, 3, 3));
	assertTrue(result.isEmpty());

	result = toList(idx.rangeQuery(1, 2, 2));
	assertEquals(1, result.size());
	check(8, result.get(0), 2, 2);

	result = toList(idx.rangeQuery(1, 1, 1));
	assertEquals(1, result.size());
	check(8, result.get(0), 1, 1);

	result = toList(idx.rangeQuery(1, 1, 3));
	assertEquals(1, result.size());
	check(8, result.get(0), 1, 3);

	result = toList(idx.rangeQuery(1, 3, 1));
	assertEquals(1, result.size());
	check(8, result.get(0), 3, 1);
}
 
开发者ID:tzaeschke,项目名称:phtree,代码行数:28,代码来源:TestRangeQuery.java

示例8: testNeighbour1of5DirectHit

import ch.ethz.globis.phtree.PhTree; //导入方法依赖的package包/类
@Test
public void testNeighbour1of5DirectHit() {
	PhTree<long[]> idx = TestUtil.newTree(2, 8);
	idx.put(new long[]{3,3}, new long[]{3,3});
	idx.put(new long[]{2,2}, new long[]{2,2});
	idx.put(new long[]{1,1}, new long[]{1,1});
	idx.put(new long[]{1,3}, new long[]{1,3});
	idx.put(new long[]{3,1}, new long[]{3,1});

	List<long[]> result = toList(idx.rangeQuery(1, 3, 3));
	check(8, result.get(0), 3, 3);
	assertEquals(1, result.size());
}
 
开发者ID:tzaeschke,项目名称:phtree,代码行数:14,代码来源:TestRangeQuery.java

示例9: testDeleteSingle

import ch.ethz.globis.phtree.PhTree; //导入方法依赖的package包/类
@Test
public void testDeleteSingle() {
	PhTree<long[]> ind = create(3, 32);
	Random R = new Random(0);
	for (int i = 0; i < 100000; i++) {
		long[] v = new long[]{R.nextInt(), R.nextInt(), R.nextInt()};
		//System.out.println("i=" + i + "  " + Bits.toBinary(v, 32));
		ind.put(v, v);
		assertTrue(ind.contains(v));
		assertNotNull(ind.remove(v));
		assertFalse(ind.contains(v));
	}
}
 
开发者ID:tzaeschke,项目名称:phtree,代码行数:14,代码来源:TestIndexDeletion.java

示例10: testDirectHit

import ch.ethz.globis.phtree.PhTree; //导入方法依赖的package包/类
@Test
public void testDirectHit() {
	PhTree<long[]> idx = TestUtil.newTree(2, 8);
	idx.put(new long[]{2,2}, new long[]{2,2});
	idx.put(new long[]{1,1}, new long[]{1,1});
	idx.put(new long[]{1,3}, new long[]{1,3});
	idx.put(new long[]{3,1}, new long[]{3,1});
	
	List<long[]> result = toList(idx.nearestNeighbour(0, 3, 3));
	assertTrue(result.isEmpty());
	
	result = toList(idx.nearestNeighbour(1, 2, 2));
	assertEquals(1, result.size());
	check(8, result.get(0), 2, 2);
	
	result = toList(idx.nearestNeighbour(1, 1, 1));
	assertEquals(1, result.size());
	check(8, result.get(0), 1, 1);
	
	result = toList(idx.nearestNeighbour(1, 1, 3));
	assertEquals(1, result.size());
	check(8, result.get(0), 1, 3);
	
	result = toList(idx.nearestNeighbour(1, 3, 1));
	assertEquals(1, result.size());
	check(8, result.get(0), 3, 1);
}
 
开发者ID:tzaeschke,项目名称:phtree,代码行数:28,代码来源:TestNearestNeighbour.java

示例11: 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());
}
 
开发者ID:tzaeschke,项目名称:phtree,代码行数:15,代码来源:TestIndexQueries.java

示例12: 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());
	}
}
 
开发者ID:tzaeschke,项目名称:phtree,代码行数:33,代码来源:TestIndexQueries.java

示例13: 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());
}
 
开发者ID:tzaeschke,项目名称:phtree,代码行数:49,代码来源:TestIndexQueries.java

示例14: 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);
}
 
开发者ID:tzaeschke,项目名称:phtree,代码行数:67,代码来源:TestNearestNeighbour.java

示例15: testFind16Hosts_Across1

import ch.ethz.globis.phtree.PhTree; //导入方法依赖的package包/类
/**
 * Configuration presented below:
 *
 +----+----+----+----+
 |    |    |    |    |
 |    |    |    |    |
 +--------------B----+
 |    |    |    |    |
 |    |    |    |    |
 +---------Q----AC---+
 |    |    |    |    |
 |    |    |    |    |
 +-------------------+
 |    |    |    |    |
 |    |    |    |    |
 +----+----+----+----+
 *  The space is split evenly between 16 hosts and the points contained are A, B and C. Q is the query point
 *  for kNN but it is not stored.
 *
 *  dist(Q, A) = side
 *  dist(Q, B) = side * sqrt(2)
 *  dist(Q, C) = side + 1
 *
 *  The two nearest neighbours of Q are A and C.
 */
@Test
public void testFind16Hosts_Across1() {
    phTree.create(2, BIT_WIDTH);
    PhTree<Object> tree = new DistributedPhTreeV<>(phTree);
    long side = SQUARE_SIDE;
    long[] A = {side, 0};
    long[] B = {side, side};
    long[] C = {side + 1, 0};
    long[] Q = {0, 0};
    assertTrue("Configuration not set up properly. C should be closer to Q than B.", metric.dist(Q, B) > metric.dist(Q, C));

    tree.put(A, A);
    tree.put(B, B);
    tree.put(C, C);

    List<long[]> result = MultidimUtil.knnToList(tree.nearestNeighbour(2, Q));
    assertEquals(2, result.size());
    checkContains(result, C);
    checkContains(result, A);
}
 
开发者ID:tzaeschke,项目名称:distributed-phtree,代码行数:46,代码来源:TestNearestNeighbours.java


注:本文中的ch.ethz.globis.phtree.PhTree.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。