de.lmu.ifi.dbs.elki.database.query.knn
Class LinearScanPrimitiveDistanceKNNQuery<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.database.query.knn.LinearScanKNNQuery<O,D>
              extended by de.lmu.ifi.dbs.elki.database.query.knn.LinearScanPrimitiveDistanceKNNQuery<O,D>
All Implemented Interfaces:
DatabaseQuery, KNNQuery<O,D>, LinearScanQuery
Direct Known Subclasses:
LinearScanRawDoubleDistanceKNNQuery

public class LinearScanPrimitiveDistanceKNNQuery<O,D extends Distance<D>>
extends LinearScanKNNQuery<O,D>

Instance of this query for a particular database. This is a subtle optimization: for primitive queries, it is clearly faster to retrieve the query object from the relation only once!


Field Summary
 
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
LinearScanPrimitiveDistanceKNNQuery(PrimitiveDistanceQuery<O,D> distanceQuery)
          Constructor.
 
Method Summary
 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.
protected  void linearScanBatchKNN(List<O> objs, List<KNNHeap<D>> heaps)
          Perform a linear scan batch kNN for primitive distance functions.
 
Methods inherited from class de.lmu.ifi.dbs.elki.database.query.knn.LinearScanKNNQuery
getKNNForObject
 
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
 

Constructor Detail

LinearScanPrimitiveDistanceKNNQuery

public LinearScanPrimitiveDistanceKNNQuery(PrimitiveDistanceQuery<O,D> distanceQuery)
Constructor.

Parameters:
distanceQuery - Distance function to use
Method Detail

linearScanBatchKNN

protected void linearScanBatchKNN(List<O> objs,
                                  List<KNNHeap<D>> heaps)
Perform a linear scan batch kNN for primitive distance functions.

Parameters:
objs - Objects list
heaps - Heaps array

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>>
Overrides:
getKNNForDBID in class LinearScanKNNQuery<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

Specified by:
getKNNForBulkDBIDs in interface KNNQuery<O,D extends Distance<D>>
Overrides:
getKNNForBulkDBIDs in class LinearScanKNNQuery<O,D extends Distance<D>>
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)

Specified by:
getKNNForBulkHeaps in interface KNNQuery<O,D extends Distance<D>>
Overrides:
getKNNForBulkHeaps in class LinearScanKNNQuery<O,D extends Distance<D>>
Parameters:
heaps - Map of heaps to fill.

Release 0.4.0 (2011-09-20_1324)