Class PartialVAFile<V extends NumberVector>

  • Type Parameters:
    V - Vector type
    All Implemented Interfaces:
    Index, KNNIndex<V>, RangeIndex<V>

    @Reference(authors="Hans-Peter Kriegel, Peer Kr\u00f6ger, Matthias Schubert, Ziyue Zhu",
               title="Efficient Query Processing in Arbitrary Subspaces Using Vector Approximations",
               booktitle="Proc. 18th Int. Conf. on Scientific and Statistical Database Management (SSDBM 06)",
               url="https://doi.org/10.1109/SSDBM.2006.23",
               bibkey="DBLP:conf/ssdbm/KriegelKSZ06")
    public class PartialVAFile<V extends NumberVector>
    extends AbstractRefiningIndex<V>
    implements KNNIndex<V>, RangeIndex<V>
    PartialVAFile. In-memory only implementation.

    Reference:

    Hans-Peter Kriegel, Peer Kröger, Matthias Schubert, Ziyue Zhu
    Efficient Query Processing in Arbitrary Subspaces Using Vector Approximations
    Proc. 18th Int. Conf. on Scientific and Statistical Database Management (SSDBM 06)

    TODO: This needs to be optimized more low-level.

    Since:
    0.5.0
    Author:
    Thomas Bernecker, Erich Schubert
    • Field Detail

      • LOG

        private static final Logging LOG
        Class logger.
      • daFiles

        java.util.List<DAFile> daFiles
        Partial VA files.
      • partitions

        private final int partitions
        Number of partitions.
      • pageSize

        private final int pageSize
        Page size.
      • splitPartitions

        private double[][] splitPartitions
        Splitting grid.
      • vectorApprox

        private java.util.ArrayList<VectorApproximation> vectorApprox
        The (full - we are in-memory only right now) vector approximations.
    • Constructor Detail

      • PartialVAFile

        public PartialVAFile​(int pageSize,
                             Relation<V> relation,
                             int partitions)
        Constructor.
        Parameters:
        pageSize - Page size
        relation - Data relation
        partitions - Number of partitions
    • Method Detail

      • initialize

        public void initialize()
                        throws java.lang.IllegalStateException
        Description copied from interface: Index
        Initialize the index. For static indexes, this is the moment the index is bulk loaded.
        Specified by:
        initialize in interface Index
        Throws:
        java.lang.IllegalStateException
      • logStatistics

        public void logStatistics()
        Description copied from interface: Index
        Send statistics to the logger, if enabled.

        Note: you must have set the logging level appropriately before initializing the index! Otherwise, the index might not have collected the desired statistics.

        Specified by:
        logStatistics in interface Index
        Overrides:
        logStatistics in class AbstractRefiningIndex<V extends NumberVector>
      • calculateFullApproximation

        protected VectorApproximation calculateFullApproximation​(DBIDRef id,
                                                                 V dv)
        Calculate the VA file position given the existing borders.
        Parameters:
        id - Object ID
        dv - Data vector
        Returns:
        Vector approximation
      • kNNByObject

        public KNNSearcher<V> kNNByObject​(DistanceQuery<V> distanceQuery,
                                          int maxk,
                                          int flags)
        Description copied from interface: KNNIndex
        Get a KNN query object for the given distance query and k.

        This function MAY return null, when the given distance is not supported!

        Specified by:
        kNNByObject in interface KNNIndex<V extends NumberVector>
        Parameters:
        distanceQuery - Distance query
        maxk - Maximum value of k
        flags - Hints for the optimizer
        Returns:
        KNN Query object or null
      • rangeByObject

        public RangeSearcher<V> rangeByObject​(DistanceQuery<V> distanceQuery,
                                              double maxradius,
                                              int flags)
        Description copied from interface: RangeIndex
        Get a range query object for the given distance query and k.

        This function MAY return null, when the given distance is not supported!

        Specified by:
        rangeByObject in interface RangeIndex<V extends NumberVector>
        Parameters:
        distanceQuery - Distance query
        maxradius - Maximum range
        flags - Hints for the optimizer
        Returns:
        KNN Query object or null
      • calculateSelectivityCoeffs

        protected static void calculateSelectivityCoeffs​(java.util.List<DoubleObjPair<DAFile>> daFiles,
                                                         NumberVector query,
                                                         double epsilon)
        Calculate selectivity coefficients.
        Parameters:
        daFiles - List of files to use
        query - Query vector
        epsilon - Epsilon radius
      • calculatePartialApproximation

        protected static VectorApproximation calculatePartialApproximation​(NumberVector dv,
                                                                           java.util.List<DoubleObjPair<DAFile>> daFiles)
        Calculate partial vector approximation.
        Parameters:
        dv - Object vector
        daFiles - List of approximations to use
        Returns:
        Vector approximation
      • roundToPageSize

        protected long roundToPageSize​(long l)
        Round a value to the next page size.
        Parameters:
        l - value
        Returns:
        rounded value