Class MTreeIndex<O>
- java.lang.Object
-
- elki.index.tree.IndexTree<N,E>
-
- elki.index.tree.metrical.MetricalIndexTree<O,N,E>
-
- elki.index.tree.metrical.mtreevariants.AbstractMTree<O,MTreeNode<O>,MTreeEntry,MTreeSettings<O,MTreeNode<O>,MTreeEntry>>
-
- elki.index.tree.metrical.mtreevariants.mtree.MTree<O>
-
- elki.index.tree.metrical.mtreevariants.mtree.MTreeIndex<O>
-
- Type Parameters:
O- Object type
- All Implemented Interfaces:
DynamicIndex,Index,KNNIndex<O>,RangeIndex<O>
public class MTreeIndex<O> extends MTree<O> implements RangeIndex<O>, KNNIndex<O>, DynamicIndex
Class for using an m-tree as database index.- Since:
- 0.4.0
- Author:
- Erich Schubert
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class elki.index.tree.metrical.mtreevariants.AbstractMTree
AbstractMTree.Statistics
-
-
Field Summary
Fields Modifier and Type Field Description protected DistanceQuery<O>distanceQueryThe distance query.private Relation<O>relationThe relation indexed.-
Fields inherited from class elki.index.tree.metrical.mtreevariants.AbstractMTree
settings, statistics
-
Fields inherited from class elki.index.tree.IndexTree
dirCapacity, dirMinimum, initialized, leafCapacity, leafMinimum
-
-
Constructor Summary
Constructors Constructor Description MTreeIndex(Relation<O> relation, PageFile<MTreeNode<O>> pagefile, MTreeSettings<O,MTreeNode<O>,MTreeEntry> settings)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected MTreeEntrycreateNewLeafEntry(DBID id, O object, double parentDistance)booleandelete(DBIDRef id)Throws an UnsupportedOperationException since deletion of objects is not yet supported by an M-Tree.voiddeleteAll(DBIDs ids)Throws an UnsupportedOperationException since deletion of objects is not yet supported by an M-Tree.doubledistance(DBIDRef id1, DBIDRef id2)Returns the distance between the two specified ids.voidinitialize()Initialize the tree if the page file already existed.protected voidinitializeCapacities(MTreeEntry exampleLeaf)Determines the maximum and minimum number of entries in a node.voidinsert(DBIDRef id)Inserts the specified object into this index.voidinsertAll(DBIDs ids)Inserts the specified objects into this index.KNNSearcher<DBIDRef>kNNByDBID(DistanceQuery<O> distanceQuery, int maxk, int flags)Get a KNN query object for the given distance query and k.KNNSearcher<O>kNNByObject(DistanceQuery<O> distanceQuery, int maxk, int flags)Get a KNN query object for the given distance query and k.RangeSearcher<DBIDRef>rangeByDBID(DistanceQuery<O> distanceQuery, double maxradius, int flags)Get a range query object for the given distance query and k.RangeSearcher<O>rangeByObject(DistanceQuery<O> distanceQuery, double maxrange, int flags)Get a range query object for the given distance query and k.-
Methods inherited from class elki.index.tree.metrical.mtreevariants.mtree.MTree
createNewDirectoryEntry, createNewDirectoryNode, createNewLeafNode, createRootEntry, getLogger, preInsert
-
Methods inherited from class elki.index.tree.metrical.mtreevariants.AbstractMTree
createEmptyRoot, distance, doExtraIntegrityChecks, getDistance, getHeight, getLeaves, getSortedEntries, insert, insertAll, logStatistics, toString
-
Methods inherited from class elki.index.tree.IndexTree
createHeader, deleteNode, getFile, getNode, getNode, getPageID, getPageSize, getRootEntry, getRootID, getRootPath, initialize, initializeFromFile, isRoot, postDelete, writeNode
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface elki.index.Index
logStatistics
-
-
-
-
Field Detail
-
distanceQuery
protected DistanceQuery<O> distanceQuery
The distance query.
-
-
Constructor Detail
-
MTreeIndex
public MTreeIndex(Relation<O> relation, PageFile<MTreeNode<O>> pagefile, MTreeSettings<O,MTreeNode<O>,MTreeEntry> settings)
Constructor.- Parameters:
relation- Relation indexedpagefile- Page filesettings- Tree settings
-
-
Method Detail
-
distance
public double distance(DBIDRef id1, DBIDRef id2)
Description copied from class:AbstractMTreeReturns the distance between the two specified ids.- Specified by:
distancein classAbstractMTree<O,MTreeNode<O>,MTreeEntry,MTreeSettings<O,MTreeNode<O>,MTreeEntry>>- Parameters:
id1- the first idid2- the second id- Returns:
- the distance between the two specified ids
-
initializeCapacities
protected void initializeCapacities(MTreeEntry exampleLeaf)
Description copied from class:IndexTreeDetermines the maximum and minimum number of entries in a node.- Specified by:
initializeCapacitiesin classIndexTree<MTreeNode<O>,MTreeEntry>- Parameters:
exampleLeaf- an object that will be stored in the index
-
createNewLeafEntry
protected MTreeEntry createNewLeafEntry(DBID id, O object, double parentDistance)
- Returns:
- a new MTreeLeafEntry representing the specified data object
-
initialize
public void initialize()
Description copied from class:IndexTreeInitialize the tree if the page file already existed.- Specified by:
initializein interfaceIndex- Overrides:
initializein classIndexTree<MTreeNode<O>,MTreeEntry>
-
insert
public void insert(DBIDRef id)
Description copied from interface:DynamicIndexInserts the specified object into this index.- Specified by:
insertin interfaceDynamicIndex- Parameters:
id- the object to be inserted
-
insertAll
public void insertAll(DBIDs ids)
Description copied from interface:DynamicIndexInserts the specified objects into this index. If a bulk load mode is implemented, the objects are inserted in one bulk.- Specified by:
insertAllin interfaceDynamicIndex- Parameters:
ids- the objects to be inserted
-
delete
public final boolean delete(DBIDRef id)
Throws an UnsupportedOperationException since deletion of objects is not yet supported by an M-Tree.- Specified by:
deletein interfaceDynamicIndex- Parameters:
id- Object to remove- Returns:
- true if this index did contain the object, false otherwise
- Throws:
java.lang.UnsupportedOperationException- thrown, since deletions aren't implemented yet.
-
deleteAll
public void deleteAll(DBIDs ids)
Throws an UnsupportedOperationException since deletion of objects is not yet supported by an M-Tree.- Specified by:
deleteAllin interfaceDynamicIndex- Parameters:
ids- Objects to remove- Throws:
java.lang.UnsupportedOperationException- thrown, since deletions aren't implemented yet.
-
kNNByObject
public KNNSearcher<O> kNNByObject(DistanceQuery<O> distanceQuery, int maxk, int flags)
Description copied from interface:KNNIndexGet a KNN query object for the given distance query and k.This function MAY return null, when the given distance is not supported!
- Specified by:
kNNByObjectin interfaceKNNIndex<O>- Parameters:
distanceQuery- Distance querymaxk- Maximum value of kflags- Hints for the optimizer- Returns:
- KNN Query object or
null
-
kNNByDBID
public KNNSearcher<DBIDRef> kNNByDBID(DistanceQuery<O> distanceQuery, int maxk, int flags)
Description copied from interface:KNNIndexGet a KNN query object for the given distance query and k.This function MAY return null, when the given distance is not supported!
-
rangeByObject
public RangeSearcher<O> rangeByObject(DistanceQuery<O> distanceQuery, double maxrange, int flags)
Description copied from interface:RangeIndexGet a range query object for the given distance query and k.This function MAY return null, when the given distance is not supported!
- Specified by:
rangeByObjectin interfaceRangeIndex<O>- Parameters:
distanceQuery- Distance querymaxrange- Maximum rangeflags- Hints for the optimizer- Returns:
- KNN Query object or
null
-
rangeByDBID
public RangeSearcher<DBIDRef> rangeByDBID(DistanceQuery<O> distanceQuery, double maxradius, int flags)
Description copied from interface:RangeIndexGet a range query object for the given distance query and k.This function MAY return null, when the given distance is not supported!
- Specified by:
rangeByDBIDin interfaceRangeIndex<O>- Parameters:
distanceQuery- Distance querymaxradius- Maximum rangeflags- Hints for the optimizer- Returns:
- KNN Query object or
null
-
-