本文整理匯總了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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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)));
}
示例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));
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}