|
|
|||||||||||||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.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.metrical.MetricalIndex<O,D,N,E> de.lmu.ifi.dbs.elki.index.tree.metrical.mtreevariants.AbstractMTree<O,D,N,E>
public abstract class AbstractMTree<O extends DatabaseObject,D extends Distance<D>,N extends AbstractMTreeNode<O,D,N,E>,E extends MTreeEntry<D>>
Abstract super class for all M-Tree variants.
Nested Class Summary | |
---|---|
private class |
AbstractMTree.SplitResult
Encapsulates a split object and the newly created node- |
Field Summary | |
---|---|
static String |
DEFAULT_DISTANCE_FUNCTION
The default distance function. |
static String |
DISTANCE_FUNCTION_D
Description for parameter distance function. |
static String |
DISTANCE_FUNCTION_P
Parameter for distance function. |
private DistanceFunction<O,D> |
distanceFunction
The distance function. |
Fields inherited from class de.lmu.ifi.dbs.elki.index.tree.TreeIndex |
---|
CACHE_SIZE_D, CACHE_SIZE_P, cacheSize, DEFAULT_CACHE_SIZE, DEFAULT_PAGE_SIZE, dirCapacity, dirMinimum, file, FILE_NAME_D, FILE_NAME_P, initialized, leafCapacity, leafMinimum, PAGE_SIZE_D, PAGE_SIZE_P, 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 |
Constructor Summary | |
---|---|
AbstractMTree()
Empty constructor. |
Method Summary | |
---|---|
private void |
adjustTree(TreeIndexPath<E> subtree)
Adjusts the tree after insertion of some nodes. |
protected void |
batchNN(N node,
List<Integer> ids,
Map<Integer,KNNList<D>> knnLists)
Performs a batch knn query. |
protected TreeIndexPath<E> |
choosePath(Integer objectID,
TreeIndexPath<E> subtree)
Chooses the best path of the specified subtree for insertion of the given object. |
protected void |
createEmptyRoot(O object)
Creates an empty root node and writes it to file. |
protected abstract E |
createNewDirectoryEntry(N node,
Integer routingObjectID,
D parentDistance)
Creates a new directory entry representing the specified node. |
protected abstract E |
createNewLeafEntry(O object,
D parentDistance)
Creates a new leaf entry representing the specified data object in the specified subtree. |
private TreeIndexPath<E> |
createNewRoot(N oldRoot,
N newNode,
Integer firstRoutingObjectID,
Integer secondRoutingObjectID)
Creates a new root node that points to the two specified child nodes and return the path to the new root. |
boolean |
delete(O o)
Deletes the specified obect from this index. |
protected D |
distance(Integer id1,
Integer id2)
Returns the distance between the two specified ids. |
protected void |
doKNNQuery(Integer q,
KNNList<D> knnList)
Performs a k-nearest neighbor query for the given NumberVector with the given parameter k and the according distance function. |
private void |
doRangeQuery(Integer o_p,
N node,
Integer q,
D r_q,
List<QueryResult<D>> result)
Performs a range query. |
List<AttributeSettings> |
getAttributeSettings()
Returns the parameter setting of the attributes. |
DistanceFunction<O,D> |
getDistanceFunction()
Returns the distance function. |
protected List<DistanceEntry<D,E>> |
getSortedEntries(N node,
Integer q)
Sorts the entries of the specified node according to their minimum distance to the specified object. |
protected List<DistanceEntry<D,E>> |
getSortedEntries(N node,
Integer[] ids)
Sorts the entries of the specified node according to their minimum distance to the specified objects. |
private List<DistanceEntry<D,E>> |
getSortedEntries(N node,
List<Integer> ids)
Sorts the entries of the specified node according to their minimum distance to the specified objects. |
private boolean |
hasOverflow(N node)
Returns true if in the specified node an overflow has occured, false otherwise. |
protected void |
initializeCapacities(O object,
boolean verbose)
Determines the maximum and minimum number of entries in a node. |
void |
insert(List<O> objects)
Inserts the specified objects into this index sequentially. |
void |
insert(O object)
Inserts the specified object into this M-Tree. |
protected void |
insert(O object,
boolean withPreInsert)
todo: do a bulk load for M-Tree and remove this method Inserts the specified object into this M-Tree. |
List<QueryResult<D>> |
kNNQuery(O object,
int k)
Performs a k-nearest neighbor query for the given NumberVector with the given parameter k and the according distance function. |
protected void |
postDelete(O o)
Performs necessary operations after deleting the specified object. |
List<QueryResult<D>> |
rangeQuery(O object,
String epsilon)
Performs a range query for the given spatial object with the given epsilon range and the according distance function. |
List<QueryResult<D>> |
reverseKNNQuery(O object,
int k)
Performs a reverse k-nearest neighbor query for the given object ID. |
void |
setDatabase(Database<O> database)
Sets the databse in the distance function of this index (if existing). |
String[] |
setParameters(String[] args)
Sets the attributes of the class accordingly to the given parameters. |
private AbstractMTree.SplitResult |
split(N node)
Splits the specified node and returns the split result. |
String |
toString()
Returns a string representation of this RTree. |
Methods inherited from class de.lmu.ifi.dbs.elki.index.tree.TreeIndex |
---|
close, createHeader, createNewDirectoryNode, createNewLeafNode, createRootEntry, description, getLogicalPageAccess, getNode, getNode, getPhysicalReadAccess, getPhysicalWriteAccess, getRoot, getRootEntry, getRootPath, initialize, initializeFromFile, preInsert, resetPageAccess |
Methods inherited from class de.lmu.ifi.dbs.elki.utilities.optionhandling.AbstractParameterizable |
---|
addOption, checkGlobalParameterConstraints, deleteOption, description, description, getParameters, getParameterValue, getPossibleOptions, inlineDescription, isSet, setParameters |
Methods inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable |
---|
debugFine, debugFiner, debugFinest, exception, message, progress, progress, progress, verbose, 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, getParameters, getPossibleOptions, inlineDescription |
Field Detail |
---|
public static final String DEFAULT_DISTANCE_FUNCTION
public static final String DISTANCE_FUNCTION_P
public static final String DISTANCE_FUNCTION_D
private DistanceFunction<O extends DatabaseObject,D extends Distance<D>> distanceFunction
Constructor Detail |
---|
public AbstractMTree()
Method Detail |
---|
public void insert(O object)
object
- the object to be inserted todo: in subclassespublic void insert(List<O> objects)
objects
- the objects to be insertedpublic final boolean delete(O o)
o
- the object to be deleted
protected final void postDelete(O o)
postDelete
in class TreeIndex<O extends DatabaseObject,N extends AbstractMTreeNode<O,D,N,E>,E extends MTreeEntry<D>>
o
- the object to be deletedpublic List<QueryResult<D>> rangeQuery(O object, String epsilon)
rangeQuery
in class MetricalIndex<O extends DatabaseObject,D extends Distance<D>,N extends AbstractMTreeNode<O,D,N,E>,E extends MTreeEntry<D>>
object
- the query objectepsilon
- the string representation of the query range
public List<QueryResult<D>> kNNQuery(O object, int k)
kNNQuery
in class MetricalIndex<O extends DatabaseObject,D extends Distance<D>,N extends AbstractMTreeNode<O,D,N,E>,E extends MTreeEntry<D>>
object
- the query objectk
- the number of nearest neighbors to be returned
public List<QueryResult<D>> reverseKNNQuery(O object, int k)
reverseKNNQuery
in class MetricalIndex<O extends DatabaseObject,D extends Distance<D>,N extends AbstractMTreeNode<O,D,N,E>,E extends MTreeEntry<D>>
object
- the query objectk
- the number of nearest neighbors to be returned
public final DistanceFunction<O,D> getDistanceFunction()
getDistanceFunction
in class MetricalIndex<O extends DatabaseObject,D extends Distance<D>,N extends AbstractMTreeNode<O,D,N,E>,E extends MTreeEntry<D>>
public String toString()
toString
in class Object
public String[] setParameters(String[] args) throws ParameterException
Parameterizable
setParameters
in interface Parameterizable
setParameters
in class TreeIndex<O extends DatabaseObject,N extends AbstractMTreeNode<O,D,N,E>,E extends MTreeEntry<D>>
args
- parameters to set the attributes accordingly to
ParameterException
- in case of wrong parameter-settingParameterizable.setParameters(String[])
public List<AttributeSettings> getAttributeSettings()
getAttributeSettings
in interface Parameterizable
getAttributeSettings
in class AbstractParameterizable
Parameterizable.getAttributeSettings()
public final void setDatabase(Database<O> database)
database
- the databaseprotected void insert(O object, boolean withPreInsert)
object
- the object to be insertedwithPreInsert
- if this flag is true, the preInsert method will be called
before inserting the objectprotected final void createEmptyRoot(O object)
TreeIndex
createEmptyRoot
in class TreeIndex<O extends DatabaseObject,N extends AbstractMTreeNode<O,D,N,E>,E extends MTreeEntry<D>>
object
- an object that will be stored in the indexTreeIndex.createEmptyRoot(de.lmu.ifi.dbs.elki.data.DatabaseObject)
protected final void doKNNQuery(Integer q, KNNList<D> knnList)
q
- the id of the query objectknnList
- the query result listprotected TreeIndexPath<E> choosePath(Integer objectID, TreeIndexPath<E> subtree)
subtree
- the subtree to be tested for insertionobjectID
- the id of the obbject to be inserted
protected final void batchNN(N node, List<Integer> ids, Map<Integer,KNNList<D>> knnLists)
node
- the node for which the query should be performedids
- the ids of th query objectsknnLists
- the knn lists of the query objcetsprotected void initializeCapacities(O object, boolean verbose)
TreeIndex
initializeCapacities
in class TreeIndex<O extends DatabaseObject,N extends AbstractMTreeNode<O,D,N,E>,E extends MTreeEntry<D>>
object
- an object that will be stored in the indexverbose
- flag to allow verbose messagesTreeIndex.initializeCapacities(DatabaseObject,boolean)
protected final List<DistanceEntry<D,E>> getSortedEntries(N node, Integer q)
node
- the nodeq
- the id of the object
protected final List<DistanceEntry<D,E>> getSortedEntries(N node, Integer[] ids)
node
- the nodeids
- the ids of the objects
protected abstract E createNewLeafEntry(O object, D parentDistance)
object
- the data object to be represented by the new entryparentDistance
- the distance from the object to the routing object of the
parent node
protected abstract E createNewDirectoryEntry(N node, Integer routingObjectID, D parentDistance)
node
- the node to be represented by the new entryroutingObjectID
- the id of the routing object of the nodeparentDistance
- the distance from the routing object of the node to the
routing object of the parent node
private AbstractMTree.SplitResult split(N node)
node
- the node to be splitted
private List<DistanceEntry<D,E>> getSortedEntries(N node, List<Integer> ids)
node
- the nodeids
- the ids of the objects
private void doRangeQuery(Integer o_p, N node, Integer q, D r_q, List<QueryResult<D>> result)
o_p
- the routing object of the specified nodenode
- the root of the subtree to be traversedq
- the id of the query objectr_q
- the query rangeresult
- the list holding the query resultsprivate void adjustTree(TreeIndexPath<E> subtree)
subtree
- the subtree to be adjustedprivate boolean hasOverflow(N node)
node
- the node to be tested for overflow
private TreeIndexPath<E> createNewRoot(N oldRoot, N newNode, Integer firstRoutingObjectID, Integer secondRoutingObjectID)
oldRoot
- the old root of this RTreenewNode
- the new split nodefirstRoutingObjectID
- the id of the routing objects of the first child nodesecondRoutingObjectID
- the id of the routing objects of the second child node
protected D distance(Integer id1, Integer id2)
id1
- the first idid2
- the second id
|
|
||||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |