
O - the type of database objects the preprocessor can be applied toD - the type of distance the used distance function will return@Title(value="Materialize kNN and RkNN Neighborhood preprocessor") @Description(value="Materializes the k nearest neighbors and the reverse k nearest neighbors of objects of a database.") public class MaterializeKNNAndRKNNPreprocessor<O,D extends Distance<D>> extends MaterializeKNNPreprocessor<O,D> implements RKNNIndex<O>
| Modifier and Type | Class and Description | 
|---|---|
| static class  | MaterializeKNNAndRKNNPreprocessor.Factory<O,D extends Distance<D>>The parameterizable factory. | 
| Modifier and Type | Field and Description | 
|---|---|
| protected boolean | doubleOptimizeUse optimizations for double values | 
| private static Logging | LOGLogger to use. | 
| private WritableDataStore<TreeSet<DistanceDBIDPair<D>>> | materialized_RkNNAdditional data storage for RkNN. | 
knnQuery, listenerListdistanceFunction, distanceQuery, kstoragerelation| Constructor and Description | 
|---|
| MaterializeKNNAndRKNNPreprocessor(Relation<O> relation,
                                 DistanceFunction<? super O,D> distanceFunction,
                                 int k)Constructor. | 
| Modifier and Type | Method and Description | 
|---|---|
| protected ArrayDBIDs | affectedkNN(List<? extends KNNResult<D>> extraxt,
           DBIDs remove)Extracts and removes the DBIDs in the given collections. | 
| protected ArrayDBIDs | affectedRkNN(List<? extends Collection<DistanceDBIDPair<D>>> extraxt,
            DBIDs remove)Extracts and removes the DBIDs in the given collections. | 
| KNNResult<D> | getKNN(DBID id)Returns the materialized kNNs of the specified id. | 
| protected Logging | getLogger()Get the classes static logger. | 
| String | getLongName()A "pretty" name for the result, for use in titles, captions and menus. | 
| GenericDistanceDBIDList<D> | getRKNN(DBIDRef id)Returns the materialized RkNNs of the specified id. | 
| <S extends Distance<S>>  | getRKNNQuery(DistanceQuery<O,S> distanceQuery,
            Object... hints)Get a KNN query object for the given distance query and k. | 
| String | getShortName()A short name for the result, useful for file names. | 
| private DistanceDBIDPair<D> | makePair(DistanceDBIDResultIter<D> iter,
        DBIDIter id) | 
| private void | materializeKNNAndRKNNs(ArrayDBIDs ids,
                      FiniteProgress progress)Materializes the kNNs and RkNNs of the specified object IDs. | 
| protected void | objectsInserted(DBIDs ids)Called after new objects have been inserted, updates the materialized
 neighborhood. | 
| protected void | objectsRemoved(DBIDs ids)Called after objects have been removed, updates the materialized
 neighborhood. | 
| protected void | preprocess()The actual preprocessing step. | 
| private ArrayDBIDs | updateKNNsAndRkNNs(DBIDs ids)Updates the kNNs and RkNNs after insertion of the specified ids. | 
addKNNListener, delete, deleteAll, fireKNNsInserted, fireKNNsRemoved, insert, insertAll, removeKNNListenercreateStorage, get, getDistanceFactory, getDistanceQuery, getK, getKNNQuerygetPageFileStatisticsprivate static final Logging LOG
private WritableDataStore<TreeSet<DistanceDBIDPair<D extends Distance<D>>>> materialized_RkNN
protected boolean doubleOptimize
public MaterializeKNNAndRKNNPreprocessor(Relation<O> relation, DistanceFunction<? super O,D> distanceFunction, int k)
relation - Relation to processdistanceFunction - the distance function to usek - query kprotected void preprocess()
MaterializeKNNPreprocessorpreprocess in class MaterializeKNNPreprocessor<O,D extends Distance<D>>private void materializeKNNAndRKNNs(ArrayDBIDs ids, FiniteProgress progress)
ids - the IDs of the objectsprivate DistanceDBIDPair<D> makePair(DistanceDBIDResultIter<D> iter, DBIDIter id)
protected void objectsInserted(DBIDs ids)
MaterializeKNNPreprocessorobjectsInserted in class MaterializeKNNPreprocessor<O,D extends Distance<D>>ids - the ids of the newly inserted objectsprivate ArrayDBIDs updateKNNsAndRkNNs(DBIDs ids)
ids - the ids of newly inserted objects causing a change of
        materialized kNNs and RkNNsprotected void objectsRemoved(DBIDs ids)
MaterializeKNNPreprocessorobjectsRemoved in class MaterializeKNNPreprocessor<O,D extends Distance<D>>ids - the ids of the removed objectsprotected ArrayDBIDs affectedkNN(List<? extends KNNResult<D>> extraxt, DBIDs remove)
extraxt - a list of lists of DistanceResultPair to extractremove - the ids to removeprotected ArrayDBIDs affectedRkNN(List<? extends Collection<DistanceDBIDPair<D>>> extraxt, DBIDs remove)
extraxt - a list of lists of DistanceResultPair to extractremove - the ids to removepublic KNNResult<D> getKNN(DBID id)
id - the query idpublic GenericDistanceDBIDList<D> getRKNN(DBIDRef id)
id - the query idpublic <S extends Distance<S>> RKNNQuery<O,S> getRKNNQuery(DistanceQuery<O,S> distanceQuery, Object... hints)
RKNNIndexgetRKNNQuery in interface RKNNIndex<O>S - Distance typedistanceQuery - Distance queryhints - Hints for the optimizernullpublic String getLongName()
ResultgetLongName in interface ResultgetLongName in class MaterializeKNNPreprocessor<O,D extends Distance<D>>public String getShortName()
ResultgetShortName in interface ResultgetShortName in class MaterializeKNNPreprocessor<O,D extends Distance<D>>protected Logging getLogger()
AbstractPreprocessorIndex