de.lmu.ifi.dbs.elki.database.query.knn
Class PreprocessorKNNQuery<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.PreprocessorKNNQuery<O,D>
All Implemented Interfaces:
DatabaseQuery, KNNQuery<O,D>

public class PreprocessorKNNQuery<O,D extends Distance<D>>
extends AbstractDataBasedQuery<O>
implements KNNQuery<O,D>

Instance for a particular database, invoking the preprocessor.


Field Summary
private  MaterializeKNNPreprocessor<O,D> preprocessor
          The last preprocessor result
private  boolean warned
          Warn only once.
 
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
PreprocessorKNNQuery(Relation<O> database, MaterializeKNNPreprocessor.Factory<O,D> preprocessor)
          Constructor.
PreprocessorKNNQuery(Relation<O> database, MaterializeKNNPreprocessor<O,D> preprocessor)
          Constructor.
 
Method Summary
 D getDistanceFactory()
          Get the distance data type of the function.
 DistanceQuery<O,D> getDistanceQuery()
          Get the distance query for this 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.
 AbstractMaterializeKNNPreprocessor<O,D> getPreprocessor()
          Get the preprocessor instance.
 
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

preprocessor

private final MaterializeKNNPreprocessor<O,D extends Distance<D>> preprocessor
The last preprocessor result


warned

private boolean warned
Warn only once.

Constructor Detail

PreprocessorKNNQuery

public PreprocessorKNNQuery(Relation<O> database,
                            MaterializeKNNPreprocessor<O,D> preprocessor)
Constructor.

Parameters:
database - Database to query
preprocessor - Preprocessor instance to use

PreprocessorKNNQuery

public PreprocessorKNNQuery(Relation<O> database,
                            MaterializeKNNPreprocessor.Factory<O,D> preprocessor)
Constructor.

Parameters:
database - Database to query
preprocessor - Preprocessor to use
Method Detail

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>>
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>>
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>>
Parameters:
heaps - Map of heaps to fill.

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>>
Parameters:
obj - Query object
k - Number of neighbors requested
Returns:
neighbors

getPreprocessor

public AbstractMaterializeKNNPreprocessor<O,D> getPreprocessor()
Get the preprocessor instance.

Returns:
preprocessor instance

getDistanceFactory

public D getDistanceFactory()
Description copied from interface: KNNQuery
Get the distance data type of the function.

Specified by:
getDistanceFactory in interface KNNQuery<O,D extends Distance<D>>

getDistanceQuery

public DistanceQuery<O,D> getDistanceQuery()
Description copied from interface: KNNQuery
Get the distance query for this function.

Specified by:
getDistanceQuery in interface KNNQuery<O,D extends Distance<D>>

Release 0.4.0 (2011-09-20_1324)