Class ProjectedIndex<O,​I>

  • Type Parameters:
    O - Outer object type
    I - Inner object type
    All Implemented Interfaces:
    Index, KNNIndex<O>, RangeIndex<O>, RKNNIndex<O>
    Direct Known Subclasses:
    LatLngAsECEFIndex, LngLatAsECEFIndex

    public class ProjectedIndex<O,​I>
    extends java.lang.Object
    implements KNNIndex<O>, RKNNIndex<O>, RangeIndex<O>
    Index data in an arbitrary projection.

    Note: be careful when using this class, as it may/will yield incorrect distances, depending on your projection! It may be desirable to use a modified index that corrects for this error, or supports specific combinations only.

    See LatLngAsECEFIndex and LngLatAsECEFIndex for example indexes that support only a specific (good) combination.

    FIXME: add refinement to bulk queries!

    Since:
    0.6.0
    Author:
    Erich Schubert
    • Field Detail

      • LOG

        private static final Logging LOG
        Class logger
      • inner

        Index inner
        Inner index.
      • relation

        Relation<? extends O> relation
        The relation we predend to index.
      • view

        Relation<I> view
        The view that we really index.
      • norefine

        boolean norefine
        Refinement disable flag.
      • kmulti

        double kmulti
        Multiplier for k.
      • refinements

        final Counter refinements
        Count the number of distance refinements computed.
    • Constructor Detail

      • ProjectedIndex

        public ProjectedIndex​(Relation<? extends O> relation,
                              Projection<O,​I> proj,
                              Relation<I> view,
                              Index inner,
                              boolean norefine,
                              double kmulti)
        Constructor.
        Parameters:
        relation - Relation to index.
        proj - Projection to use.
        view - View to use.
        inner - Index to wrap.
        norefine - Refinement disable flag.
        kmulti - Multiplicator for k
    • Method Detail

      • countRefinement

        private void countRefinement()
        Count a single distance refinement.
      • initialize

        public void initialize()
        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
      • 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
      • kNNByObject

        public KNNSearcher<O> kNNByObject​(DistanceQuery<O> 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<O>
        Parameters:
        distanceQuery - Distance query
        maxk - Maximum value of k
        flags - Hints for the optimizer
        Returns:
        KNN Query object or null
      • kNNByDBID

        public KNNSearcher<DBIDRef> kNNByDBID​(DistanceQuery<O> 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:
        kNNByDBID in interface KNNIndex<O>
        Parameters:
        distanceQuery - Distance query
        maxk - Maximum value of k
        flags - Hints for the optimizer
        Returns:
        KNN Query object or null
      • rangeByObject

        public RangeSearcher<O> rangeByObject​(DistanceQuery<O> 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<O>
        Parameters:
        distanceQuery - Distance query
        maxradius - Maximum range
        flags - Hints for the optimizer
        Returns:
        KNN Query object or null
      • rangeByDBID

        public RangeSearcher<DBIDRef> rangeByDBID​(DistanceQuery<O> 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:
        rangeByDBID in interface RangeIndex<O>
        Parameters:
        distanceQuery - Distance query
        maxradius - Maximum range
        flags - Hints for the optimizer
        Returns:
        KNN Query object or null
      • rkNNByObject

        public RKNNSearcher<O> rkNNByObject​(DistanceQuery<O> distanceQuery,
                                            int maxk,
                                            int flags)
        Description copied from interface: RKNNIndex
        Get a RKNN query object for the given distance query and k.

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

        Specified by:
        rkNNByObject in interface RKNNIndex<O>
        Parameters:
        distanceQuery - Distance query
        maxk - Maximum k for RkNN query
        flags - Hints for the optimizer
        Returns:
        RKNN Query object or null
      • rkNNByDBID

        public RKNNSearcher<DBIDRef> rkNNByDBID​(DistanceQuery<O> distanceQuery,
                                                int maxk,
                                                int flags)
        Description copied from interface: RKNNIndex
        Get a RKNN query object for the given distance query and k.

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

        Specified by:
        rkNNByDBID in interface RKNNIndex<O>
        Parameters:
        distanceQuery - Distance query
        maxk - Maximum k for RkNN query
        flags - Hints for the optimizer
        Returns:
        RKNN Query object or null