Commit 6c371de1 authored by xnovak8's avatar xnovak8
Browse files

* Sketch search alg. theoretically finished

 * DC refinement now uses 4 threads
parent 92fa854d
Loading
Loading
Loading
Loading
+6 −7
Original line number Diff line number Diff line
@@ -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;
@@ -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 ******************//

@@ -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;    
@@ -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];
    }
@@ -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()];
            
@@ -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);
    }

    /**
@@ -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);
    }
    
    /**
+1 −2
Original line number Diff line number Diff line
@@ -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)) {
+2 −1
Original line number Diff line number Diff line
@@ -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");
    }

    
+2 −0
Original line number Diff line number Diff line
@@ -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;
@@ -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);
    }
    
    /**
+4 −4
Original line number Diff line number Diff line
@@ -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;
            }
        }
@@ -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