O
- the type of database objects the preprocessor can be applied to@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> extends MaterializeKNNPreprocessor<O> implements RKNNIndex<O>
BUG: This class currently does not seem able to correctly keep track of the nearest neighbors!
Modifier and Type | Class and Description |
---|---|
static class |
MaterializeKNNAndRKNNPreprocessor.Factory<O>
The parameterizable factory.
|
Modifier and Type | Field and Description |
---|---|
private static Logging |
LOG
Logger to use.
|
private WritableDataStore<java.util.TreeSet<DoubleDBIDPair>> |
materialized_RkNN
Additional data storage for RkNN.
|
knnQuery, listenerList
distanceFunction, distanceQuery, k
relation, storage
Constructor and Description |
---|
MaterializeKNNAndRKNNPreprocessor(Relation<O> relation,
DistanceFunction<? super O> distanceFunction,
int k)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected ArrayDBIDs |
affectedkNN(java.util.List<? extends KNNList> extract,
DBIDs remove)
Extracts and removes the DBIDs in the given collections.
|
protected ArrayDBIDs |
affectedRkNN(java.util.List<? extends java.util.Collection<DoubleDBIDPair>> extract,
DBIDs remove)
Extracts and removes the DBIDs in the given collections.
|
KNNList |
getKNN(DBID id)
Returns the materialized kNNs of the specified id.
|
protected Logging |
getLogger()
Get the classes static logger.
|
java.lang.String |
getLongName()
A "pretty" name for the result, for use in titles, captions and menus.
|
DoubleDBIDList |
getRKNN(DBIDRef id)
Returns the materialized RkNNs of the specified id.
|
RKNNQuery<O> |
getRKNNQuery(DistanceQuery<O> distanceQuery,
java.lang.Object... hints)
Get a KNN query object for the given distance query and k.
|
java.lang.String |
getShortName()
A short name for the result, useful for file names.
|
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, logStatistics, removeKNNListener
createStorage, get, getDistanceQuery, getK, getKNNQuery, initialize
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
initialize, logStatistics
private static final Logging LOG
private WritableDataStore<java.util.TreeSet<DoubleDBIDPair>> materialized_RkNN
public MaterializeKNNAndRKNNPreprocessor(Relation<O> relation, DistanceFunction<? super O> distanceFunction, int k)
relation
- Relation to processdistanceFunction
- the distance function to usek
- query kprotected void preprocess()
MaterializeKNNPreprocessor
preprocess
in class MaterializeKNNPreprocessor<O>
private void materializeKNNAndRKNNs(ArrayDBIDs ids, FiniteProgress progress)
ids
- the IDs of the objectsprotected void objectsInserted(DBIDs ids)
MaterializeKNNPreprocessor
objectsInserted
in class MaterializeKNNPreprocessor<O>
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)
MaterializeKNNPreprocessor
objectsRemoved
in class MaterializeKNNPreprocessor<O>
ids
- the ids of the removed objectsprotected ArrayDBIDs affectedkNN(java.util.List<? extends KNNList> extract, DBIDs remove)
extract
- a list of lists of DistanceResultPair to extractremove
- the ids to removeprotected ArrayDBIDs affectedRkNN(java.util.List<? extends java.util.Collection<DoubleDBIDPair>> extract, DBIDs remove)
extract
- a list of lists of DistanceResultPair to extractremove
- the ids to removepublic KNNList getKNN(DBID id)
id
- the query idpublic DoubleDBIDList getRKNN(DBIDRef id)
id
- the query idpublic RKNNQuery<O> getRKNNQuery(DistanceQuery<O> distanceQuery, java.lang.Object... hints)
RKNNIndex
getRKNNQuery
in interface RKNNIndex<O>
distanceQuery
- Distance queryhints
- Hints for the optimizernull
public java.lang.String getLongName()
Result
getLongName
in interface Result
getLongName
in class MaterializeKNNPreprocessor<O>
public java.lang.String getShortName()
Result
getShortName
in interface Result
getShortName
in class MaterializeKNNPreprocessor<O>
protected Logging getLogger()
AbstractPreprocessorIndex
getLogger
in class MaterializeKNNPreprocessor<O>
Copyright © 2019 ELKI Development Team. License information.