diff --git a/src/mhtree/benchmarking/PerformanceMeasures.java b/src/mhtree/benchmarking/PerformanceMeasures.java index 6cd84986df4bbdb8f9ad7c0ec58541a99ff7d556..88f04aaa3242f8f256938eee526819bb38c33bc1 100644 --- a/src/mhtree/benchmarking/PerformanceMeasures.java +++ b/src/mhtree/benchmarking/PerformanceMeasures.java @@ -1,12 +1,12 @@ package mhtree.benchmarking; +import messif.algorithms.Algorithm; +import messif.algorithms.AlgorithmMethodException; import messif.objects.util.DistanceRankedObject; import messif.objects.util.RankedAbstractObject; import messif.operations.query.ApproxKNNQueryOperation; import messif.operations.query.KNNQueryOperation; -import messif.utility.reflection.NoSuchInstantiatorException; -import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -16,13 +16,9 @@ import java.util.stream.Collectors; public class PerformanceMeasures { - public static double measureErrorOnThePosition(ApproxKNNQueryOperation approxKNNQueryOperation, Tree tree) { + public static double measureErrorOnThePosition(ApproxKNNQueryOperation approxKNNQueryOperation, Algorithm tree) throws NoSuchMethodException, AlgorithmMethodException { KNNQueryOperation rankedObjects = new KNNQueryOperation(approxKNNQueryOperation.getQueryObject(), tree.getObjectCount()); - try { - tree.kNN(rankedObjects); - } catch (ClassNotFoundException | NoSuchInstantiatorException | InvocationTargetException e) { - e.printStackTrace(); - } + tree.executeOperation(rankedObjects); Map<String, Integer> IDtoPosition = new HashMap<>(rankedObjects.getAnswerCount()); @@ -44,15 +40,11 @@ public class PerformanceMeasures { } // comparing done based on distances, counts how many of the same distances of KNNQueryOperation were presents in the answer of ApproxKNNQueryOperation - public static double measureRecall(ApproxKNNQueryOperation approxKNNQueryOperation, Tree tree) { + public static double measureRecall(ApproxKNNQueryOperation approxKNNQueryOperation, Algorithm tree) throws NoSuchMethodException, AlgorithmMethodException { if (approxKNNQueryOperation.getAnswerCount() == 0) return 0d; KNNQueryOperation knnQueryOperation = new KNNQueryOperation(approxKNNQueryOperation.getQueryObject(), approxKNNQueryOperation.getK()); - try { - tree.kNN(knnQueryOperation); - } catch (ClassNotFoundException | NoSuchInstantiatorException | InvocationTargetException e) { - e.printStackTrace(); - } + tree.executeOperation(knnQueryOperation); List<RankedAbstractObject> objects = new ArrayList<>(knnQueryOperation.getAnswerCount()); for (RankedAbstractObject object : knnQueryOperation)