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


Java PhTree类代码示例

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


PhTree类属于ch.ethz.globis.phtree包,在下文中一共展示了PhTree类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: RectanglePHC

import ch.ethz.globis.phtree.PhTree; //导入依赖的package包/类
/**
 * Setup of a native PH tree
 * @param ts test stats
 */
public RectanglePHC(TestStats ts) {
	this.N = ts.cfgNEntries;
	this.dims = ts.cfgNDims;
	this.phc = PhTree.create(2*dims);
	this.pre = new PreProcessorRangeF.IEEE(dims);
	//this.pre = new PreProcessorRangeF.IPP(dims, 10e9);
	//distFn = new PhDistanceSFCenterDist(pre, dims);
	distFn = new PhDistanceSFEdgeDist(pre, dims);
	this.buffer = new long[2*dims];
	this.bufLow = new long[2*dims];
	this.bufUpp = new long[2*dims];
	this.qMIN = new double[dims];
	Arrays.fill(qMIN, Double.NEGATIVE_INFINITY);
	this.qMAX = new double[dims];
	Arrays.fill(qMAX, Double.POSITIVE_INFINITY);
}
 
开发者ID:tzaeschke,项目名称:TinSpin,代码行数:21,代码来源:RectanglePHC.java

示例2: PointPHC

import ch.ethz.globis.phtree.PhTree; //导入依赖的package包/类
/**
	 * Setup of a native PH tree
	 * 
	 * @param ts TestStats
	 */
	public PointPHC(TestStats ts) {
//		phc = new PhTree8<Object>(ts.cfgNDims);
		phc = PhTree.create(ts.cfgNDims);
//		Node.AHC_LHC_BIAS = 1*1000*1000;
//		Node.NT_THRESHOLD = 2*1000*1000;
//		PhTree11.HCI_ENABLED = true;
//		TestRunner.USE_NEW_QUERIES = false;
		this.N = ts.cfgNEntries;
		this.dims = ts.cfgNDims;
		this.S = ts;
		qMin = new long[dims];
		qMax = new long[dims];
		knnCenter = new long[dims];
		query = phc.query(qMin, qMax);
		knnQuery = phc.nearestNeighbour(1, knnCenter);
	}
 
开发者ID:tzaeschke,项目名称:TinSpin,代码行数:22,代码来源:PointPHC.java

示例3: init

import ch.ethz.globis.phtree.PhTree; //导入依赖的package包/类
@Setup
public void init() throws FileNotFoundException {

    //create a tree containing random entries
    int nrEntries = 10000;
    tree = PhTree.create(dim);

    long[] key = new long[dim];
    Random random = new Random();

    for (int i = 0; i < nrEntries; i++) {
        for (int j = 0; j < dim; j++) {
            key[j] = random.nextInt();
        }
        tree.put(key, Arrays.toString(key));
    }

    //serialize the tree so that de-serialization benchmark works every time
    FullTreeSerializer serializer = new FullTreeSerializer();
    serializer.export(tree, FULL_TREE_FILE);

    IterativeSerializer<String> itSerializer = new IterativeSerializer<String>();
    itSerializer.export(tree, ITERATIVE_TREE_FILE);
}
 
开发者ID:tzaeschke,项目名称:distributed-phtree,代码行数:25,代码来源:SerializationBenchmark.java

示例4: 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

示例5: exportPhTree

import ch.ethz.globis.phtree.PhTree; //导入依赖的package包/类
@Test
public void exportPhTree() throws FileNotFoundException {
    int dim = 6;
    int size = 100000;
    PhTree<String> tree = TestOperationsUtil.createRandomPhTree(size, dim);
    String filename = "tree.txt";
    IterativeSerializer<String> serializer = new IterativeSerializer<>();

    serializer.export(tree, filename);

    PhTree<String> outputTree = PhTree.create(dim);
    serializer.setTree(outputTree);

    PhTree<String> newTree = serializer.load(filename);

    assertEquals(tree.toStringPlain(), newTree.toStringPlain());
}
 
开发者ID:tzaeschke,项目名称:distributed-phtree,代码行数:18,代码来源:IterativeSerializerTest.java

示例6: 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

示例7: handleDelete

import ch.ethz.globis.phtree.PhTree; //导入依赖的package包/类
@Override
public Response handleDelete(DeleteRequest<long[]> request) {
    if (isVersionOutDate(request)|| currentlyBalancing()) {
        return createOutdateVersionResponse(request);
    }

    PhTree<byte[]> phTree = tree();
    long[] key = request.getKey();
    byte[] value;
    value = phTree.remove(key);

    if (value != null) {
        checkNeedForSizeUpdate();
    }
    IndexEntryList<long[], byte[]> results = new IndexEntryList<>(key, value);
    return createResponse(request, results);
}
 
开发者ID:tzaeschke,项目名称:distributed-phtree,代码行数:18,代码来源:PhTreeRequestHandler.java

示例8: handleUpdateKey

import ch.ethz.globis.phtree.PhTree; //导入依赖的package包/类
@Override
public Response handleUpdateKey(UpdateKeyRequest<long[]> request) {

    if (isVersionOutDate(request) || currentlyBalancing()) {
        return createOutdateVersionResponse(request);
    }
    long[] oldKey = request.getOldKey();
    long[] newKey = request.getNewKey();
    PhTree<byte[]> tree = tree();
    byte[] value;

    value = (byte[]) tree.update(oldKey, newKey);

    IndexEntryList<long[], byte[]> singleResult = new IndexEntryList<>(newKey, value);
    return createResponse(request, singleResult);
}
 
开发者ID:tzaeschke,项目名称:distributed-phtree,代码行数:17,代码来源:PhTreeRequestHandler.java

示例9: testNeighbour4_5of4

import ch.ethz.globis.phtree.PhTree; //导入依赖的package包/类
@Test
public void testNeighbour4_5of4() {
	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[]{4,4}, new long[]{4,4});
	idx.put(new long[]{2,4}, new long[]{2,4});
	idx.put(new long[]{4,2}, new long[]{4,2});

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

	checkContains(result, 3, 3);
	int n = 1;
	n += contains(result, 4, 4) ? 1 : 0;
	n += contains(result, 4, 2) ? 1 : 0;
	n += contains(result, 2, 2) ? 1 : 0;
	n += contains(result, 2, 4) ? 1 : 0;

	assertEquals(5, n);
}
 
开发者ID:tzaeschke,项目名称:phtree,代码行数:21,代码来源:TestRangeQuery.java

示例10: testFind16Hosts_NotEnough

import ch.ethz.globis.phtree.PhTree; //导入依赖的package包/类
@Test
public void testFind16Hosts_NotEnough() {
    phTree.create(2, BIT_WIDTH);
    PhTree<Object> tree = new DistributedPhTreeV<>(phTree);

    long side = SQUARE_SIDE;
    long[] A = {side * 2, 0};
    long[] B = {0, side * 2};

    long[] Q = {0, 0};

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

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

示例11: 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

示例12: serialize_FullTree

import ch.ethz.globis.phtree.PhTree; //导入依赖的package包/类
@Benchmark
public PhTree<String> serialize_FullTree(BenchmarkState state) throws FileNotFoundException {
    FullTreeSerializer serializer = new FullTreeSerializer();

    serializer.export(state.tree, FULL_TREE_FILE);

    return state.tree;
}
 
开发者ID:tzaeschke,项目名称:distributed-phtree,代码行数:9,代码来源:SerializationBenchmark.java

示例13: serialize_Iterative

import ch.ethz.globis.phtree.PhTree; //导入依赖的package包/类
@Benchmark
public PhTree<String> serialize_Iterative(BenchmarkState state) throws FileNotFoundException {
    IterativeSerializer<String> serializer = new IterativeSerializer<String>();

    serializer.export(state.tree, ITERATIVE_TREE_FILE);

    return state.tree;
}
 
开发者ID:tzaeschke,项目名称:distributed-phtree,代码行数:9,代码来源:SerializationBenchmark.java

示例14: deserialize_IterativeTree

import ch.ethz.globis.phtree.PhTree; //导入依赖的package包/类
@Benchmark
public PhTree<String> deserialize_IterativeTree(BenchmarkState state) throws FileNotFoundException {
    IterativeSerializer<String> serializer = new IterativeSerializer<String>();

    serializer.setTree(PhTree.create(state.dim));
    return serializer.load(ITERATIVE_TREE_FILE);
}
 
开发者ID:tzaeschke,项目名称:distributed-phtree,代码行数:8,代码来源:SerializationBenchmark.java

示例15: delete

import ch.ethz.globis.phtree.PhTree; //导入依赖的package包/类
protected String delete(BenchmarkState state) {
    PhTree<String> tree = state.getTree();

    int dim = tree.getDim();

    long[] key = createRandomKey(dim);
    return state.tree.remove(key);
}
 
开发者ID:tzaeschke,项目名称:distributed-phtree,代码行数:9,代码来源:ConcurrencyBenchmarkBase.java


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