Class CLARA.CachedDistanceQuery<V>

  • Type Parameters:
    V - Data type
    All Implemented Interfaces:
    DistanceQuery<V>
    Enclosing class:
    CLARA<V>

    protected static class CLARA.CachedDistanceQuery<V>
    extends java.lang.Object
    implements DistanceQuery<V>
    Cached distance query.
    Author:
    Erich Schubert
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) int bad
      Number of uncacheable queries
      (package private) it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap cache
      Cache
      (package private) DistanceQuery<V> inner
      Inner distance query
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Clear the distance cache.
      double distance​(DBIDRef id1, DBIDRef id2)
      Returns the distance between the two objects specified by their object ids.
      double distance​(DBIDRef id1, V o2)
      Returns the distance between the two objects specified by their object ids.
      double distance​(V o1, DBIDRef id2)
      Returns the distance between the two objects specified by their object ids.
      double distance​(V o1, V o2)
      Returns the distance between the two objects specified by their object ids.
      Distance<? super V> getDistance()
      Get the inner distance function.
      Relation<? extends V> getRelation()
      Access the underlying data query.
      boolean hasUncachedQueries()
      Check if any queries were uncached (not using DBIDs).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • cache

        it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap cache
        Cache
      • bad

        int bad
        Number of uncacheable queries
    • Constructor Detail

      • CachedDistanceQuery

        public CachedDistanceQuery​(DistanceQuery<V> inner,
                                   int size)
        Constructor.
        Parameters:
        inner - Inner query
        size - Initial size of map
    • Method Detail

      • hasUncachedQueries

        public boolean hasUncachedQueries()
        Check if any queries were uncached (not using DBIDs).
        Returns:
        True if uncached distances were used
      • clear

        public void clear()
        Clear the distance cache.
      • distance

        public double distance​(DBIDRef id1,
                               DBIDRef id2)
        Description copied from interface: DistanceQuery
        Returns the distance between the two objects specified by their object ids.
        Specified by:
        distance in interface DistanceQuery<V>
        Parameters:
        id1 - first object id
        id2 - second object id
        Returns:
        the distance between the two objects specified by their object ids
      • distance

        public double distance​(V o1,
                               DBIDRef id2)
        Description copied from interface: DistanceQuery
        Returns the distance between the two objects specified by their object ids.
        Specified by:
        distance in interface DistanceQuery<V>
        Parameters:
        o1 - first object
        id2 - second object id
        Returns:
        the distance between the two objects specified by their object ids
      • distance

        public double distance​(DBIDRef id1,
                               V o2)
        Description copied from interface: DistanceQuery
        Returns the distance between the two objects specified by their object ids.
        Specified by:
        distance in interface DistanceQuery<V>
        Parameters:
        id1 - first object id
        o2 - second object
        Returns:
        the distance between the two objects specified by their object ids
      • distance

        public double distance​(V o1,
                               V o2)
        Description copied from interface: DistanceQuery
        Returns the distance between the two objects specified by their object ids.
        Specified by:
        distance in interface DistanceQuery<V>
        Parameters:
        o1 - first object
        o2 - second object
        Returns:
        the distance between the two objects specified by their object ids