* @param knnLists a map containing the knn lists for each query objects
*/
protected void batchNN(AbstractRStarTreeNode<?, ?> node, Map<DBID, KNNHeap<D>> knnLists) {
if(node.isLeaf()) {
for(int i = 0; i < node.getNumEntries(); i++) {
SpatialEntry p = node.getEntry(i);
for(Entry<DBID, KNNHeap<D>> ent : knnLists.entrySet()) {
final DBID q = ent.getKey();
final KNNHeap<D> knns_q = ent.getValue();
D knn_q_maxDist = knns_q.getKNNDistance();
DBID pid = ((LeafEntry) p).getDBID();
// FIXME: objects are NOT accessible by DBID in a plain rtree context!
D dist_pq = distanceQuery.distance(pid, q);
if(dist_pq.compareTo(knn_q_maxDist) <= 0) {
knns_q.add(dist_pq, pid);
}
}
}
}
else {
ModifiableDBIDs ids = DBIDUtil.newArray(knnLists.size());
for(DBID id : knnLists.keySet()) {
ids.add(id);
}
List<DistanceEntry<D, SpatialEntry>> entries = getSortedEntries(node, ids);
for(DistanceEntry<D, SpatialEntry> distEntry : entries) {
D minDist = distEntry.getDistance();
for(Entry<DBID, KNNHeap<D>> ent : knnLists.entrySet()) {
final KNNHeap<D> knns_q = ent.getValue();
D knn_q_maxDist = knns_q.getKNNDistance();
if(minDist.compareTo(knn_q_maxDist) <= 0) {
SpatialEntry entry = distEntry.getEntry();
AbstractRStarTreeNode<?, ?> child = tree.getNode(((DirectoryEntry) entry).getPageID());
batchNN(child, knnLists);
break;
}
}