Skip to content
Snippets Groups Projects
Verified Commit 64dadd3f authored by David Procházka's avatar David Procházka
Browse files

ADD: MH-Tree javadocs

parent 1dc06d06
No related branches found
No related tags found
No related merge requests found
...@@ -25,6 +25,9 @@ import static mhtree.InsertType.GREEDY; ...@@ -25,6 +25,9 @@ import static mhtree.InsertType.GREEDY;
import static mhtree.MergingMethod.HULL_BASED_MERGE; import static mhtree.MergingMethod.HULL_BASED_MERGE;
import static mhtree.ObjectToNodeDistance.NEAREST; import static mhtree.ObjectToNodeDistance.NEAREST;
/**
* MH-Tree is a metric index utilizing metric hulls.
*/
public class MHTree extends Algorithm implements Serializable { public class MHTree extends Algorithm implements Serializable {
/** /**
...@@ -33,19 +36,40 @@ public class MHTree extends Algorithm implements Serializable { ...@@ -33,19 +36,40 @@ public class MHTree extends Algorithm implements Serializable {
private static final long serialVersionUID = 42L; private static final long serialVersionUID = 42L;
/** /**
* Minimal number of objects in leaf node's bucket. * The minimal number of objects in a bucket of a leaf node.
*/ */
private final int bucketCapacity; private final int bucketCapacity;
/** /**
* Arity * The maximal degree of an internal node.
*/ */
private final int arity; private final int arity;
/**
* The root node of MH-Tree.
*/
private final Node root; private final Node root;
/**
* Specifies which method to use when adding a new object.
*/
private final InsertType insertType; private final InsertType insertType;
/**
* Specifies how to measure distance between an object and a node.
*/
private final ObjectToNodeDistance objectToNodeDistance; private final ObjectToNodeDistance objectToNodeDistance;
/**
* A dispatcher for maintaining a set of local buckets.
*/
private final BucketDispatcher bucketDispatcher; private final BucketDispatcher bucketDispatcher;
/**
* Create a new MH-Tree.
*
* @param builder the result of MH-Tree bulk-loading algorithm
*/
@AlgorithmConstructor(description = "MH-Tree", arguments = { @AlgorithmConstructor(description = "MH-Tree", arguments = {
"MH-Tree builder object", "MH-Tree builder object",
}) })
...@@ -129,18 +153,21 @@ public class MHTree extends Algorithm implements Serializable { ...@@ -129,18 +153,21 @@ public class MHTree extends Algorithm implements Serializable {
operation.endOperation(); operation.endOperation();
} }
public Node getRoot() { /**
return root; * Returns the number of objects in the tree.
} *
* @return the number of objects in the tree
*/
public int getObjectCount() { public int getObjectCount() {
return bucketDispatcher.getObjectCount(); return bucketDispatcher.getObjectCount();
} }
public List<LocalAbstractObject> getObjects() { /**
return root.getObjects(); * Inserts a new object into the tree.
} *
* @param operation contains the inserted object
* @throws BucketStorageException when adding the object into a node
*/
public void insert(InsertOperation operation) throws BucketStorageException { public void insert(InsertOperation operation) throws BucketStorageException {
LocalAbstractObject object = operation.getInsertedObject(); LocalAbstractObject object = operation.getInsertedObject();
...@@ -179,6 +206,9 @@ public class MHTree extends Algorithm implements Serializable { ...@@ -179,6 +206,9 @@ public class MHTree extends Algorithm implements Serializable {
return leafNodes; return leafNodes;
} }
/**
* Prints statistics about the tree.
*/
public void printStatistics() { public void printStatistics() {
List<Node> nodes = getNodes(); List<Node> nodes = getNodes();
...@@ -215,6 +245,10 @@ public class MHTree extends Algorithm implements Serializable { ...@@ -215,6 +245,10 @@ public class MHTree extends Algorithm implements Serializable {
leafNodeObjects.getMax()); leafNodeObjects.getMax());
} }
public Node getRoot() {
return root;
}
@Override @Override
public String toString() { public String toString() {
return "MHTree{" + return "MHTree{" +
...@@ -236,12 +270,12 @@ public class MHTree extends Algorithm implements Serializable { ...@@ -236,12 +270,12 @@ public class MHTree extends Algorithm implements Serializable {
private final List<LocalAbstractObject> objects; private final List<LocalAbstractObject> objects;
/** /**
* Minimal number of objects in bucket of a leaf node. * The minimal number of objects in a bucket of a leaf node.
*/ */
private final int bucketCapacity; private final int bucketCapacity;
/** /**
* Maximal degree of an internal node. * The maximal degree of an internal node.
*/ */
private final int arity; private final int arity;
...@@ -261,17 +295,17 @@ public class MHTree extends Algorithm implements Serializable { ...@@ -261,17 +295,17 @@ public class MHTree extends Algorithm implements Serializable {
private BucketDispatcher bucketDispatcher; private BucketDispatcher bucketDispatcher;
/** /**
* Specifies the merging strategy. * Specifies the merging method.
*/ */
private MergingMethod mergingMethod; private MergingMethod mergingMethod;
/** /**
* Precomputed object distances. * Contains the object distance matrix.
*/ */
private AbstractRepresentation.PrecomputedDistances objectDistances; private AbstractRepresentation.PrecomputedDistances objectDistances;
/** /**
* Stores intermediate nodes. * Stores intermediate nodes needed during the algorithm.
*/ */
private Node[] nodes; private Node[] nodes;
...@@ -281,12 +315,12 @@ public class MHTree extends Algorithm implements Serializable { ...@@ -281,12 +315,12 @@ public class MHTree extends Algorithm implements Serializable {
private BitSet validNodeIndices; private BitSet validNodeIndices;
/** /**
* Precomputed node distances. * Contains the node distance matrix.
*/ */
private PrecomputedNodeDistances nodeDistances; private PrecomputedNodeDistances nodeDistances;
/** /**
* Root of MH-Tree. * The root node of MH-Tree.
*/ */
private Node root; private Node root;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment