Class LinearScanPrimitiveKNNByObject<O>

  • Type Parameters:
    O - relation object type
    All Implemented Interfaces:
    KNNSearcher<O>, LinearScanQuery
    Direct Known Subclasses:
    LinearScanEuclideanKNNByObject

    public class LinearScanPrimitiveKNNByObject<O>
    extends java.lang.Object
    implements KNNSearcher<O>, LinearScanQuery
    Instance of this query for a particular database.

    This is a subtle optimization: for primitive queries, it is clearly faster to retrieve the query object from the relation only once!

    Since:
    0.4.0
    Author:
    Erich Schubert
    • Field Detail

      • relation

        protected Relation<? extends O> relation
        Relation to query.
    • Constructor Detail

      • LinearScanPrimitiveKNNByObject

        public LinearScanPrimitiveKNNByObject​(PrimitiveDistanceQuery<O> distanceQuery)
        Constructor.
        Parameters:
        distanceQuery - Distance function to use
    • Method Detail

      • getKNN

        public KNNList getKNN​(O obj,
                              int k)
        Description copied from interface: KNNSearcher
        Get the k nearest neighbors for a particular object.
        Specified by:
        getKNN in interface KNNSearcher<O>
        Parameters:
        obj - query object
        k - Number of neighbors requested
        Returns:
        neighbors