mtree
Class MTree

java.lang.Object
  extended by messif.algorithms.Algorithm
      extended by mtree.MTree
All Implemented Interfaces:
java.io.Serializable

public class MTree
extends messif.algorithms.Algorithm
implements java.io.Serializable

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class messif.algorithms.Algorithm
messif.algorithms.Algorithm.AlgorithmConstructor
 
Field Summary
static java.util.concurrent.atomic.AtomicInteger nextMTreeHash
          unique hash for M-tree (unique hash is used by statistics)
 java.util.List<messif.objects.LocalAbstractObject> refusedObjects
          set of refused objects (objects which are refused by M-tree, using by M-tree forest)
 
Fields inherited from class messif.algorithms.Algorithm
algorithmName, bgExecutionList, log, maximalConcurrentOperations, operationExecutor, runningOperations
 
Constructor Summary
MTree()
          Constructors of M-tree
MTree(int pivotCount, messif.objects.StreamGenericAbstractObjectIterator<messif.objects.LocalAbstractObject> pivotIterator)
          Constructors of PM-tree
MTree(long intNodeCap, long leafCap)
           
MTree(long intNodeCap, long leafCap, double maxLeafRadius, double maxFatFactor, int minReorganizeLeaf, double insRadius, int maxSpanningTree, boolean isAlgorithmInBucket, long intNodeCapInBucketAlgorithm, long leafCapInBucketAlgorithm)
           
MTree(long intNodeCap, long leafCap, int pivotCount, messif.objects.StreamGenericAbstractObjectIterator<messif.objects.LocalAbstractObject> pivotIterator, int npd, int nhr)
           
MTree(long intNodeCap, long leafCap, int pivotCount, messif.objects.StreamGenericAbstractObjectIterator<messif.objects.LocalAbstractObject> pivotIterator, int npd, int nhr, double maxLeafRadius, double maxFatFactor, int minReorganizeLeaf, double insRadius, int maxSpanningTree, boolean isAlgorithmInBucket, long intNodeCapInBucketAlgorithm, long leafCapInBucketAlgorithm)
           
 
Method Summary
 java.util.List<messif.buckets.LocalBucket> getAllBuckets()
           
 boolean getAllObjectsQueryOperation(messif.operations.GetAllObjectsQueryOperation qo)
          Looks for all objects in the tree.
 messif.buckets.BucketDispatcher getBucketDispatcher()
           
 double getGlobalFatFactor()
          Computes the global fat-factor.
protected  double getLocalFatFactor(Node n)
          Computes the fat-factor of the given subtree.
 Node getRoot()
           
 messif.statistics.StatisticRefCounter getStatNodeDC()
           
 int hashCode()
          Overrided methods of the class Object
 boolean incrementalNN(messif.operations.IncrementalNNQueryOperation incOper)
          Looks for objects which are nearest to the given object.
 boolean insert(messif.operations.InsertOperation insOper)
          Inserts a new object in the tree.
 boolean kNN(messif.operations.kNNQueryOperation kNNOper)
          Looks for objects which are nearest to the given object.
static MTree loadFromFile(java.lang.String fileName)
           
protected  void print(Node n)
          Recursive method for printTree.
 void printStatistics()
          Prints statistics of whole the tree (number of nodes, number of slim nodes - nodes with only one inserted object, number of all objects).
 void printTree()
          Prints a structure of the whole tree (all nodes with their objects).
 java.util.Map<messif.buckets.LocalBucket,messif.operations.RangeQueryOperation> rangeSearch(messif.operations.RangeQueryOperation rqo)
          Looks for all objects incident to the region R(q, r).
 void saveToFile(java.lang.String fileName)
          Saves M-tree into file specified by filename.
 void setDefaultBucketClass(java.lang.Class<? extends messif.buckets.LocalFilteredBucket> defaultBucketClass)
          Sets the default bucket class used by bucket dispatcher.
 void setMaximumFatFactor(double d)
          Sets the maximum fat-factor of nodes with level 1.
 void setMaximumLeafRadius(double r)
          Sets the maximum leaf radius.
 void setMinimumReorganizeLeaf(int minReorganizeLeaf)
          Sets the minimum leafs which have to be selected to reorganize.
 java.lang.String toString()
           
 
Methods inherited from class messif.algorithms.Algorithm
backgroundExecuteOperation, executeOperation, finalize, getAnnotatedConstructors, getConstructorArgumentDescriptions, getConstructorDescription, getConstructorDescriptionSimple, getExecutorParamClasses, getName, getRunningOperationsCount, getSupportedOperations, getSupportedOperations, initializeExecutor, restoreFromFile, restoreFromFile, storeToFile, waitBackgroundExecuteOperation, waitBackgroundExecuteOperation
 
Methods inherited from class java.lang.Object
clone, equals, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

nextMTreeHash

public static java.util.concurrent.atomic.AtomicInteger nextMTreeHash
unique hash for M-tree (unique hash is used by statistics)


refusedObjects

public java.util.List<messif.objects.LocalAbstractObject> refusedObjects
set of refused objects (objects which are refused by M-tree, using by M-tree forest)

Constructor Detail

MTree

public MTree()
      throws java.lang.InstantiationException
Constructors of M-tree

Throws:
java.lang.InstantiationException

MTree

public MTree(long intNodeCap,
             long leafCap)
      throws java.lang.InstantiationException
Throws:
java.lang.InstantiationException

MTree

public MTree(long intNodeCap,
             long leafCap,
             double maxLeafRadius,
             double maxFatFactor,
             int minReorganizeLeaf,
             double insRadius,
             int maxSpanningTree,
             boolean isAlgorithmInBucket,
             long intNodeCapInBucketAlgorithm,
             long leafCapInBucketAlgorithm)
      throws java.lang.InstantiationException,
             messif.algorithms.AlgorithmMethodException
Throws:
java.lang.InstantiationException
messif.algorithms.AlgorithmMethodException

MTree

public MTree(int pivotCount,
             messif.objects.StreamGenericAbstractObjectIterator<messif.objects.LocalAbstractObject> pivotIterator)
      throws java.lang.InstantiationException
Constructors of PM-tree

Throws:
java.lang.InstantiationException

MTree

public MTree(long intNodeCap,
             long leafCap,
             int pivotCount,
             messif.objects.StreamGenericAbstractObjectIterator<messif.objects.LocalAbstractObject> pivotIterator,
             int npd,
             int nhr)
      throws java.lang.InstantiationException,
             messif.algorithms.AlgorithmMethodException
Throws:
java.lang.InstantiationException
messif.algorithms.AlgorithmMethodException

MTree

public MTree(long intNodeCap,
             long leafCap,
             int pivotCount,
             messif.objects.StreamGenericAbstractObjectIterator<messif.objects.LocalAbstractObject> pivotIterator,
             int npd,
             int nhr,
             double maxLeafRadius,
             double maxFatFactor,
             int minReorganizeLeaf,
             double insRadius,
             int maxSpanningTree,
             boolean isAlgorithmInBucket,
             long intNodeCapInBucketAlgorithm,
             long leafCapInBucketAlgorithm)
      throws java.lang.InstantiationException,
             messif.algorithms.AlgorithmMethodException
Throws:
java.lang.InstantiationException
messif.algorithms.AlgorithmMethodException
Method Detail

getRoot

public Node getRoot()
Returns:
Returns the root of the tree.

getBucketDispatcher

public messif.buckets.BucketDispatcher getBucketDispatcher()
Returns:
Returns the bucket dispatcher of the tree.

setDefaultBucketClass

public void setDefaultBucketClass(java.lang.Class<? extends messif.buckets.LocalFilteredBucket> defaultBucketClass)
Sets the default bucket class used by bucket dispatcher.


getAllBuckets

public java.util.List<messif.buckets.LocalBucket> getAllBuckets()
Returns:
Returns all buckets of the tree.

getAllObjectsQueryOperation

public boolean getAllObjectsQueryOperation(messif.operations.GetAllObjectsQueryOperation qo)
Looks for all objects in the tree.


rangeSearch

public java.util.Map<messif.buckets.LocalBucket,messif.operations.RangeQueryOperation> rangeSearch(messif.operations.RangeQueryOperation rqo)
Looks for all objects incident to the region R(q, r).

Returns:
Return map with nodes and all found objects (incident to the region R(q, r)) in these found nodes.

kNN

public boolean kNN(messif.operations.kNNQueryOperation kNNOper)
            throws messif.algorithms.AlgorithmMethodException
Looks for objects which are nearest to the given object.

Throws:
messif.algorithms.AlgorithmMethodException - when all objects have already been returned and operation is run again.

incrementalNN

public boolean incrementalNN(messif.operations.IncrementalNNQueryOperation incOper)
                      throws messif.algorithms.AlgorithmMethodException
Looks for objects which are nearest to the given object.

Throws:
messif.algorithms.AlgorithmMethodException - when all objects have already been returned and operation is run again.

insert

public boolean insert(messif.operations.InsertOperation insOper)
Inserts a new object in the tree. If the M-tree forest is used then some objects (after insertion of a new object) can be removed from this tree and moved to refusedObjects.

Returns:
Returns false if a new object isn't inserted in the tree (object can be refused due to set maximum leaf radius or maximum fat-factor).

saveToFile

public void saveToFile(java.lang.String fileName)
Saves M-tree into file specified by filename.


loadFromFile

public static MTree loadFromFile(java.lang.String fileName)
Returns:
Returns loaded M-tree from file specified by filename.

setMaximumLeafRadius

public void setMaximumLeafRadius(double r)
Sets the maximum leaf radius.

Parameters:
r - If parameter is set to -1 then maximum leaf radius is not considered.

setMaximumFatFactor

public void setMaximumFatFactor(double d)
Sets the maximum fat-factor of nodes with level 1.

Parameters:
d - If parameter is set to -1 then maximum fat-factor is not considered.

setMinimumReorganizeLeaf

public void setMinimumReorganizeLeaf(int minReorganizeLeaf)
Sets the minimum leafs which have to be selected to reorganize. If new object is inserting and more then minReorganizeLeaf convenient leafs exists then some object from the tree is refused and put into refusedObjects.


getGlobalFatFactor

public double getGlobalFatFactor()
Computes the global fat-factor.


getLocalFatFactor

protected double getLocalFatFactor(Node n)
Computes the fat-factor of the given subtree.


getStatNodeDC

public messif.statistics.StatisticRefCounter getStatNodeDC()
Returns:
Returns a statistic of distance computations in the particular nodes.

printStatistics

public void printStatistics()
Prints statistics of whole the tree (number of nodes, number of slim nodes - nodes with only one inserted object, number of all objects).


printTree

public void printTree()
Prints a structure of the whole tree (all nodes with their objects).


print

protected void print(Node n)
Recursive method for printTree.


hashCode

public int hashCode()
Overrided methods of the class Object

Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object