Class EmpiricalQueryOptimizer

  • All Implemented Interfaces:
    QueryOptimizer

    @Alias("auto")
    public class EmpiricalQueryOptimizer
    extends java.lang.Object
    implements QueryOptimizer
    Class to automatically add indexes to a database.
    Since:
    0.8.0
    Author:
    Erich Schubert
    • Field Detail

      • LOG

        private static final Logging LOG
        Class logger.
      • matrixIndex

        private final java.lang.reflect.Constructor<? extends Index> matrixIndex
        Distance matrix index class.
      • knnIndex

        private final java.lang.reflect.Constructor<? extends KNNIndex<?>> knnIndex
        kNN preprocessor class.
      • coverIndex

        private final java.lang.reflect.Constructor<? extends Index> coverIndex
        cover tree index class.
      • vpIndex

        private final java.lang.reflect.Constructor<? extends Index> vpIndex
        vp tree index class.
      • kdIndex

        private final java.lang.reflect.Constructor<? extends Index> kdIndex
        k-d-tree index class.
    • Constructor Detail

      • EmpiricalQueryOptimizer

        public EmpiricalQueryOptimizer()
        Constructor.
    • Method Detail

      • getDistanceQuery

        public <O> DistanceQuery<O> getDistanceQuery​(Relation<? extends O> relation,
                                                     Distance<? super O> distance,
                                                     int flags)
        Description copied from interface: QueryOptimizer
        Optimize a distance query for this relation.
        Specified by:
        getDistanceQuery in interface QueryOptimizer
        Type Parameters:
        O - Object type
        Parameters:
        relation - Data relation
        distance - Distance function
        flags - Optimizer flags
        Returns:
        optimized query, if possible
      • kNNByObject

        public <O> KNNSearcher<O> kNNByObject​(Relation<? extends O> relation,
                                              DistanceQuery<O> distanceQuery,
                                              int maxk,
                                              int flags)
        Description copied from interface: QueryOptimizer
        Optimize a kNN query for this relation.
        Specified by:
        kNNByObject in interface QueryOptimizer
        Type Parameters:
        O - Object type
        Parameters:
        relation - Data relation
        distanceQuery - distance query
        maxk - Maximum k
        flags - Optimizer flags
        Returns:
        optimized query, if possible
      • kNNByDBID

        public <O> KNNSearcher<DBIDRef> kNNByDBID​(Relation<? extends O> relation,
                                                  DistanceQuery<O> distanceQuery,
                                                  int maxk,
                                                  int flags)
        Description copied from interface: QueryOptimizer
        Optimize a kNN query for this relation.
        Specified by:
        kNNByDBID in interface QueryOptimizer
        Type Parameters:
        O - Object type
        Parameters:
        relation - Data relation
        distanceQuery - distance query
        maxk - Maximum k
        flags - Optimizer flags
        Returns:
        optimized query, if possible
      • rangeByObject

        public <O> RangeSearcher<O> rangeByObject​(Relation<? extends O> relation,
                                                  DistanceQuery<O> distanceQuery,
                                                  double maxrange,
                                                  int flags)
        Description copied from interface: QueryOptimizer
        Optimize a range query for this relation.
        Specified by:
        rangeByObject in interface QueryOptimizer
        Type Parameters:
        O - Object type
        Parameters:
        relation - Data relation
        distanceQuery - distance query
        maxrange - Maximum range
        flags - Optimizer flags
        Returns:
        optimized query, if possible
      • rangeByDBID

        public <O> RangeSearcher<DBIDRef> rangeByDBID​(Relation<? extends O> relation,
                                                      DistanceQuery<O> distanceQuery,
                                                      double maxrange,
                                                      int flags)
        Description copied from interface: QueryOptimizer
        Optimize a range query for this relation.
        Specified by:
        rangeByDBID in interface QueryOptimizer
        Type Parameters:
        O - Object type
        Parameters:
        relation - Data relation
        distanceQuery - distance query
        maxrange - Maximum range
        flags - Optimizer flags
        Returns:
        optimized query, if possible
      • priorityByObject

        public <O> PrioritySearcher<O> priorityByObject​(Relation<? extends O> relation,
                                                        DistanceQuery<O> distanceQuery,
                                                        double maxrange,
                                                        int flags)
        Description copied from interface: QueryOptimizer
        Optimize a distance priority search for this relation.
        Specified by:
        priorityByObject in interface QueryOptimizer
        Type Parameters:
        O - Object type
        Parameters:
        relation - Data relation
        distanceQuery - distance query
        maxrange - Maximum range
        flags - Optimizer flags
        Returns:
        optimized query, if possible
      • priorityByDBID

        public <O> PrioritySearcher<DBIDRef> priorityByDBID​(Relation<? extends O> relation,
                                                            DistanceQuery<O> distanceQuery,
                                                            double maxrange,
                                                            int flags)
        Description copied from interface: QueryOptimizer
        Optimize a distance priority search for this relation.
        Specified by:
        priorityByDBID in interface QueryOptimizer
        Type Parameters:
        O - Object type
        Parameters:
        relation - Data relation
        distanceQuery - distance query
        maxrange - Maximum range
        flags - Optimizer flags
        Returns:
        optimized query, if possible
      • makeKnnPreprocessor

        private <O> KNNIndex<O> makeKnnPreprocessor​(Relation<? extends O> relation,
                                                    DistanceQuery<O> distanceQuery,
                                                    int maxk,
                                                    int flags)
        Make a knn preprocessor.
        Type Parameters:
        O - Object type
        Parameters:
        relation - Data relation
        distanceQuery - distance query
        maxk - Maximum k
        flags - Optimizer flags
        Returns:
        knn preprocessor
      • getFreeMemory

        private static long getFreeMemory()
        Get the currently free amount of memory.
        Returns:
        Free memory
      • formatMemory

        private static java.lang.String formatMemory​(long mem)
        Format a memory amount.
        Parameters:
        mem - Memory
        Returns:
        Memory amount