Class WrappedKNNDBIDByLookup<O>

  • Type Parameters:
    O - relation object type
    All Implemented Interfaces:
    KNNSearcher<DBIDRef>
    Direct Known Subclasses:
    WrappedKNNDBIDByLookup.Linear

    public class WrappedKNNDBIDByLookup<O>
    extends java.lang.Object
    implements KNNSearcher<DBIDRef>
    Find nearest neighbors by querying with the original object.
    Since:
    0.8.0
    Author:
    Erich Schubert
    • Field Detail

      • relation

        private Relation<? extends O> relation
        Data relation.
    • Constructor Detail

      • WrappedKNNDBIDByLookup

        private WrappedKNNDBIDByLookup​(Relation<? extends O> relation,
                                       KNNSearcher<O> inner)
        Constructor.
        Parameters:
        relation - data relation
        inner - inner kNN searcher
    • Method Detail

      • getKNN

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

        public static <O> KNNSearcher<DBIDRef> wrap​(Relation<? extends O> relation,
                                                    KNNSearcher<O> inner)
        Wrap a query, if not null.
        Type Parameters:
        O - inner data type
        Parameters:
        relation - Relation to get object from
        inner - inner query
        Returns:
        wrapped query, or null if inner was null