diff --git a/src/mhtree/MHTree.java b/src/mhtree/MHTree.java index e033b49ff9df30efd742fc70702a506a30068083..fd57ecbcc5014c4ed9ee4d4064d3abbb5db73a53 100644 --- a/src/mhtree/MHTree.java +++ b/src/mhtree/MHTree.java @@ -35,7 +35,7 @@ public class MHTree extends Algorithm implements Serializable { /** * Minimal number of objects in leaf node's bucket. */ - private final int leafCapacity; + private final int bucketCapacity; /** * Arity @@ -52,7 +52,7 @@ public class MHTree extends Algorithm implements Serializable { private MHTree(Builder builder) { super("MH-Tree"); - leafCapacity = builder.leafCapacity; + bucketCapacity = builder.bucketCapacity; arity = builder.arity; bucketDispatcher = builder.bucketDispatcher; @@ -192,7 +192,7 @@ public class MHTree extends Algorithm implements Serializable { .mapToInt(LeafNode::getObjectCount) .summaryStatistics(); - System.out.println("Leaf object capacity: " + leafCapacity); + System.out.println("Bucket capacity: " + bucketCapacity); System.out.println("Node degree: " + arity); System.out.println("Object to node distance measurement: " + objectToNodeDistance); System.out.println("Insert type: " + insertType); @@ -218,7 +218,7 @@ public class MHTree extends Algorithm implements Serializable { @Override public String toString() { return "MHTree{" + - "leafCapacity=" + leafCapacity + + "bucketCapacity=" + bucketCapacity + ", nodeDegree=" + arity + ", insertType=" + insertType + ", objectToNodeDistance=" + objectToNodeDistance + @@ -235,7 +235,7 @@ public class MHTree extends Algorithm implements Serializable { /** * Minimal number of objects in leaf node's bucket. */ - private final int leafCapacity; + private final int bucketCapacity; /** * Maximal degree of internal node. @@ -287,14 +287,14 @@ public class MHTree extends Algorithm implements Serializable { */ private Node root; - public Builder(List<LocalAbstractObject> objects, int leafCapacity, int arity) { + public Builder(List<LocalAbstractObject> objects, int bucketCapacity, int arity) { this.objects = objects; - this.leafCapacity = leafCapacity; + this.bucketCapacity = bucketCapacity; this.arity = arity; this.insertType = InsertType.GREEDY; this.objectToNodeDistance = ObjectToNodeDistance.NEAREST; - this.bucketDispatcher = new BucketDispatcher(Integer.MAX_VALUE, Long.MAX_VALUE, leafCapacity, 0, false, MemoryStorageBucket.class, null); + this.bucketDispatcher = new BucketDispatcher(Integer.MAX_VALUE, Long.MAX_VALUE, bucketCapacity, 0, false, MemoryStorageBucket.class, null); this.mergeType = MergeType.HULL_BASED; } @@ -314,7 +314,7 @@ public class MHTree extends Algorithm implements Serializable { } public Builder bucketDispatcher(Class<? extends LocalBucket> defaultBucketClass, Map<String, Object> bucketClassParams) { - this.bucketDispatcher = new BucketDispatcher(Integer.MAX_VALUE, Long.MAX_VALUE, leafCapacity, 0, false, defaultBucketClass, bucketClassParams); + this.bucketDispatcher = new BucketDispatcher(Integer.MAX_VALUE, Long.MAX_VALUE, bucketCapacity, 0, false, defaultBucketClass, bucketClassParams); return this; } @@ -324,7 +324,7 @@ public class MHTree extends Algorithm implements Serializable { } public MHTree build() throws BucketStorageException { - nodes = new Node[objects.size() / leafCapacity]; + nodes = new Node[objects.size() / bucketCapacity]; validNodeIndices = new BitSet(nodes.length); validNodeIndices.set(0, nodes.length); @@ -332,12 +332,12 @@ public class MHTree extends Algorithm implements Serializable { objectDistances = new AbstractRepresentation.PrecomputedDistances(objects); // Every object is stored in the root - if (objectDistances.getObjectCount() <= leafCapacity) { + if (objectDistances.getObjectCount() <= bucketCapacity) { root = new LeafNode(objectDistances, bucketDispatcher.createBucket(), insertType, objectToNodeDistance); return new MHTree(this); } - createLeafNodes(leafCapacity); + createLeafNodes(bucketCapacity); nodeDistances = new PrecomputedNodeDistances(); @@ -377,12 +377,12 @@ public class MHTree extends Algorithm implements Serializable { return nodes[validNodeIndices.nextSetBit(0)]; } - private void createLeafNodes(int leafCapacity) throws BucketStorageException { + private void createLeafNodes(int bucketCapacity) throws BucketStorageException { BitSet notProcessedObjectIndices = new BitSet(objectDistances.getObjectCount()); notProcessedObjectIndices.set(0, objectDistances.getObjectCount()); for (int nodeIndex = 0; !notProcessedObjectIndices.isEmpty(); nodeIndex++) { - if (notProcessedObjectIndices.cardinality() < leafCapacity) { + if (notProcessedObjectIndices.cardinality() < bucketCapacity) { for (int i = notProcessedObjectIndices.nextSetBit(0); i >= 0; i = notProcessedObjectIndices.nextSetBit(i + 1)) { LocalAbstractObject object = objectDistances.getObject(i); nodes[getClosestNodeIndex(object)].addObject(object); @@ -391,15 +391,15 @@ public class MHTree extends Algorithm implements Serializable { return; } - List<Integer> objectIndices = new ArrayList<>(leafCapacity); + List<Integer> objectIndices = new ArrayList<>(bucketCapacity); // Select the furthest object (the outlier) int furthestIndex = Utils.maxDistanceIndex(objectDistances.getDistances(), notProcessedObjectIndices); notProcessedObjectIndices.clear(furthestIndex); objectIndices.add(furthestIndex); - // Select the rest of the objects up to the total of leafCapacity with respect to the building of a hull - objectIndices.addAll(findClosestItems(this::findClosestObjectIndex, furthestIndex, leafCapacity - 1, notProcessedObjectIndices)); + // Select the rest of the objects up to the total of bucketCapacity with respect to the building of a hull + objectIndices.addAll(findClosestItems(this::findClosestObjectIndex, furthestIndex, bucketCapacity - 1, notProcessedObjectIndices)); List<LocalAbstractObject> objects = objectIndices .stream()