O
- the type of database objects the preprocessor can be applied to@Title(value="Materialize kNN Neighborhood preprocessor") @Description(value="Materializes the k nearest neighbors of objects of a database.") @Alias(value="de.lmu.ifi.dbs.elki.preprocessing.MaterializeKNNPreprocessor") public class MaterializeKNNPreprocessor<O> extends AbstractMaterializeKNNPreprocessor<O> implements DynamicIndex
Used for example by LOF
.
Modifier and Type | Class and Description |
---|---|
static class |
MaterializeKNNPreprocessor.Factory<O>
The parameterizable factory.
|
Modifier and Type | Field and Description |
---|---|
protected KNNQuery<O> |
knnQuery
KNNQuery instance to use.
|
protected javax.swing.event.EventListenerList |
listenerList
Holds the listener.
|
private static Logging |
LOG
Logger to use.
|
private static boolean |
usebulk
Flag to use bulk operations.
|
distanceFunction, distanceQuery, k
relation, storage
Constructor and Description |
---|
MaterializeKNNPreprocessor(Relation<O> relation,
DistanceFunction<? super O> distanceFunction,
int k)
Constructor with preprocessing step.
|
Modifier and Type | Method and Description |
---|---|
void |
addKNNListener(KNNListener l)
Adds a
KNNListener which will be invoked when the kNNs of objects
are changing. |
boolean |
delete(DBIDRef id)
Deletes the specified object from this index.
|
void |
deleteAll(DBIDs ids)
Deletes the specified objects from this index.
|
protected void |
fireKNNsInserted(DBIDs insertions,
DBIDs updates)
Informs all registered KNNListener that new kNNs have been inserted and as
a result some kNNs have been changed.
|
protected void |
fireKNNsRemoved(DBIDs removals,
DBIDs updates)
Informs all registered KNNListener that existing kNNs have been removed and
as a result some kNNs have been changed.
|
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.
|
java.lang.String |
getShortName()
A short name for the result, useful for file names.
|
void |
insert(DBIDRef id)
Inserts the specified object into this index.
|
void |
insertAll(DBIDs ids)
Inserts the specified objects into this index.
|
void |
logStatistics()
Send statistics to the logger, if enabled.
|
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.
|
void |
removeKNNListener(KNNListener l)
Removes a
KNNListener previously added with
addKNNListener(de.lmu.ifi.dbs.elki.index.preprocessed.knn.KNNListener) . |
private ArrayDBIDs |
updateKNNsAfterDeletion(DBIDs ids)
Updates the kNNs of the RkNNs of the specified ids.
|
private ArrayDBIDs |
updateKNNsAfterInsertion(DBIDs ids)
Updates the kNNs of the RkNNs of the specified ids.
|
createStorage, get, getDistanceQuery, getK, getKNNQuery, initialize
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
initialize
private static final Logging LOG
private static final boolean usebulk
protected final javax.swing.event.EventListenerList listenerList
public MaterializeKNNPreprocessor(Relation<O> relation, DistanceFunction<? super O> distanceFunction, int k)
relation
- Relation to preprocessdistanceFunction
- the distance function to usek
- query kprotected void preprocess()
preprocess
in class AbstractMaterializeKNNPreprocessor<O>
public final void insert(DBIDRef id)
DynamicIndex
insert
in interface DynamicIndex
id
- the object to be insertedpublic void insertAll(DBIDs ids)
DynamicIndex
insertAll
in interface DynamicIndex
ids
- the objects to be insertedpublic boolean delete(DBIDRef id)
DynamicIndex
delete
in interface DynamicIndex
id
- Object to removepublic void deleteAll(DBIDs ids)
DynamicIndex
deleteAll
in interface DynamicIndex
ids
- Objects to removeprotected void objectsInserted(DBIDs ids)
ids
- the ids of the newly inserted objectsprivate ArrayDBIDs updateKNNsAfterInsertion(DBIDs ids)
ids
- the ids of newly inserted objects causing a change of
materialized kNNsprivate ArrayDBIDs updateKNNsAfterDeletion(DBIDs ids)
ids
- the ids of deleted objects causing a change of materialized kNNsprotected void objectsRemoved(DBIDs ids)
ids
- the ids of the removed objectsprotected void fireKNNsInserted(DBIDs insertions, DBIDs updates)
insertions
- the ids of the newly inserted kNNsupdates
- the ids of kNNs which have been changed due to the
insertionsKNNListener
protected void fireKNNsRemoved(DBIDs removals, DBIDs updates)
removals
- the ids of the removed kNNsupdates
- the ids of kNNs which have been changed due to the removalsKNNListener
public void addKNNListener(KNNListener l)
KNNListener
which will be invoked when the kNNs of objects
are changing.l
- the listener to addremoveKNNListener(de.lmu.ifi.dbs.elki.index.preprocessed.knn.KNNListener)
,
KNNListener
public void removeKNNListener(KNNListener l)
KNNListener
previously added with
addKNNListener(de.lmu.ifi.dbs.elki.index.preprocessed.knn.KNNListener)
.l
- the listener to removeaddKNNListener(de.lmu.ifi.dbs.elki.index.preprocessed.knn.KNNListener)
,
KNNListener
public java.lang.String getLongName()
Result
getLongName
in interface Result
public java.lang.String getShortName()
Result
getShortName
in interface Result
public void logStatistics()
Index
logStatistics
in interface Index
protected Logging getLogger()
AbstractPreprocessorIndex
getLogger
in class AbstractPreprocessorIndex<O,KNNList>
Copyright © 2019 ELKI Development Team. License information.