當前位置: 首頁>>代碼示例>>Java>>正文


Java PhKnnQuery類代碼示例

本文整理匯總了Java中ch.ethz.globis.phtree.PhTree.PhKnnQuery的典型用法代碼示例。如果您正苦於以下問題:Java PhKnnQuery類的具體用法?Java PhKnnQuery怎麽用?Java PhKnnQuery使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PhKnnQuery類屬於ch.ethz.globis.phtree.PhTree包,在下文中一共展示了PhKnnQuery類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: radiusSearch

import ch.ethz.globis.phtree.PhTree.PhKnnQuery; //導入依賴的package包/類
@Override
public <V> PhKnnQuery<V> radiusSearch(String initialHost, long[] key, int k, 
		List<long[]> candidates, PHTreeIndexProxy<V> indexProxy) {
    long[] farthestNeighbor = candidates.get(k - 1);
    long distance = MultidimUtil.computeDistance(key, farthestNeighbor);
    long[] start = MultidimUtil.transpose(key, -distance);
    long[] end = MultidimUtil.transpose(key, distance);
    PhDistance measure = new PhDistanceF();
    double dist = measure.dist(key, farthestNeighbor);

    List<long[]> extendedCandidates = indexProxy.getRange(initialHost, start, end, dist);

    extendedCandidates.addAll(candidates);

    return MultidimUtil.nearestNeighbours(key, k, extendedCandidates);
}
 
開發者ID:tzaeschke,項目名稱:distributed-phtree,代碼行數:17,代碼來源:RangeFilteredKNNRadiusStrategy.java

示例2: radiusSearch

import ch.ethz.globis.phtree.PhTree.PhKnnQuery; //導入依賴的package包/類
/**
 * Perform a radius search to check if there are any neighbours nearer to the query point than the
 * neighbours found on the query host server.
 *
 * This is done using a range search.
 *
 * @param key                       The key to be used as query.
 * @param k                         The number of neighbours to be returned.
 * @param candidates                The nearest neighbours on the query point's host server.
 * @return                          The k nearest neighbour points.
 */
@Override
public <V> PhKnnQuery<V> radiusSearch(String initialHost, long[] key, int k, 
		List<long[]> candidates, PHTreeIndexProxy<V> indexProxy) {
    long[] farthestNeighbor = candidates.get(k - 1);
    long distance = MultidimUtil.computeDistance(key, farthestNeighbor);
    long[] start = MultidimUtil.transpose(key, -distance);
    long[] end = MultidimUtil.transpose(key, distance);
    KeyMapping<long[]> mapping = indexProxy.getMapping();

    //make sure to not query the first host twice
    List<String> hostIds = mapping.get(start, end);
    hostIds.remove(initialHost);
    if (hostIds.size() == 0) {
        return new MultidimUtil.KnnFromList<V>(candidates, indexProxy);
    }

    List<long[]> expandedCandidates = 
    		MultidimUtil.knnToList(indexProxy.getNearestNeighbors(hostIds, key, k));

    //add the points we retrieved from the initial call since we didn't query that host again
    expandedCandidates.addAll(candidates);

    return MultidimUtil.nearestNeighbours(key, k, expandedCandidates);
}
 
開發者ID:tzaeschke,項目名稱:distributed-phtree,代碼行數:36,代碼來源:RangeHostsKNNRadiusStrategy.java

示例3: nearestNeighbours

import ch.ethz.globis.phtree.PhTree.PhKnnQuery; //導入依賴的package包/類
public static PhKnnQuery nearestNeighbours(long[] q, int k, List<long[]> points) {
	if (points.size() == 0) {
		return new EmptyPhKnnQuery<>();
	}
	PhTree<long[]> tree = createTree(points);
	return tree.nearestNeighbour(k, q);
}
 
開發者ID:tzaeschke,項目名稱:distributed-phtree,代碼行數:8,代碼來源:MultidimUtil.java

示例4: knnToList

import ch.ethz.globis.phtree.PhTree.PhKnnQuery; //導入依賴的package包/類
public static <V> List<long[]> knnToList(PhKnnQuery<V> knn) {
	ArrayList<long[]> ret = new ArrayList<>();
	while (knn.hasNext()) {
		ret.add(knn.nextKey());
	}
	return ret;
}
 
開發者ID:tzaeschke,項目名稱:distributed-phtree,代碼行數:8,代碼來源:MultidimUtil.java

示例5: createTree

import ch.ethz.globis.phtree.PhTree.PhKnnQuery; //導入依賴的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

示例6: createKeyList

import ch.ethz.globis.phtree.PhTree.PhKnnQuery; //導入依賴的package包/類
private IndexEntryList<long[], byte[]> createKeyList(PhKnnQuery<byte[]> keyList) {
    IndexEntryList<long[], byte[]> results = new IndexEntryList<>();
    while (keyList.hasNext()) {
        results.add(keyList.nextKey(), null);
    }
    return results;
}
 
開發者ID:tzaeschke,項目名稱:distributed-phtree,代碼行數:8,代碼來源:PhTreeRequestHandler.java

示例7: radiusSearch

import ch.ethz.globis.phtree.PhTree.PhKnnQuery; //導入依賴的package包/類
/**
 * Perform a radius search to check if there are any neighbours nearer to the query point than 
 * the neighbours found on the query host server.
 *
 * This is done using a knn search on hosts intersecting the range (q - r, q + r) .
 *
 * @param key                       The key to be used as query.
 * @param k                         The number of neighbours to be returned.
 * @param candidates                The nearest neighbours on the query point's host server.
 * @return                          The k nearest neighbour points.
 */

@Override
public <V> PhKnnQuery<V> radiusSearch(String initialHost, long[] key, int k, 
		List<long[]> candidates,
                                     PHTreeIndexProxy<V> indexProxy) {
    long[] farthestNeighbor = candidates.get(k - 1);
    long distance = MultidimUtil.computeDistance(key, farthestNeighbor);
    long[] start = MultidimUtil.transpose(key, -distance);
    long[] end = MultidimUtil.transpose(key, distance);


    return MultidimUtil.nearestNeighbours(key, k, 
    		indexProxy.combineKeys(indexProxy.getRange(start, end)));
}
 
開發者ID:tzaeschke,項目名稱:distributed-phtree,代碼行數:26,代碼來源:RangeKNNRadiusStrategy.java

示例8: getNearestNeighbors

import ch.ethz.globis.phtree.PhTree.PhKnnQuery; //導入依賴的package包/類
/**
 *  Find the k nearest neighbours of a query point from the hosts with the ids contained
 *  int the hostIds list.
 *
 * @param hostIds
 * @param key                       The key to be used as query.
 * @param k                         The number of neighbours to be returned.
 * @return                          The k nearest neighbours on the hosts.
 */
PhKnnQuery<V> getNearestNeighbors(Collection<String> hostIds, long[] key, int k) {
    logKNNRequest(hostIds, key, k);
    boolean versionOutdated;
    List<ResultResponse> responses;
    do {
        GetKNNRequest<long[]> request = requests.newGetKNN(key, k);
        responses = getRequestDispatcher().send(hostIds, request, ResultResponse.class);
        versionOutdated = check(request, responses);
    } while (versionOutdated);

    return MultidimUtil.nearestNeighbours(key, k, combineKeys(responses));
}
 
開發者ID:tzaeschke,項目名稱:distributed-phtree,代碼行數:22,代碼來源:PHTreeIndexProxy.java

示例9: getNearestNeighbors

import ch.ethz.globis.phtree.PhTree.PhKnnQuery; //導入依賴的package包/類
@Override
public PhKnnQuery<V> getNearestNeighbors(long[] key, int k, PHTreeIndexProxy<V> indexProxy) {
    LOG.debug("KNN request started for key={} and k={}", Arrays.toString(key), k);
    KeyMapping<long[]> keyMapping = indexProxy.getMapping();
    String keyHostId = keyMapping.get(key);
    List<long[]> candidates = getNearestNeighbors(keyHostId, key, k, indexProxy);
    PhKnnQuery<V> neighbours;
    if (candidates.size() < k) {
        neighbours = iterativeExpansion(keyMapping, key, k, indexProxy);
    } else {
        neighbours = radiusSearch(keyHostId, key, k, candidates, indexProxy);
    }
    LOG.debug("KNN request ended for key={} and k={}", Arrays.toString(key), k);
    return neighbours;
}
 
開發者ID:tzaeschke,項目名稱:distributed-phtree,代碼行數:16,代碼來源:ZMappingKNNStrategy.java

示例10: PhKnnQueryF

import ch.ethz.globis.phtree.PhTree.PhKnnQuery; //導入依賴的package包/類
protected PhKnnQueryF(PhKnnQuery<T> iter, int dims, PreProcessorPointF pre) {
	super(iter, dims, pre);
	this.dims = dims;
	q = iter;
	lCenter = new long[dims];
	buffer = new PhEntryDistF<>(new double[dims], null, Double.NaN); 
}
 
開發者ID:tzaeschke,項目名稱:phtree,代碼行數:8,代碼來源:PhTreeF.java

示例11: reset

import ch.ethz.globis.phtree.PhTree.PhKnnQuery; //導入依賴的package包/類
@Override
public PhKnnQuery<T> reset(int nMin, PhDistance dist, long... center) {
	this.distance = dist == null ? this.distance : dist;
	this.nMin = nMin;
	clearEntries();

	if (nMin > 0) {
		nearestNeighbourBinarySearch(center, nMin);
	}

	currentPos = 0;
	return this;
}
 
開發者ID:tzaeschke,項目名稱:phtree,代碼行數:14,代碼來源:PhQueryKnnMbbPP.java

示例12: reset

import ch.ethz.globis.phtree.PhTree.PhKnnQuery; //導入依賴的package包/類
@Override
public PhKnnQuery<T> reset(int nMin, PhDistance dist, long... center) {
	this.distance = dist == null ? this.distance : dist;
	this.nMin = nMin;
	
	if (nMin > 0) {
		results.reset(nMin, center);
		nearestNeighbourBinarySearch(center, nMin);
	} else {
		results.clear();
	}

	currentPos = 0;
	return this;
}
 
開發者ID:tzaeschke,項目名稱:phtree,代碼行數:16,代碼來源:PhQueryKnnMbbPPList.java

示例13: nearestNeighbour

import ch.ethz.globis.phtree.PhTree.PhKnnQuery; //導入依賴的package包/類
@Override
	public PhKnnQuery<long[]> nearestNeighbour(int nMin, long... v) {
//		ArrayList<long[]> ret = new ArrayList<>();
//		for (PhEntry<Object> e: ) {
//			ret.add(e.getKey());
//		}
//		return ret;
		throw new UnsupportedOperationException();
//		return tree.nearestNeighbour(nMin, v);
	}
 
開發者ID:tzaeschke,項目名稱:phtree,代碼行數:11,代碼來源:PhTreeVProxy.java

示例14: PhKnnQuerySF

import ch.ethz.globis.phtree.PhTree.PhKnnQuery; //導入依賴的package包/類
protected PhKnnQuerySF(PhKnnQuery<T> iter, int dims, PreProcessorRangeF pre) {
	super(iter, dims, pre);
	this.q = iter;
	this.qMIN = new double[dims];
	Arrays.fill(qMIN, Double.NEGATIVE_INFINITY);
	this.qMAX = new double[dims];
	Arrays.fill(qMAX, Double.POSITIVE_INFINITY);
	this.lCenterBuffer = new long[dims*2];
	this.dims = dims;
	this.pre = pre;
	this.buffer = new PhEntryDistSF<>(new double[dims], new double[dims], null, Double.NaN);
}
 
開發者ID:tzaeschke,項目名稱:phtree,代碼行數:13,代碼來源:PhTreeSolidF.java

示例15: toList

import ch.ethz.globis.phtree.PhTree.PhKnnQuery; //導入依賴的package包/類
private List<long[]> toList(PhKnnQuery<?> q) {
	ArrayList<long[]> ret = new ArrayList<>();
	while (q.hasNext()) {
		ret.add(q.nextKey());
	}
	return ret;
}
 
開發者ID:tzaeschke,項目名稱:phtree,代碼行數:8,代碼來源:TestNearestNeighbourF.java


注:本文中的ch.ethz.globis.phtree.PhTree.PhKnnQuery類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。