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>
distanceQuery
The distance query.private Relation<O>
relation
The 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 MTreeEntry
createNewLeafEntry(DBID id, O object, double parentDistance)
boolean
delete(DBIDRef id)
Throws an UnsupportedOperationException since deletion of objects is not yet supported by an M-Tree.void
deleteAll(DBIDs ids)
Throws an UnsupportedOperationException since deletion of objects is not yet supported by an M-Tree.double
distance(DBIDRef id1, DBIDRef id2)
Returns the distance between the two specified ids.void
initialize()
Initialize the tree if the page file already existed.protected void
initializeCapacities(MTreeEntry exampleLeaf)
Determines the maximum and minimum number of entries in a node.void
insert(DBIDRef id)
Inserts the specified object into this index.void
insertAll(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:AbstractMTree
Returns the distance between the two specified ids.- Specified by:
distance
in 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:IndexTree
Determines the maximum and minimum number of entries in a node.- Specified by:
initializeCapacities
in 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:IndexTree
Initialize the tree if the page file already existed.- Specified by:
initialize
in interfaceIndex
- Overrides:
initialize
in classIndexTree<MTreeNode<O>,MTreeEntry>
-
insert
public void insert(DBIDRef id)
Description copied from interface:DynamicIndex
Inserts the specified object into this index.- Specified by:
insert
in interfaceDynamicIndex
- Parameters:
id
- the object to be inserted
-
insertAll
public void insertAll(DBIDs ids)
Description copied from interface:DynamicIndex
Inserts the specified objects into this index. If a bulk load mode is implemented, the objects are inserted in one bulk.- Specified by:
insertAll
in 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:
delete
in 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:
deleteAll
in 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:KNNIndex
Get 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:
kNNByObject
in 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:KNNIndex
Get 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:RangeIndex
Get 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:
rangeByObject
in 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:RangeIndex
Get 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:
rangeByDBID
in interfaceRangeIndex<O>
- Parameters:
distanceQuery
- Distance querymaxradius
- Maximum rangeflags
- Hints for the optimizer- Returns:
- KNN Query object or
null
-
-