Package elki.index.preprocessed.knn
Class MaterializeKNNAndRKNNPreprocessor<O>
- java.lang.Object
-
- elki.index.preprocessed.knn.AbstractMaterializeKNNPreprocessor<O>
-
- elki.index.preprocessed.knn.MaterializeKNNPreprocessor<O>
-
- elki.index.preprocessed.knn.MaterializeKNNAndRKNNPreprocessor<O>
-
- Type Parameters:
O- the type of database objects the preprocessor can be applied to the type of distance the used distance function will return
- All Implemented Interfaces:
elki.index.DynamicIndex,elki.index.Index,elki.index.KNNIndex<O>,elki.index.RKNNIndex<O>
@Title("Materialize kNN and RkNN Neighborhood preprocessor") @Description("Materializes the k nearest neighbors and the reverse k nearest neighbors of objects of a database.") public class MaterializeKNNAndRKNNPreprocessor<O> extends MaterializeKNNPreprocessor<O> implements elki.index.RKNNIndex<O>A preprocessor for annotation of the k nearest neighbors and the reverse k nearest neighbors (and their distances) to each database object.BUG: This class currently does not seem able to correctly keep track of the nearest neighbors?
TODO: for better performance, we would need some ModifiableDoubleDBIDHashSet or TreeSet to store the rkNN.
- Since:
- 0.4.0
- Author:
- Elke Achtert
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMaterializeKNNAndRKNNPreprocessor.Factory<O>The parameterizable factory.
-
Field Summary
Fields Modifier and Type Field Description private static elki.logging.LoggingLOGLogger to use.private elki.database.datastore.WritableDataStore<elki.database.ids.ModifiableDoubleDBIDList>storageRkNNAdditional data storage for RkNN.-
Fields inherited from class elki.index.preprocessed.knn.MaterializeKNNPreprocessor
knnQuery, listenerList
-
Fields inherited from class elki.index.preprocessed.knn.AbstractMaterializeKNNPreprocessor
distance, distanceQuery, k, relation, storage
-
-
Constructor Summary
Constructors Constructor Description MaterializeKNNAndRKNNPreprocessor(elki.database.relation.Relation<O> relation, elki.distance.Distance<? super O> distance, int k)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description elki.database.ids.KNNListgetKNN(elki.database.ids.DBID id)Returns the materialized kNNs of the specified id.protected elki.logging.LogginggetLogger()Get the classes static logger.elki.database.ids.DoubleDBIDListgetRKNN(elki.database.ids.DBIDRef id)Returns the materialized RkNNs of the specified id.private voidmaterializeKNNAndRKNNs(elki.database.ids.ArrayDBIDs ids, elki.logging.progress.FiniteProgress progress)Materializes the kNNs and RkNNs of the specified object IDs.protected voidobjectsInserted(elki.database.ids.DBIDs ids)Called after new objects have been inserted, updates the materialized neighborhood.protected voidobjectsRemoved(elki.database.ids.DBIDs ids)Called after objects have been removed, updates the materialized neighborhood.protected voidpreprocess()The actual preprocessing step.elki.database.query.rknn.RKNNSearcher<elki.database.ids.DBIDRef>rkNNByDBID(elki.database.query.distance.DistanceQuery<O> distanceQuery, int maxk, int flags)elki.database.query.rknn.RKNNSearcher<O>rkNNByObject(elki.database.query.distance.DistanceQuery<O> distanceQuery, int maxk, int flags)private elki.database.ids.DBIDsupdateKNNsAndRkNNs(elki.database.ids.DBIDs ids)Updates the kNNs and RkNNs after insertion of the specified ids.-
Methods inherited from class elki.index.preprocessed.knn.MaterializeKNNPreprocessor
addKNNListener, delete, deleteAll, fireKNNsInserted, fireKNNsRemoved, insert, insertAll, removeKNNListener
-
Methods inherited from class elki.index.preprocessed.knn.AbstractMaterializeKNNPreprocessor
createStorage, get, getDistanceQuery, getK, initialize, kNNByDBID, kNNByObject
-
-
-
-
Method Detail
-
preprocess
protected void preprocess()
Description copied from class:MaterializeKNNPreprocessorThe actual preprocessing step.- Overrides:
preprocessin classMaterializeKNNPreprocessor<O>
-
materializeKNNAndRKNNs
private void materializeKNNAndRKNNs(elki.database.ids.ArrayDBIDs ids, elki.logging.progress.FiniteProgress progress)Materializes the kNNs and RkNNs of the specified object IDs.- Parameters:
ids- the IDs of the objects
-
objectsInserted
protected void objectsInserted(elki.database.ids.DBIDs ids)
Description copied from class:MaterializeKNNPreprocessorCalled after new objects have been inserted, updates the materialized neighborhood.- Overrides:
objectsInsertedin classMaterializeKNNPreprocessor<O>- Parameters:
ids- the ids of the newly inserted objects
-
updateKNNsAndRkNNs
private elki.database.ids.DBIDs updateKNNsAndRkNNs(elki.database.ids.DBIDs ids)
Updates the kNNs and RkNNs after insertion of the specified ids.- Parameters:
ids- the ids of newly inserted objects causing a change of materialized kNNs and RkNNs- Returns:
- the RkNNs of the specified ids, i.e. the kNNs which have been updated
-
objectsRemoved
protected void objectsRemoved(elki.database.ids.DBIDs ids)
Description copied from class:MaterializeKNNPreprocessorCalled after objects have been removed, updates the materialized neighborhood.- Overrides:
objectsRemovedin classMaterializeKNNPreprocessor<O>- Parameters:
ids- the ids of the removed objects
-
getKNN
public elki.database.ids.KNNList getKNN(elki.database.ids.DBID id)
Returns the materialized kNNs of the specified id.- Parameters:
id- the query id- Returns:
- the kNNs
-
getRKNN
public elki.database.ids.DoubleDBIDList getRKNN(elki.database.ids.DBIDRef id)
Returns the materialized RkNNs of the specified id.- Parameters:
id- the query id- Returns:
- the RkNNs
-
rkNNByObject
public elki.database.query.rknn.RKNNSearcher<O> rkNNByObject(elki.database.query.distance.DistanceQuery<O> distanceQuery, int maxk, int flags)
- Specified by:
rkNNByObjectin interfaceelki.index.RKNNIndex<O>
-
rkNNByDBID
public elki.database.query.rknn.RKNNSearcher<elki.database.ids.DBIDRef> rkNNByDBID(elki.database.query.distance.DistanceQuery<O> distanceQuery, int maxk, int flags)
- Specified by:
rkNNByDBIDin interfaceelki.index.RKNNIndex<O>
-
getLogger
protected elki.logging.Logging getLogger()
Description copied from class:AbstractMaterializeKNNPreprocessorGet the classes static logger.- Overrides:
getLoggerin classMaterializeKNNPreprocessor<O>- Returns:
- Logger
-
-