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 Neighborhood preprocessor") @Description(value="Materializes the k nearest neighbors of objects of a database.") public class MaterializeKNNPreprocessor<O,D extends Distance<D>> extends AbstractMaterializeKNNPreprocessor<O,D,KNNList<D>> implements DynamicIndex
LOF
.Modifier and Type | Class and Description |
---|---|
static class |
MaterializeKNNPreprocessor.Factory<O,D extends Distance<D>>
The parameterizable factory.
|
Modifier and Type | Field and Description |
---|---|
protected KNNQuery<O,D> |
knnQuery
KNNQuery instance to use.
|
protected EventListenerList |
listenerList
Holds the listener.
|
private static Logging |
LOG
Logger to use.
|
private static boolean |
usebulk
Flag to use bulk operations.
|
distanceFunction, distanceQuery, k
storage
relation
Constructor and Description |
---|
MaterializeKNNPreprocessor(Relation<O> relation,
DistanceFunction<? super O,D> 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.
|
String |
getLongName()
A "pretty" name for the result, for use in titles, captions and menus.
|
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, getDistanceFactory, 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 EventListenerList listenerList
public MaterializeKNNPreprocessor(Relation<O> relation, DistanceFunction<? super O,D> distanceFunction, int k)
relation
- Relation to preprocessdistanceFunction
- the distance function to usek
- query kprotected void preprocess()
preprocess
in class AbstractMaterializeKNNPreprocessor<O,D extends Distance<D>,KNNList<D extends Distance<D>>>
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 String getLongName()
Result
getLongName
in interface Result
getLongName
in class AbstractIndex<O>
public String getShortName()
Result
getShortName
in interface Result
getShortName
in class AbstractIndex<O>
public void logStatistics()
Index
logStatistics
in interface Index
protected Logging getLogger()
AbstractPreprocessorIndex