Class RdKNNTree<O extends NumberVector>

    • Constructor Detail

      • RdKNNTree

        public RdKNNTree​(Relation<O> relation,
                         PageFile<RdKNNNode> pagefile,
                         RdkNNSettings settings)
        Constructor.
        Parameters:
        relation - Relation to index
        pagefile - Data storage
        settings - Tree settings
    • Method Detail

      • preInsert

        protected void preInsert​(RdKNNEntry entry)
        Performs necessary operations before inserting the specified entry.
        Overrides:
        preInsert in class IndexTree<RdKNNNode,​RdKNNEntry>
        Parameters:
        entry - the entry to be inserted
      • postDelete

        protected void postDelete​(RdKNNEntry entry)
        Performs necessary operations after deleting the specified object.
        Overrides:
        postDelete in class IndexTree<RdKNNNode,​RdKNNEntry>
        Parameters:
        entry - the entry that was removed
      • bulkLoad

        protected void bulkLoad​(java.util.List<RdKNNEntry> entries)
        Performs a bulk load on this RTree with the specified data. Is called by the constructor and should be overwritten by subclasses if necessary.
        Overrides:
        bulkLoad in class NonFlatRStarTree<RdKNNNode,​RdKNNEntry,​RdkNNSettings>
        Parameters:
        entries - Entries to bulk load
      • getSortedEntries

        protected java.util.List<DoubleObjPair<RdKNNEntry>> getSortedEntries​(AbstractRStarTreeNode<?,​?> node,
                                                                             SpatialComparable q,
                                                                             SpatialPrimitiveDistance<?> distance)
        Sorts the entries of the specified node according to their minimum distance to the specified object.
        Parameters:
        node - the node
        q - the query object
        distance - the distance function for computing the distances
        Returns:
        a list of the sorted entries
      • preInsert

        private void preInsert​(RdKNNEntry q,
                               RdKNNEntry nodeEntry,
                               KNNHeap knns_q)
        Adapts the knn distances before insertion of entry q.
        Parameters:
        q - the entry to be inserted
        nodeEntry - the entry representing the root of the current subtree
        knns_q - the knns of q
      • doReverseKNN

        private void doReverseKNN​(RdKNNNode node,
                                  DBID oid,
                                  ModifiableDoubleDBIDList result)
        Performs a reverse knn query in the specified subtree.
        Parameters:
        node - the root node of the current subtree
        oid - the id of the object for which the rknn query is performed
        result - the list containing the query results
      • adjustKNNDistances

        private void adjustKNNDistances​(RdKNNEntry entry,
                                        ArrayDBIDs ids,
                                        double[] kdists)
        Adjusts the knn distance in the subtree of the specified root entry.
        Parameters:
        entry - the root entry of the current subtree
        ids - Sorted list of IDs
        kdists - knn distances
      • checkDistance

        private void checkDistance​(SpatialPrimitiveDistance<? super O> distance)
        Throws an IllegalArgumentException if the specified distance function is not an instance of the distance function used by this index.
        Parameters:
        distance - the distance function to be checked
        Throws:
        java.lang.IllegalArgumentException
      • insert

        public final void insert​(DBIDRef id)
        Inserts the specified real vector object into this index.
        Specified by:
        insert in interface DynamicIndex
        Parameters:
        id - the object id that was inserted
      • insertAll

        public final void insertAll​(DBIDs ids)
        Inserts the specified objects into this index. If a bulk load mode is implemented, the objects are inserted in one bulk.
        Specified by:
        insertAll in interface DynamicIndex
        Parameters:
        ids - the objects to be inserted
      • delete

        public final boolean delete​(DBIDRef id)
        Deletes the specified object from this index.
        Specified by:
        delete in interface DynamicIndex
        Parameters:
        id - Object to remove
        Returns:
        true if this index did contain the object with the specified id, false otherwise
      • deleteAll

        public void deleteAll​(DBIDs ids)
        Description copied from interface: DynamicIndex
        Deletes the specified objects from this index.
        Specified by:
        deleteAll in interface DynamicIndex
        Parameters:
        ids - Objects to remove
      • 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 DistancePriorityIndex<O extends NumberVector>
        Specified by:
        kNNByObject in interface KNNIndex<O 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<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 DistancePriorityIndex<O extends NumberVector>
        Specified by:
        rangeByObject in interface RangeIndex<O extends NumberVector>
        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 extends NumberVector>
        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 extends NumberVector>
        Parameters:
        distanceQuery - Distance query
        maxk - Maximum k for RkNN query
        flags - Hints for the optimizer
        Returns:
        RKNN Query object or null