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>
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.
|
private static Logging |
logger
Logger to use.
|
private static boolean |
usebulk
Flag to use bulk operations.
|
distanceFunction, distanceQuery, k, listenerList
storage
relation
Modifier | Constructor and Description |
---|---|
|
MaterializeKNNPreprocessor(Relation<O> relation,
DistanceFunction<? super O,D> distanceFunction,
int k)
Constructor with preprocessing step.
|
protected |
MaterializeKNNPreprocessor(Relation<O> relation,
DistanceFunction<? super O,D> distanceFunction,
int k,
boolean preprocess)
Constructor.
|
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(DBID id)
Deletes the specified object from this index.
|
void |
deleteAll(DBIDs ids)
Deletes the specified objects from this index.
|
protected ArrayDBIDs |
extractAndRemoveIDs(List<List<DistanceResultPair<D>>> extraxt,
ArrayDBIDs remove)
Extracts and removes the DBIDs in the given collections.
|
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.
|
List<DistanceResultPair<D>> |
get(DBID objid)
Get the k nearest neighbors.
|
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(DBID id)
Inserts the specified object into this index.
|
void |
insertAll(DBIDs ids)
Inserts the specified objects into this index.
|
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.
|
getDistanceFactory, getDistanceQuery, getK, getKNNQuery
getPageFileStatistics
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getPageFileStatistics
private static final Logging logger
private static final boolean usebulk
public MaterializeKNNPreprocessor(Relation<O> relation, DistanceFunction<? super O,D> distanceFunction, int k)
relation
- Relation to preprocessdistanceFunction
- the distance function to usek
- query kprotected MaterializeKNNPreprocessor(Relation<O> relation, DistanceFunction<? super O,D> distanceFunction, int k, boolean preprocess)
relation
- Relation to preprocessdistanceFunction
- the distance function to usek
- query kprotected void preprocess()
preprocess
in class AbstractMaterializeKNNPreprocessor<O,D extends Distance<D>>
public List<DistanceResultPair<D>> get(DBID objid)
objid
- Object IDpublic final void insert(DBID id)
Index
insert
in interface Index
insert
in class AbstractIndex<O>
id
- the object to be insertedpublic void insertAll(DBIDs ids)
Index
insertAll
in interface Index
insertAll
in class AbstractIndex<O>
ids
- the objects to be insertedpublic boolean delete(DBID id)
Index
delete
in interface Index
delete
in class AbstractIndex<O>
id
- Object to removepublic void deleteAll(DBIDs ids)
Index
deleteAll
in interface Index
deleteAll
in class AbstractIndex<O>
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
protected ArrayDBIDs extractAndRemoveIDs(List<List<DistanceResultPair<D>>> extraxt, ArrayDBIDs remove)
extraxt
- a list of lists of DistanceResultPair to extractremove
- the ids to removepublic 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>
protected Logging getLogger()
AbstractPreprocessorIndex
getLogger
in class AbstractPreprocessorIndex<O,List<DistanceResultPair<D extends Distance<D>>>>