Package elki.index.preprocessed.knn
Class MaterializeKNNPreprocessor<O>
- java.lang.Object
-
- elki.index.preprocessed.knn.AbstractMaterializeKNNPreprocessor<O>
-
- elki.index.preprocessed.knn.MaterializeKNNPreprocessor<O>
-
- Type Parameters:
O- the type of database objects the preprocessor can be applied to
- All Implemented Interfaces:
elki.index.DynamicIndex,elki.index.Index,elki.index.KNNIndex<O>
- Direct Known Subclasses:
MaterializeKNNAndRKNNPreprocessor
@Title("Materialize kNN Neighborhood preprocessor") @Description("Materializes the k nearest neighbors of objects of a database.") public class MaterializeKNNPreprocessor<O> extends AbstractMaterializeKNNPreprocessor<O> implements elki.index.DynamicIndexA preprocessor for annotation of the k nearest neighbors (and their distances) to each database object.Automatically added by the query optimizer if memory permits.
- Since:
- 0.2
- Author:
- Erich Schubert
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMaterializeKNNPreprocessor.Factory<O>The parameterizable factory.
-
Field Summary
Fields Modifier and Type Field Description protected elki.database.query.knn.KNNSearcher<elki.database.ids.DBIDRef>knnQueryKNNSearcher instance to use.protected javax.swing.event.EventListenerListlistenerListHolds the listener.private static elki.logging.LoggingLOGLogger to use.-
Fields inherited from class elki.index.preprocessed.knn.AbstractMaterializeKNNPreprocessor
distance, distanceQuery, k, relation, storage
-
-
Constructor Summary
Constructors Constructor Description MaterializeKNNPreprocessor(elki.database.relation.Relation<O> relation, elki.database.query.distance.DistanceQuery<O> distanceQuery, int k, boolean noopt)Constructor with preprocessing step.MaterializeKNNPreprocessor(elki.database.relation.Relation<O> relation, elki.distance.Distance<? super O> distance, int k)Constructor with preprocessing step.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddKNNListener(KNNListener l)Adds aKNNListenerwhich will be invoked when the kNNs of objects are changing.booleandelete(elki.database.ids.DBIDRef id)voiddeleteAll(elki.database.ids.DBIDs ids)protected voidfireKNNsInserted(elki.database.ids.DBIDs insertions, elki.database.ids.DBIDs updates)Informs all registered KNNListener that new kNNs have been inserted and as a result some kNNs have been changed.protected voidfireKNNsRemoved(elki.database.ids.DBIDs removals, elki.database.ids.DBIDs updates)Informs all registered KNNListener that existing kNNs have been removed and as a result some kNNs have been changed.protected elki.logging.LogginggetLogger()Get the classes static logger.voidinsert(elki.database.ids.DBIDRef id)voidinsertAll(elki.database.ids.DBIDs 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.voidremoveKNNListener(KNNListener l)Removes aKNNListenerpreviously added withaddKNNListener(elki.index.preprocessed.knn.KNNListener).private elki.database.ids.ArrayDBIDsupdateKNNsAfterDeletion(elki.database.ids.DBIDs ids)Updates the kNNs of the RkNNs of the specified ids.private elki.database.ids.ArrayDBIDsupdateKNNsAfterInsertion(elki.database.ids.DBIDs ids)Updates the kNNs of the RkNNs of the specified ids.-
Methods inherited from class elki.index.preprocessed.knn.AbstractMaterializeKNNPreprocessor
createStorage, get, getDistanceQuery, getK, initialize, kNNByDBID, kNNByObject
-
-
-
-
Field Detail
-
LOG
private static final elki.logging.Logging LOG
Logger to use.
-
knnQuery
protected final elki.database.query.knn.KNNSearcher<elki.database.ids.DBIDRef> knnQuery
KNNSearcher instance to use.
-
listenerList
protected final javax.swing.event.EventListenerList listenerList
Holds the listener.
-
-
Constructor Detail
-
MaterializeKNNPreprocessor
public MaterializeKNNPreprocessor(elki.database.relation.Relation<O> relation, elki.distance.Distance<? super O> distance, int k)
Constructor with preprocessing step.- Parameters:
relation- Relation to preprocessdistance- the distance function to usek- query k
-
MaterializeKNNPreprocessor
public MaterializeKNNPreprocessor(elki.database.relation.Relation<O> relation, elki.database.query.distance.DistanceQuery<O> distanceQuery, int k, boolean noopt)
Constructor with preprocessing step.- Parameters:
relation- Relation to preprocessdistanceQuery- the distance function to usek- query knoopt- Flag to disable optimization
-
-
Method Detail
-
preprocess
protected void preprocess()
The actual preprocessing step.- Specified by:
preprocessin classAbstractMaterializeKNNPreprocessor<O>
-
insert
public final void insert(elki.database.ids.DBIDRef id)
- Specified by:
insertin interfaceelki.index.DynamicIndex
-
insertAll
public void insertAll(elki.database.ids.DBIDs ids)
- Specified by:
insertAllin interfaceelki.index.DynamicIndex
-
delete
public boolean delete(elki.database.ids.DBIDRef id)
- Specified by:
deletein interfaceelki.index.DynamicIndex
-
deleteAll
public void deleteAll(elki.database.ids.DBIDs ids)
- Specified by:
deleteAllin interfaceelki.index.DynamicIndex
-
objectsInserted
protected void objectsInserted(elki.database.ids.DBIDs ids)
Called after new objects have been inserted, updates the materialized neighborhood.- Parameters:
ids- the ids of the newly inserted objects
-
updateKNNsAfterInsertion
private elki.database.ids.ArrayDBIDs updateKNNsAfterInsertion(elki.database.ids.DBIDs ids)
Updates the kNNs of the RkNNs of the specified ids.- Parameters:
ids- the ids of newly inserted objects causing a change of materialized kNNs- Returns:
- the RkNNs of the specified ids, i.e. the kNNs which have been updated
-
updateKNNsAfterDeletion
private elki.database.ids.ArrayDBIDs updateKNNsAfterDeletion(elki.database.ids.DBIDs ids)
Updates the kNNs of the RkNNs of the specified ids.- Parameters:
ids- the ids of deleted objects causing a change of materialized kNNs- Returns:
- the RkNNs of the specified ids, i.e. the kNNs which have been updated
-
objectsRemoved
protected void objectsRemoved(elki.database.ids.DBIDs ids)
Called after objects have been removed, updates the materialized neighborhood.- Parameters:
ids- the ids of the removed objects
-
fireKNNsInserted
protected void fireKNNsInserted(elki.database.ids.DBIDs insertions, elki.database.ids.DBIDs updates)Informs all registered KNNListener that new kNNs have been inserted and as a result some kNNs have been changed.- Parameters:
insertions- the ids of the newly inserted kNNsupdates- the ids of kNNs which have been changed due to the insertions- See Also:
KNNListener
-
fireKNNsRemoved
protected void fireKNNsRemoved(elki.database.ids.DBIDs removals, elki.database.ids.DBIDs updates)Informs all registered KNNListener that existing kNNs have been removed and as a result some kNNs have been changed.- Parameters:
removals- the ids of the removed kNNsupdates- the ids of kNNs which have been changed due to the removals- See Also:
KNNListener
-
addKNNListener
public void addKNNListener(KNNListener l)
Adds aKNNListenerwhich will be invoked when the kNNs of objects are changing.- Parameters:
l- the listener to add- See Also:
removeKNNListener(elki.index.preprocessed.knn.KNNListener),KNNListener
-
removeKNNListener
public void removeKNNListener(KNNListener l)
Removes aKNNListenerpreviously added withaddKNNListener(elki.index.preprocessed.knn.KNNListener).- Parameters:
l- the listener to remove- See Also:
addKNNListener(elki.index.preprocessed.knn.KNNListener),KNNListener
-
getLogger
protected elki.logging.Logging getLogger()
Description copied from class:AbstractMaterializeKNNPreprocessorGet the classes static logger.- Specified by:
getLoggerin classAbstractMaterializeKNNPreprocessor<O>- Returns:
- Logger
-
-