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

FIX: better variable names

parent 00dd4495
No related branches found
No related tags found
No related merge requests found
......@@ -51,48 +51,47 @@ public class MHTree extends Algorithm implements Serializable {
}
public void approxKNN(ApproxKNNQueryOperation operation) {
LocalAbstractObject object = operation.getQueryObject();
LocalAbstractObject queryObject = operation.getQueryObject();
PriorityQueue<ObjectToNodeDistanceRank> queue = new PriorityQueue<>();
queue.add(new ObjectToNodeDistanceRank(root, object));
queue.add(new ObjectToNodeDistanceRank(queryObject, root));
while (!queue.isEmpty()) {
Node currentNode = queue.poll().getNode();
Node node = queue.poll().getNode();
if (currentNode.isLeaf()) {
for (LocalAbstractObject obj : currentNode.getObjects()) {
if (operation.getAnswerCount() >= operation.getK() && currentNode.getDistance(object) > operation.getAnswerDistance())
if (node.isLeaf()) {
for (LocalAbstractObject object : node.getObjects()) {
if (operation.getAnswerCount() >= operation.getK() && object.getDistance(queryObject) > operation.getAnswerDistance())
continue;
operation.addToAnswer(obj);
operation.addToAnswer(object);
}
if (operation.getAnswerCount() >= operation.getK())
break;
} else {
for (Node child : ((InternalNode) currentNode).getChildren())
queue.add(new ObjectToNodeDistanceRank(child, object));
for (Node child : ((InternalNode) node).getChildren())
queue.add(new ObjectToNodeDistanceRank(queryObject, child));
}
}
operation.endOperation();
}
public boolean insert(InsertOperation operation) throws BucketStorageException {
public void insert(InsertOperation operation) throws BucketStorageException {
LocalAbstractObject object = operation.getInsertedObject();
Node currentNode = root;
Node node = root;
while (!currentNode.isLeaf()) {
currentNode.addObject(object);
while (!node.isLeaf()) {
node.addObject(object);
currentNode = ((InternalNode) currentNode).getNearestChild(object);
node = ((InternalNode) node).getNearestChild(object);
}
currentNode.addObject(object);
node.addObject(object);
operation.endOperation(BucketErrorCode.OBJECT_INSERTED);
return true;
}
public void printStatistics() {
......
......@@ -8,7 +8,7 @@ public class ObjectToNodeDistanceRank implements Comparable<ObjectToNodeDistance
private final LocalAbstractObject object;
private final double distance;
public ObjectToNodeDistanceRank(Node node, LocalAbstractObject object) {
public ObjectToNodeDistanceRank(LocalAbstractObject object, Node node) {
this.node = node;
this.object = object;
this.distance = node.getDistance(object);
......
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