|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.lmu.ifi.dbs.elki.index.AbstractIndex<O> de.lmu.ifi.dbs.elki.index.preprocessed.AbstractPreprocessorIndex<O,List<DistanceResultPair<D>>> de.lmu.ifi.dbs.elki.index.preprocessed.knn.AbstractMaterializeKNNPreprocessor<O,D> de.lmu.ifi.dbs.elki.index.preprocessed.knn.MaterializeKNNPreprocessor<O,D>
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>>
A preprocessor for annotation of the k nearest neighbors (and their
distances) to each database object.
Used for example by LOF
.
Nested Class Summary | |
---|---|
static class |
MaterializeKNNPreprocessor.Factory<O,D extends Distance<D>>
The parameterizable factory. |
Field Summary | |
---|---|
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. |
Fields inherited from class de.lmu.ifi.dbs.elki.index.preprocessed.knn.AbstractMaterializeKNNPreprocessor |
---|
distanceFunction, distanceQuery, k, listenerList |
Fields inherited from class de.lmu.ifi.dbs.elki.index.preprocessed.AbstractPreprocessorIndex |
---|
storage |
Fields inherited from class de.lmu.ifi.dbs.elki.index.AbstractIndex |
---|
relation |
Constructor Summary | |
---|---|
|
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. |
Method Summary | |
---|---|
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. |
Methods inherited from class de.lmu.ifi.dbs.elki.index.preprocessed.knn.AbstractMaterializeKNNPreprocessor |
---|
getDistanceFactory, getDistanceQuery, getK, getKNNQuery |
Methods inherited from class de.lmu.ifi.dbs.elki.index.AbstractIndex |
---|
getPageFileStatistics |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface de.lmu.ifi.dbs.elki.index.Index |
---|
getPageFileStatistics |
Field Detail |
---|
private static final Logging logger
private static final boolean usebulk
protected final KNNQuery<O,D extends Distance<D>> knnQuery
Constructor Detail |
---|
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 kMethod Detail |
---|
protected void preprocess()
preprocess
in class AbstractMaterializeKNNPreprocessor<O,D extends Distance<D>>
public List<DistanceResultPair<D>> get(DBID objid)
objid
- Object ID
public 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 remove
public 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 kNNs
private ArrayDBIDs updateKNNsAfterDeletion(DBIDs ids)
ids
- the ids of deleted objects causing a change of materialized kNNs
protected 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 remove
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>
protected Logging getLogger()
AbstractPreprocessorIndex
getLogger
in class AbstractPreprocessorIndex<O,List<DistanceResultPair<D extends Distance<D>>>>
|
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |