de.lmu.ifi.dbs.elki.index.tree.metrical.mtreevariants.query
Class MetricalIndexKNNQuery<O,D extends Distance<D>>

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.database.query.AbstractDataBasedQuery<O>
      extended by de.lmu.ifi.dbs.elki.database.query.knn.AbstractDistanceKNNQuery<O,D>
          extended by de.lmu.ifi.dbs.elki.index.tree.metrical.mtreevariants.query.MetricalIndexKNNQuery<O,D>
Type Parameters:
O - Object type
D - Distance type
All Implemented Interfaces:
DatabaseQuery, KNNQuery<O,D>

public class MetricalIndexKNNQuery<O,D extends Distance<D>>
extends AbstractDistanceKNNQuery<O,D>

Instance of a KNN query for a particular spatial index.


Field Summary
protected  AbstractMTree<O,D,?,?> index
          The index to use
 
Fields inherited from class de.lmu.ifi.dbs.elki.database.query.knn.AbstractDistanceKNNQuery
distanceQuery
 
Fields inherited from class de.lmu.ifi.dbs.elki.database.query.AbstractDataBasedQuery
relation
 
Fields inherited from interface de.lmu.ifi.dbs.elki.database.query.DatabaseQuery
HINT_BULK, HINT_EXACT, HINT_HEAVY_USE, HINT_NO_CACHE, HINT_OPTIMIZED_ONLY, HINT_SINGLE
 
Constructor Summary
MetricalIndexKNNQuery(AbstractMTree<O,D,?,?> index, DistanceQuery<O,D> distanceQuery)
          Constructor.
 
Method Summary
protected  void doKNNQuery(O q, KNNHeap<D> knnList)
          Performs a k-nearest neighbor query for the given FeatureVector with the given parameter k and the according distance function.
 List<List<DistanceResultPair<D>>> getKNNForBulkDBIDs(ArrayDBIDs ids, int k)
          Bulk query method
 void getKNNForBulkHeaps(Map<DBID,KNNHeap<D>> heaps)
          Bulk query method configured by a map.
 List<DistanceResultPair<D>> getKNNForDBID(DBID id, int k)
          Get the k nearest neighbors for a particular id.
 List<DistanceResultPair<D>> getKNNForObject(O obj, int k)
          Get the k nearest neighbors for a particular id.
 
Methods inherited from class de.lmu.ifi.dbs.elki.database.query.knn.AbstractDistanceKNNQuery
getDistanceFactory, getDistanceQuery
 
Methods inherited from class de.lmu.ifi.dbs.elki.database.query.AbstractDataBasedQuery
getRelation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.lmu.ifi.dbs.elki.database.query.knn.KNNQuery
getRelation
 

Field Detail

index

protected final AbstractMTree<O,D extends Distance<D>,?,?> index
The index to use

Constructor Detail

MetricalIndexKNNQuery

public MetricalIndexKNNQuery(AbstractMTree<O,D,?,?> index,
                             DistanceQuery<O,D> distanceQuery)
Constructor.

Parameters:
index - Index to use
distanceQuery - Distance query used
Method Detail

doKNNQuery

protected final void doKNNQuery(O q,
                                KNNHeap<D> knnList)
Performs a k-nearest neighbor query for the given FeatureVector with the given parameter k and the according distance function. The query result is in ascending order to the distance to the query object.

Parameters:
q - the id of the query object
knnList - the query result list

getKNNForObject

public List<DistanceResultPair<D>> getKNNForObject(O obj,
                                                   int k)
Description copied from interface: KNNQuery
Get the k nearest neighbors for a particular id.

Specified by:
getKNNForObject in interface KNNQuery<O,D extends Distance<D>>
Specified by:
getKNNForObject in class AbstractDistanceKNNQuery<O,D extends Distance<D>>
Parameters:
obj - Query object
k - Number of neighbors requested
Returns:
neighbors

getKNNForDBID

public List<DistanceResultPair<D>> getKNNForDBID(DBID id,
                                                 int k)
Description copied from interface: KNNQuery
Get the k nearest neighbors for a particular id.

Specified by:
getKNNForDBID in interface KNNQuery<O,D extends Distance<D>>
Specified by:
getKNNForDBID in class AbstractDistanceKNNQuery<O,D extends Distance<D>>
Parameters:
id - query object ID
k - Number of neighbors requested
Returns:
neighbors

getKNNForBulkDBIDs

public List<List<DistanceResultPair<D>>> getKNNForBulkDBIDs(ArrayDBIDs ids,
                                                            int k)
Description copied from interface: KNNQuery
Bulk query method

Parameters:
ids - query object IDs
k - Number of neighbors requested
Returns:
neighbors

getKNNForBulkHeaps

public void getKNNForBulkHeaps(Map<DBID,KNNHeap<D>> heaps)
Description copied from interface: KNNQuery
Bulk query method configured by a map. Warning: this API is not optimal, and might be removed soon (in fact, it is used in a single place)

Parameters:
heaps - Map of heaps to fill.

Release 0.4.0 (2011-09-20_1324)