Loading src/main/java/messif/buckets/index/impl/DiskStorageMemoryIntIndex.java +6 −7 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; Loading @@ -46,7 +45,7 @@ public class DiskStorageMemoryIntIndex implements Serializable { private static final long serialVersionUID = 1021301L; /** Maximal length of the dynamic index; if exceeded, then the indexes are moved to static arrays */ private static final int MAX_DYNAMIC_LENGTH = 1024 * 1024; private static final int MAX_DYNAMIC_LENGTH = 1024 * 64; //****************** Attributes ******************// Loading @@ -57,7 +56,7 @@ public class DiskStorageMemoryIntIndex implements Serializable { private transient List<DiskStorage<LocalAbstractObject>> storageCopies = null; /** Ordered linked index of addresses into the storage */ private transient LinkedList<IntKeyAddressPair> dynamicIndex; private transient List<IntKeyAddressPair> dynamicIndex; /** Fixed static ordered arrays of keys and corresponding object positions in the storage. */ private int [] staticIndex; Loading @@ -72,7 +71,7 @@ public class DiskStorageMemoryIntIndex implements Serializable { */ public DiskStorageMemoryIntIndex(DiskStorage<LocalAbstractObject> storage) { this.storage = storage; this.dynamicIndex = new LinkedList<>(); this.dynamicIndex = new ArrayList<>(MAX_DYNAMIC_LENGTH); this.staticIndex = new int [0]; this.staticPositions = new long [0]; } Loading @@ -88,7 +87,7 @@ public class DiskStorageMemoryIntIndex implements Serializable { storageField.setAccessible(true); this.storage = (DiskStorage<LocalAbstractObject>) storageField.get(oldIndex); this.dynamicIndex = new LinkedList<>(); this.dynamicIndex = new ArrayList<>(MAX_DYNAMIC_LENGTH); this.staticIndex = new int [oldIndex.size()]; this.staticPositions = new long [oldIndex.size()]; Loading Loading @@ -134,7 +133,7 @@ public class DiskStorageMemoryIntIndex implements Serializable { private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); this.dynamicIndex = new LinkedList<>(); this.dynamicIndex = new ArrayList<>(MAX_DYNAMIC_LENGTH); } /** Loading Loading @@ -300,7 +299,7 @@ public class DiskStorageMemoryIntIndex implements Serializable { */ public int getMaxKey() { return Math.max(staticIndex.length > 0 ? staticIndex[staticIndex.length - 1] : -1, dynamicIndex.isEmpty() ? -1 : dynamicIndex.getLast().key); dynamicIndex.isEmpty() ? -1 : dynamicIndex.get(dynamicIndex.size() - 1).key); } /** Loading src/main/java/pppcodes/algorithms/PPPCodeAlgorithm.java +1 −2 Original line number Diff line number Diff line Loading @@ -196,7 +196,6 @@ public class PPPCodeAlgorithm extends MultipleOverlaysAlgorithm { List<PPPCodeSingleAlgorithm> indexesToRunOn = new ArrayList<>(Arrays.asList(Arrays.copyOf(algorithms, operation.getParameter("MAX_LAMBDA", Integer.class, algorithms.length)))); if (idObjectStorage == null || operation.getParameter("NOREFINE", Boolean.class, false)) { ((RankingQueryOperation) operation).setAnswerThresholdComputation(false, true, 0); return new ApproxNavProcessor((ApproxKNNQueryOperation) operation, indexesToRunOn, intLocatorTranslator); } else { if (0 < operation.getParameter(ApproxNavProcessorRefinement.PARAM_NR_OF_ACCESSED, Integer.class, 1)) { Loading src/main/java/pppcodes/index/PPPCodeLeafCell.java +2 −1 Original line number Diff line number Diff line Loading @@ -409,7 +409,8 @@ public class PPPCodeLeafCell extends VoronoiLeafCell<PPPCodeObject> implements M * @throws AlgorithmMethodException */ @Override public void deleteObject(PPPCodeObject object) throws AlgorithmMethodException { public void deleteObject(PPPCodeObject object, int deleteLimit, boolean checkLocator) throws AlgorithmMethodException { throw new AlgorithmMethodException("delete on PPP-Code algorithm is not implemented yet"); } Loading src/main/java/pppcodes/processors/ApproxNavProcessor.java +2 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ import messif.algorithms.AsynchronousNavigationProcessor; import messif.algorithms.NavigationProcessors; import messif.objects.LocalAbstractObject; import messif.objects.NoDataObject; import messif.operations.RankingQueryOperation; import messif.operations.RankingSingleQueryOperation; import messif.operations.query.ApproxKNNQueryOperation; import messif.statistics.OperationStatistics; Loading Loading @@ -96,6 +97,7 @@ public class ApproxNavProcessor implements AsynchronousNavigationProcessor<Ranki */ public ApproxNavProcessor(ApproxKNNQueryOperation operation, List<PPPCodeSingleAlgorithm> indexes, ReversibleLocatorIntTranslator locTranslator) { this(operation, indexes, locTranslator, new ArrayDeque<Integer>((int) (operation.getK() * 1.2f))); ((RankingQueryOperation) operation).setAnswerThresholdComputation(false, true, 0); } /** Loading src/main/java/pppcodes/processors/ApproxNavProcessorAdaptiveRefinement.java +4 −4 Original line number Diff line number Diff line Loading @@ -66,15 +66,15 @@ public class ApproxNavProcessorAdaptiveRefinement extends ApproxNavProcessorRefi @Override protected boolean continuteDCRefinement() { if (candSizeProcessed >= MAX_NR_OF_STEPS * checkStep) { if (candSizeProcessed.get() >= MAX_NR_OF_STEPS * checkStep) { return false; } if (candSizeProcessed >= MIN_NR_OF_STEPS * checkStep && candSizeProcessed - lastCheckPoint >= checkStep) { if (candSizeProcessed.get() >= MIN_NR_OF_STEPS * checkStep && candSizeProcessed.get() - lastCheckPoint >= checkStep) { float currentRadius = getOperation().getAnswerThreshold(); try { return (lastQueryRadius == LocalAbstractObject.MAX_DISTANCE || currentRadius < lastQueryRadius); } finally { lastCheckPoint = candSizeProcessed; lastCheckPoint = candSizeProcessed.get(); lastQueryRadius = currentRadius; } } Loading @@ -82,7 +82,7 @@ public class ApproxNavProcessorAdaptiveRefinement extends ApproxNavProcessorRefi } @Override protected boolean continuteObjectResolvement() { protected boolean continuteObjectResolving() { if (refinementToEnd.get() <= 0 && refinementToStart.get() <= 0 ) { currentlyReadObjects.clear(); currentlyReadObjects.add(Collections.singletonList((LocalAbstractObject) null).iterator()); Loading Loading
src/main/java/messif/buckets/index/impl/DiskStorageMemoryIntIndex.java +6 −7 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; Loading @@ -46,7 +45,7 @@ public class DiskStorageMemoryIntIndex implements Serializable { private static final long serialVersionUID = 1021301L; /** Maximal length of the dynamic index; if exceeded, then the indexes are moved to static arrays */ private static final int MAX_DYNAMIC_LENGTH = 1024 * 1024; private static final int MAX_DYNAMIC_LENGTH = 1024 * 64; //****************** Attributes ******************// Loading @@ -57,7 +56,7 @@ public class DiskStorageMemoryIntIndex implements Serializable { private transient List<DiskStorage<LocalAbstractObject>> storageCopies = null; /** Ordered linked index of addresses into the storage */ private transient LinkedList<IntKeyAddressPair> dynamicIndex; private transient List<IntKeyAddressPair> dynamicIndex; /** Fixed static ordered arrays of keys and corresponding object positions in the storage. */ private int [] staticIndex; Loading @@ -72,7 +71,7 @@ public class DiskStorageMemoryIntIndex implements Serializable { */ public DiskStorageMemoryIntIndex(DiskStorage<LocalAbstractObject> storage) { this.storage = storage; this.dynamicIndex = new LinkedList<>(); this.dynamicIndex = new ArrayList<>(MAX_DYNAMIC_LENGTH); this.staticIndex = new int [0]; this.staticPositions = new long [0]; } Loading @@ -88,7 +87,7 @@ public class DiskStorageMemoryIntIndex implements Serializable { storageField.setAccessible(true); this.storage = (DiskStorage<LocalAbstractObject>) storageField.get(oldIndex); this.dynamicIndex = new LinkedList<>(); this.dynamicIndex = new ArrayList<>(MAX_DYNAMIC_LENGTH); this.staticIndex = new int [oldIndex.size()]; this.staticPositions = new long [oldIndex.size()]; Loading Loading @@ -134,7 +133,7 @@ public class DiskStorageMemoryIntIndex implements Serializable { private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); this.dynamicIndex = new LinkedList<>(); this.dynamicIndex = new ArrayList<>(MAX_DYNAMIC_LENGTH); } /** Loading Loading @@ -300,7 +299,7 @@ public class DiskStorageMemoryIntIndex implements Serializable { */ public int getMaxKey() { return Math.max(staticIndex.length > 0 ? staticIndex[staticIndex.length - 1] : -1, dynamicIndex.isEmpty() ? -1 : dynamicIndex.getLast().key); dynamicIndex.isEmpty() ? -1 : dynamicIndex.get(dynamicIndex.size() - 1).key); } /** Loading
src/main/java/pppcodes/algorithms/PPPCodeAlgorithm.java +1 −2 Original line number Diff line number Diff line Loading @@ -196,7 +196,6 @@ public class PPPCodeAlgorithm extends MultipleOverlaysAlgorithm { List<PPPCodeSingleAlgorithm> indexesToRunOn = new ArrayList<>(Arrays.asList(Arrays.copyOf(algorithms, operation.getParameter("MAX_LAMBDA", Integer.class, algorithms.length)))); if (idObjectStorage == null || operation.getParameter("NOREFINE", Boolean.class, false)) { ((RankingQueryOperation) operation).setAnswerThresholdComputation(false, true, 0); return new ApproxNavProcessor((ApproxKNNQueryOperation) operation, indexesToRunOn, intLocatorTranslator); } else { if (0 < operation.getParameter(ApproxNavProcessorRefinement.PARAM_NR_OF_ACCESSED, Integer.class, 1)) { Loading
src/main/java/pppcodes/index/PPPCodeLeafCell.java +2 −1 Original line number Diff line number Diff line Loading @@ -409,7 +409,8 @@ public class PPPCodeLeafCell extends VoronoiLeafCell<PPPCodeObject> implements M * @throws AlgorithmMethodException */ @Override public void deleteObject(PPPCodeObject object) throws AlgorithmMethodException { public void deleteObject(PPPCodeObject object, int deleteLimit, boolean checkLocator) throws AlgorithmMethodException { throw new AlgorithmMethodException("delete on PPP-Code algorithm is not implemented yet"); } Loading
src/main/java/pppcodes/processors/ApproxNavProcessor.java +2 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ import messif.algorithms.AsynchronousNavigationProcessor; import messif.algorithms.NavigationProcessors; import messif.objects.LocalAbstractObject; import messif.objects.NoDataObject; import messif.operations.RankingQueryOperation; import messif.operations.RankingSingleQueryOperation; import messif.operations.query.ApproxKNNQueryOperation; import messif.statistics.OperationStatistics; Loading Loading @@ -96,6 +97,7 @@ public class ApproxNavProcessor implements AsynchronousNavigationProcessor<Ranki */ public ApproxNavProcessor(ApproxKNNQueryOperation operation, List<PPPCodeSingleAlgorithm> indexes, ReversibleLocatorIntTranslator locTranslator) { this(operation, indexes, locTranslator, new ArrayDeque<Integer>((int) (operation.getK() * 1.2f))); ((RankingQueryOperation) operation).setAnswerThresholdComputation(false, true, 0); } /** Loading
src/main/java/pppcodes/processors/ApproxNavProcessorAdaptiveRefinement.java +4 −4 Original line number Diff line number Diff line Loading @@ -66,15 +66,15 @@ public class ApproxNavProcessorAdaptiveRefinement extends ApproxNavProcessorRefi @Override protected boolean continuteDCRefinement() { if (candSizeProcessed >= MAX_NR_OF_STEPS * checkStep) { if (candSizeProcessed.get() >= MAX_NR_OF_STEPS * checkStep) { return false; } if (candSizeProcessed >= MIN_NR_OF_STEPS * checkStep && candSizeProcessed - lastCheckPoint >= checkStep) { if (candSizeProcessed.get() >= MIN_NR_OF_STEPS * checkStep && candSizeProcessed.get() - lastCheckPoint >= checkStep) { float currentRadius = getOperation().getAnswerThreshold(); try { return (lastQueryRadius == LocalAbstractObject.MAX_DISTANCE || currentRadius < lastQueryRadius); } finally { lastCheckPoint = candSizeProcessed; lastCheckPoint = candSizeProcessed.get(); lastQueryRadius = currentRadius; } } Loading @@ -82,7 +82,7 @@ public class ApproxNavProcessorAdaptiveRefinement extends ApproxNavProcessorRefi } @Override protected boolean continuteObjectResolvement() { protected boolean continuteObjectResolving() { if (refinementToEnd.get() <= 0 && refinementToStart.get() <= 0 ) { currentlyReadObjects.clear(); currentlyReadObjects.add(Collections.singletonList((LocalAbstractObject) null).iterator()); Loading