O
- Object typepublic class RdKNNTree<O extends NumberVector> extends NonFlatRStarTree<RdKNNNode,RdKNNEntry,RdkNNSettings> implements RangeIndex<O>, KNNIndex<O>, RKNNIndex<O>, DynamicIndex
TODO: noch nicht fertig!!!
AbstractRStarTree.Statistics
Modifier and Type | Field and Description |
---|---|
private SpatialDistanceQuery<O> |
distanceQuery
The distance function.
|
protected KNNQuery<O> |
knnQuery
Internal knn query object, for updating the rKNN.
|
private static Logging |
LOG
The logger for this class.
|
private Relation<O> |
relation
The relation we query.
|
EXTRA_INTEGRITY_CHECKS, height, settings, statistics
dirCapacity, dirMinimum, initialized, leafCapacity, leafMinimum
Constructor and Description |
---|
RdKNNTree(Relation<O> relation,
PageFile<RdKNNNode> pagefile,
RdkNNSettings settings)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
private void |
adjustKNNDistance(RdKNNEntry entry,
ArrayDBIDs ids,
java.util.List<? extends KNNList> knnLists)
Adjusts the knn distance in the subtree of the specified root entry.
|
protected void |
bulkLoad(java.util.List<RdKNNEntry> entries)
Performs a bulk load on this RTree with the specified data.
|
java.util.List<ModifiableDoubleDBIDList> |
bulkReverseKNNQueryForID(DBIDs ids,
int k,
SpatialPrimitiveDistanceFunction<? super O> distanceFunction,
KNNQuery<O> knnQuery) |
private void |
checkDistanceFunction(SpatialPrimitiveDistanceFunction<? super O> distanceFunction)
Throws an IllegalArgumentException if the specified distance function is
not an instance of the distance function used by this index.
|
protected TreeIndexHeader |
createHeader()
Creates a header for this index structure which is an instance of
TreeIndexHeader . |
protected RdKNNEntry |
createNewDirectoryEntry(RdKNNNode node)
Creates a new directory entry representing the specified node.
|
protected RdKNNNode |
createNewDirectoryNode()
Creates a new directory node with the specified capacity.
|
protected RdKNNLeafEntry |
createNewLeafEntry(DBID id) |
protected RdKNNNode |
createNewLeafNode()
Creates a new leaf node with the specified capacity.
|
protected RdKNNEntry |
createRootEntry()
Creates an entry representing the root node.
|
boolean |
delete(DBIDRef id)
Deletes the specified object from this index.
|
void |
deleteAll(DBIDs ids)
Deletes the specified objects from this index.
|
private void |
doBulkReverseKNN(RdKNNNode node,
DBIDs ids,
java.util.Map<DBID,ModifiableDoubleDBIDList> result)
Performs a bulk reverse knn query in the specified subtree.
|
private void |
doReverseKNN(RdKNNNode node,
DBID oid,
ModifiableDoubleDBIDList result)
Performs a reverse knn query in the specified subtree.
|
KNNQuery<O> |
getKNNQuery(DistanceQuery<O> distanceQuery,
java.lang.Object... hints)
Get a KNN query object for the given distance query and k.
|
protected Logging |
getLogger()
Get the (STATIC) logger for this class.
|
java.lang.String |
getLongName()
A "pretty" name for the result, for use in titles, captions and menus.
|
RangeQuery<O> |
getRangeQuery(DistanceQuery<O> distanceQuery,
java.lang.Object... hints)
Get a range query object for the given distance query and k.
|
RKNNQuery<O> |
getRKNNQuery(DistanceQuery<O> distanceQuery,
java.lang.Object... hints)
Get a KNN query object for the given distance query and k.
|
java.lang.String |
getShortName()
A short name for the result, useful for file names.
|
protected java.util.List<DoubleObjPair<RdKNNEntry>> |
getSortedEntries(AbstractRStarTreeNode<?,?> node,
SpatialComparable q,
SpatialPrimitiveDistanceFunction<?> distanceFunction)
Sorts the entries of the specified node according to their minimum distance
to the specified object.
|
void |
initialize()
Initialize the tree if the page file already existed.
|
protected void |
initializeCapacities(RdKNNEntry exampleLeaf)
Determines the maximum and minimum number of entries in a node.
|
void |
insert(DBIDRef id)
Inserts the specified real vector object into this index.
|
void |
insertAll(DBIDs ids)
Inserts the specified objects into this index.
|
protected void |
postDelete(RdKNNEntry entry)
Performs necessary operations after deleting the specified object.
|
protected void |
preInsert(RdKNNEntry entry)
Performs necessary operations before inserting the specified entry.
|
private void |
preInsert(RdKNNEntry q,
RdKNNEntry nodeEntry,
KNNHeap knns_q)
Adapts the knn distances before insertion of entry q.
|
DoubleDBIDList |
reverseKNNQuery(DBID oid,
int k,
SpatialPrimitiveDistanceFunction<? super O> distanceFunction,
KNNQuery<O> knnQuery) |
computeHeight, createEmptyRoot, hasOverflow, hasUnderflow
adjustTree, canBulkLoad, choosePath, containedTest, createBulkLeafNodes, createNewRoot, deletePath, doExtraIntegrityChecks, findPathToObject, getHeight, getLeaves, initializeFromFile, insertDirectoryEntry, insertLeaf, insertLeafEntry, logStatistics, reInsert, setHeight, toString
deleteNode, getDirMinimum, getFile, getLeafMinimum, getNode, getNode, getPageID, getPageSize, getRoot, getRootEntry, getRootID, getRootPath, initialize, isRoot, writeNode
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
logStatistics
private static final Logging LOG
private SpatialDistanceQuery<O extends NumberVector> distanceQuery
protected KNNQuery<O extends NumberVector> knnQuery
private Relation<O extends NumberVector> relation
public RdKNNTree(Relation<O> relation, PageFile<RdKNNNode> pagefile, RdkNNSettings settings)
relation
- Relation to indexpagefile
- Data storagesettings
- Tree settingsprotected void preInsert(RdKNNEntry entry)
preInsert
in class IndexTree<RdKNNNode,RdKNNEntry>
entry
- the entry to be insertedprotected void postDelete(RdKNNEntry entry)
postDelete
in class IndexTree<RdKNNNode,RdKNNEntry>
entry
- the entry that was removedprotected void bulkLoad(java.util.List<RdKNNEntry> entries)
bulkLoad
in class NonFlatRStarTree<RdKNNNode,RdKNNEntry,RdkNNSettings>
entries
- Entries to bulk loadpublic DoubleDBIDList reverseKNNQuery(DBID oid, int k, SpatialPrimitiveDistanceFunction<? super O> distanceFunction, KNNQuery<O> knnQuery)
public java.util.List<ModifiableDoubleDBIDList> bulkReverseKNNQueryForID(DBIDs ids, int k, SpatialPrimitiveDistanceFunction<? super O> distanceFunction, KNNQuery<O> knnQuery)
protected TreeIndexHeader createHeader()
IndexTree
TreeIndexHeader
. Subclasses may need to overwrite this method if
they need a more specialized header.createHeader
in class IndexTree<RdKNNNode,RdKNNEntry>
protected void initializeCapacities(RdKNNEntry exampleLeaf)
IndexTree
initializeCapacities
in class AbstractRStarTree<RdKNNNode,RdKNNEntry,RdkNNSettings>
exampleLeaf
- an object that will be stored in the indexprotected java.util.List<DoubleObjPair<RdKNNEntry>> getSortedEntries(AbstractRStarTreeNode<?,?> node, SpatialComparable q, SpatialPrimitiveDistanceFunction<?> distanceFunction)
node
- the nodeq
- the query objectdistanceFunction
- the distance function for computing the distancesprivate void preInsert(RdKNNEntry q, RdKNNEntry nodeEntry, KNNHeap knns_q)
q
- the entry to be insertednodeEntry
- the entry representing the root of the current subtreeknns_q
- the knns of qprivate void doReverseKNN(RdKNNNode node, DBID oid, ModifiableDoubleDBIDList result)
node
- the root node of the current subtreeoid
- the id of the object for which the rknn query is performedresult
- the list containing the query resultsprivate void doBulkReverseKNN(RdKNNNode node, DBIDs ids, java.util.Map<DBID,ModifiableDoubleDBIDList> result)
node
- the root node of the current subtreeids
- the object ids for which the rknn query is performedresult
- the map containing the query results for each objectprivate void adjustKNNDistance(RdKNNEntry entry, ArrayDBIDs ids, java.util.List<? extends KNNList> knnLists)
entry
- the root entry of the current subtreeids
- Sorted list of IDsknnLists
- a map of knn lists for each leaf entryprotected RdKNNNode createNewLeafNode()
createNewLeafNode
in class IndexTree<RdKNNNode,RdKNNEntry>
protected RdKNNNode createNewDirectoryNode()
createNewDirectoryNode
in class IndexTree<RdKNNNode,RdKNNEntry>
protected RdKNNEntry createNewDirectoryEntry(RdKNNNode node)
createNewDirectoryEntry
in class AbstractRStarTree<RdKNNNode,RdKNNEntry,RdkNNSettings>
node
- the node to be represented by the new entryprotected RdKNNEntry createRootEntry()
createRootEntry
in class IndexTree<RdKNNNode,RdKNNEntry>
private void checkDistanceFunction(SpatialPrimitiveDistanceFunction<? super O> distanceFunction)
distanceFunction
- the distance function to be checkedjava.lang.IllegalArgumentException
protected RdKNNLeafEntry createNewLeafEntry(DBID id)
public void initialize()
IndexTree
initialize
in interface Index
initialize
in class IndexTree<RdKNNNode,RdKNNEntry>
public final void insert(DBIDRef id)
insert
in interface DynamicIndex
id
- the object id that was insertedpublic final void insertAll(DBIDs ids)
insertAll
in interface DynamicIndex
ids
- the objects to be insertedpublic final boolean delete(DBIDRef id)
delete
in interface DynamicIndex
id
- Object to removepublic void deleteAll(DBIDs ids)
DynamicIndex
deleteAll
in interface DynamicIndex
ids
- Objects to removepublic RangeQuery<O> getRangeQuery(DistanceQuery<O> distanceQuery, java.lang.Object... hints)
RangeIndex
getRangeQuery
in interface RangeIndex<O extends NumberVector>
distanceQuery
- Distance queryhints
- Hints for the optimizernull
public KNNQuery<O> getKNNQuery(DistanceQuery<O> distanceQuery, java.lang.Object... hints)
KNNIndex
getKNNQuery
in interface KNNIndex<O extends NumberVector>
distanceQuery
- Distance queryhints
- Hints for the optimizernull
public RKNNQuery<O> getRKNNQuery(DistanceQuery<O> distanceQuery, java.lang.Object... hints)
RKNNIndex
getRKNNQuery
in interface RKNNIndex<O extends NumberVector>
distanceQuery
- Distance queryhints
- Hints for the optimizernull
public java.lang.String getLongName()
Result
getLongName
in interface Result
public java.lang.String getShortName()
Result
getShortName
in interface Result
Copyright © 2019 ELKI Development Team. License information.