|
|
|||||||||||||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.lmu.ifi.dbs.elki.logging.AbstractLoggable
de.lmu.ifi.dbs.elki.utilities.optionhandling.AbstractParameterizable
de.lmu.ifi.dbs.elki.index.tree.TreeIndex<O,N,E>
de.lmu.ifi.dbs.elki.index.tree.spatial.SpatialIndex<O,N,E>
de.lmu.ifi.dbs.elki.index.tree.spatial.rstarvariants.AbstractRStarTree<O,N,E>
O
- Object typeN
- Node typeE
- Entry typepublic abstract class AbstractRStarTree<O extends NumberVector<O,?>,N extends AbstractRStarTreeNode<N,E>,E extends SpatialEntry>
Abstract superclass for index structures based on a R*-Tree.
Field Summary | |
---|---|
protected static boolean |
extraIntegrityChecks
|
private int |
height
The height of this R*-Tree. |
private Map<Integer,Boolean> |
reinsertions
Contains a boolean for each level of this R*-Tree that indicates if there was already a reinsert operation in this level during the current insert / delete operation. |
Fields inherited from class de.lmu.ifi.dbs.elki.index.tree.spatial.SpatialIndex |
---|
bulk, BULK_LOAD_ID, BULK_LOAD_STRATEGY_ID, bulkLoadStrategy |
Fields inherited from class de.lmu.ifi.dbs.elki.index.tree.TreeIndex |
---|
CACHE_SIZE_ID, cacheSize, dirCapacity, dirMinimum, file, FILE_ID, initialized, leafCapacity, leafMinimum, PAGE_SIZE_ID, pageSize |
Fields inherited from class de.lmu.ifi.dbs.elki.utilities.optionhandling.AbstractParameterizable |
---|
optionHandler |
Fields inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable |
---|
debug, logger |
Constructor Summary | |
---|---|
AbstractRStarTree()
|
Method Summary | ||
---|---|---|
private void |
adjustTree(TreeIndexPath<E> subtree)
Adjusts the tree after insertion of some nodes. |
|
protected
|
batchNN(N node,
SpatialDistanceFunction<O,D> distanceFunction,
Map<Integer,KNNList<D>> knnLists)
Performs a batch knn query. |
|
|
bulkKNNQueryForIDs(List<Integer> ids,
int k,
SpatialDistanceFunction<O,D> distanceFunction)
Performs a bulk k-nearest neighbor query for the given object IDs. |
|
protected abstract void |
bulkLoad(List<O> objects)
Performs a bulk load on this RTree with the specified data. |
|
private TreeIndexPath<E> |
choosePath(TreeIndexPath<E> subtree,
HyperBoundingBox mbr,
int level)
Chooses the best path of the specified subtree for insertion of the given mbr at the specified level. |
|
protected void |
clearReinsertions()
Clears the reinsertions. |
|
protected abstract int |
computeHeight()
Computes the height of this RTree. |
|
private void |
condenseTree(TreeIndexPath<E> subtree,
Stack<N> stack)
Condenses the tree after deletion of some nodes. |
|
protected List<N> |
createLeafNodes(List<O> objects)
Creates and returns the leaf nodes for bulk load. |
|
protected abstract E |
createNewDirectoryEntry(N node)
Creates a new directory entry representing the specified node. |
|
protected abstract E |
createNewLeafEntry(O object)
Creates a new leaf entry representing the specified data object in the specified subtree. |
|
private TreeIndexPath<E> |
createNewRoot(N oldRoot,
N newNode)
Creates a new root node that points to the two specified child nodes and return the path to the new root. |
|
boolean |
delete(O object)
Deletes the specified object from this index. |
|
protected
|
doKNNQuery(Object object,
SpatialDistanceFunction<O,D> distanceFunction,
KNNList<D> knnList)
Performs a k-nearest neighbor query for the given NumberVector with the given parameter k and the according distance function. |
|
protected TreeIndexPath<E> |
findPathToObject(TreeIndexPath<E> subtree,
HyperBoundingBox mbr,
int id)
Returns the path to the leaf entry in the specified subtree that represents the data object with the specified mbr and id. |
|
private TreeIndexPathComponent<E> |
getChildWithLeastOverlap(N node,
HyperBoundingBox mbr)
Returns the path information of the entry of the specified node which needs least overlap enlargement if the given mbr would be inserted into. |
|
int |
getHeight()
Returns the height of this R*-Tree. |
|
private void |
getLeafNodes(N node,
List<E> result,
int currentLevel)
Determines the entries pointing to the leaf nodes of the specified subtree |
|
private TreeIndexPathComponent<E> |
getLeastEnlargement(N node,
HyperBoundingBox mbr)
Returns the path information of the entry of the specified node with the least enlargement if the given mbr would be inserted into. |
|
List<E> |
getLeaves()
Returns a list of entries pointing to the leaf nodes of this spatial index. |
|
protected
|
getSortedEntries(N node,
Collection<Integer> ids,
SpatialDistanceFunction<O,D> distanceFunction)
Sorts the entries of the specified node according to their minimum distance to the specified objects. |
|
protected
|
getSortedEntries(N node,
Integer q,
SpatialDistanceFunction<O,D> distanceFunction)
Sorts the entries of the specified node according to their minimum distance to the specified object. |
|
protected double[] |
getValues(O object)
Returns a double array consisting of the values of the specified real vector. |
|
protected abstract boolean |
hasOverflow(N node)
Returns true if in the specified node an overflow occurred, false otherwise. |
|
protected abstract boolean |
hasUnderflow(N node)
Returns true if in the specified node an underflow occurred, false otherwise. |
|
protected void |
initializeCapacities(O object,
boolean verbose)
Determines the maximum and minimum number of entries in a node. |
|
protected void |
initializeFromFile()
Initializes this R*-Tree from an existing persistent file. |
|
void |
insert(List<O> objects)
Inserts the specified objects into this index. |
|
void |
insert(O object)
Inserts the specified reel vector object into this index. |
|
private void |
insertDirectoryEntry(E entry,
int level)
Inserts the specified directory entry at the specified level into this R*-Tree. |
|
private void |
insertLeafEntry(E entry)
Inserts the specified leaf entry into this R*-Tree. |
|
|
kNNQuery(O object,
int k,
SpatialDistanceFunction<O,D> distanceFunction)
Performs a k-nearest neighbor query for the given NumberVector with the given parameter k and the according distance function. |
|
private N |
overflowTreatment(N node,
TreeIndexPath<E> path)
Treatment of overflow in the specified node: if the node is not the root node and this is the first call of overflowTreatment in the given level during insertion the specified node will be reinserted, otherwise the node will be splitted. |
|
|
rangeQuery(O object,
String epsilon,
SpatialDistanceFunction<O,D> distanceFunction)
Performs a range query for the given spatial object with the given epsilon range and the according distance function. |
|
private void |
reInsert(N node,
int level,
TreeIndexPath<E> path)
Reinserts the specified node at the specified level. |
|
|
reverseKNNQuery(O object,
int k,
SpatialDistanceFunction<O,D> distanceFunction)
Performs a reverse k-nearest neighbor query for the given object ID. |
|
protected void |
setHeight(int height)
Sets the height of this R*-Tree. |
|
private N |
split(N node)
Splits the specified node and returns the newly created split node. |
|
String |
toString()
Returns a string representation of this RTree. |
|
private HyperBoundingBox |
union(HyperBoundingBox mbr1,
HyperBoundingBox mbr2)
Returns the union of the two specified MBRs. |
Methods inherited from class de.lmu.ifi.dbs.elki.index.tree.spatial.SpatialIndex |
---|
setDatabase, setParameters |
Methods inherited from class de.lmu.ifi.dbs.elki.index.tree.TreeIndex |
---|
close, createEmptyRoot, createHeader, createNewDirectoryNode, createNewLeafNode, createRootEntry, getLogicalPageAccess, getNode, getNode, getPhysicalReadAccess, getPhysicalWriteAccess, getRoot, getRootEntry, getRootPath, initialize, postDelete, preInsert, resetPageAccess |
Methods inherited from class de.lmu.ifi.dbs.elki.utilities.optionhandling.AbstractParameterizable |
---|
addOption, addParameterizable, addParameterizable, checkGlobalParameterConstraints, collectOptions, getAttributeSettings, getParameters, rememberParametersExcept, removeOption, removeParameterizable, shortDescription |
Methods inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable |
---|
debugFine, debugFiner, debugFinest, exception, progress, verbose, warning |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface de.lmu.ifi.dbs.elki.utilities.optionhandling.Parameterizable |
---|
checkGlobalParameterConstraints, collectOptions, getParameters, shortDescription |
Field Detail |
---|
protected static final boolean extraIntegrityChecks
private final Map<Integer,Boolean> reinsertions
private int height
Constructor Detail |
---|
public AbstractRStarTree()
Method Detail |
---|
public final void insert(O object)
object
- the vector to be insertedpublic final void insert(List<O> objects)
objects
- the objects to be insertedprivate void insertLeafEntry(E entry)
entry
- the leaf entry to be insertedprivate void insertDirectoryEntry(E entry, int level)
entry
- the directory entry to be insertedlevel
- the level at which the directory entry is to be insertedpublic final boolean delete(O object)
object
- the object to be deleted
public <D extends Distance<D>> List<DistanceResultPair<D>> rangeQuery(O object, String epsilon, SpatialDistanceFunction<O,D> distanceFunction)
rangeQuery
in class SpatialIndex<O extends NumberVector<O,?>,N extends AbstractRStarTreeNode<N,E>,E extends SpatialEntry>
D
- distance typeobject
- the query objectepsilon
- the string representation of the query rangedistanceFunction
- the distance function that computes the distances
between the objects
public <D extends Distance<D>> List<DistanceResultPair<D>> kNNQuery(O object, int k, SpatialDistanceFunction<O,D> distanceFunction)
kNNQuery
in class SpatialIndex<O extends NumberVector<O,?>,N extends AbstractRStarTreeNode<N,E>,E extends SpatialEntry>
D
- distance typeobject
- the query objectk
- the number of nearest neighbors to be returneddistanceFunction
- the distance function that computes the distances
between the objects
public <D extends Distance<D>> List<List<DistanceResultPair<D>>> bulkKNNQueryForIDs(List<Integer> ids, int k, SpatialDistanceFunction<O,D> distanceFunction)
bulkKNNQueryForIDs
in class SpatialIndex<O extends NumberVector<O,?>,N extends AbstractRStarTreeNode<N,E>,E extends SpatialEntry>
D
- distance typeids
- the query objectsk
- the number of nearest neighbors to be returneddistanceFunction
- the distance function that computes the distances
between the objects
public <D extends Distance<D>> List<DistanceResultPair<D>> reverseKNNQuery(O object, int k, SpatialDistanceFunction<O,D> distanceFunction)
reverseKNNQuery
in class SpatialIndex<O extends NumberVector<O,?>,N extends AbstractRStarTreeNode<N,E>,E extends SpatialEntry>
D
- distance typeobject
- the query objectk
- the number of nearest neighbors to be returneddistanceFunction
- the distance function that computes the distances
between the objects
public final List<E> getLeaves()
getLeaves
in class SpatialIndex<O extends NumberVector<O,?>,N extends AbstractRStarTreeNode<N,E>,E extends SpatialEntry>
public final int getHeight()
public String toString()
toString
in class Object
protected void initializeFromFile()
initializeFromFile
in class TreeIndex<O extends NumberVector<O,?>,N extends AbstractRStarTreeNode<N,E>,E extends SpatialEntry>
protected void initializeCapacities(O object, boolean verbose)
TreeIndex
initializeCapacities
in class TreeIndex<O extends NumberVector<O,?>,N extends AbstractRStarTreeNode<N,E>,E extends SpatialEntry>
object
- an object that will be stored in the indexverbose
- flag to allow verbose messagesprotected <D extends Distance<D>> void doKNNQuery(Object object, SpatialDistanceFunction<O,D> distanceFunction, KNNList<D> knnList)
object
- the query objectdistanceFunction
- the distance function that computes the distances
between the objectsknnList
- the knn list containing the resultprotected <D extends Distance<D>> void batchNN(N node, SpatialDistanceFunction<O,D> distanceFunction, Map<Integer,KNNList<D>> knnLists)
node
- the node for which the query should be performeddistanceFunction
- the distance function for computing the distancesknnLists
- a map containing the knn lists for each query objectsprotected TreeIndexPath<E> findPathToObject(TreeIndexPath<E> subtree, HyperBoundingBox mbr, int id)
subtree
- the subtree to be testedmbr
- the mbr to look forid
- the id to look for
protected List<N> createLeafNodes(List<O> objects)
objects
- the objects to be inserted
protected <D extends Distance<D>> List<DistanceEntry<D,E>> getSortedEntries(N node, Integer q, SpatialDistanceFunction<O,D> distanceFunction)
node
- the nodeq
- the id of the objectdistanceFunction
- the distance function for computing the distances
protected <D extends Distance<D>> List<DistanceEntry<D,E>> getSortedEntries(N node, Collection<Integer> ids, SpatialDistanceFunction<O,D> distanceFunction)
node
- the nodeids
- the id of the objectsdistanceFunction
- the distance function for computing the distances
protected double[] getValues(O object)
object
- the real vector
protected void setHeight(int height)
height
- the height to be setprotected void clearReinsertions()
protected abstract boolean hasOverflow(N node)
node
- the node to be tested for overflow
protected abstract boolean hasUnderflow(N node)
node
- the node to be tested for underflow
protected abstract int computeHeight()
protected abstract void bulkLoad(List<O> objects)
objects
- the data objects to be indexedprotected abstract E createNewLeafEntry(O object)
object
- the data object to be represented by the new entry
protected abstract E createNewDirectoryEntry(N node)
node
- the node to be represented by the new entry
private TreeIndexPath<E> choosePath(TreeIndexPath<E> subtree, HyperBoundingBox mbr, int level)
subtree
- the subtree to be tested for insertionmbr
- the mbr to be insertedlevel
- the level at which the mbr should be inserted (level 1
indicates leaf-level)
private TreeIndexPathComponent<E> getLeastEnlargement(N node, HyperBoundingBox mbr)
node
- the node which children have to be testedmbr
- the mbr of the node to be inserted
private TreeIndexPathComponent<E> getChildWithLeastOverlap(N node, HyperBoundingBox mbr)
node
- the node of which the children should be testedmbr
- the mbr to be inserted into the children
private HyperBoundingBox union(HyperBoundingBox mbr1, HyperBoundingBox mbr2)
mbr1
- the first MBRmbr2
- the second MBR
private N overflowTreatment(N node, TreeIndexPath<E> path)
node
- the node where an overflow occurredpath
- the path to the specified node
private N split(N node)
node
- the node to be splitted
private void reInsert(N node, int level, TreeIndexPath<E> path)
node
- the node to be reinsertedlevel
- the level of the nodepath
- the path to the nodeprivate void adjustTree(TreeIndexPath<E> subtree)
subtree
- the subtree to be adjustedprivate void condenseTree(TreeIndexPath<E> subtree, Stack<N> stack)
subtree
- the subtree to be condensedstack
- the stack holding the nodes to be reinserted after the tree
has been condensedprivate void getLeafNodes(N node, List<E> result, int currentLevel)
node
- the subtreeresult
- the result to store the ids incurrentLevel
- the level of the node in the R-Treeprivate TreeIndexPath<E> createNewRoot(N oldRoot, N newNode)
oldRoot
- the old root of this RTreenewNode
- the new split node
|
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |