de.lmu.ifi.dbs.elki.distance.distancefunction.external
Class DiskCacheBasedFloatDistanceFunction

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.distance.distancefunction.AbstractDBIDDistanceFunction<FloatDistance>
      extended by de.lmu.ifi.dbs.elki.distance.distancefunction.external.DiskCacheBasedFloatDistanceFunction
All Implemented Interfaces:
DBIDDistanceFunction<FloatDistance>, DistanceFunction<DBID,FloatDistance>, InspectionUtilFrequentlyScanned, Parameterizable

@Title(value="File based float distance for database objects.")
@Description(value="Loads float distance values from an external matrix.")
public class DiskCacheBasedFloatDistanceFunction
extends AbstractDBIDDistanceFunction<FloatDistance>

Provides a DistanceFunction that is based on float distances given by a distance matrix of an external file.


Nested Class Summary
static class DiskCacheBasedFloatDistanceFunction.Parameterizer
          Parameterization class.
 
Field Summary
private  OnDiskUpperTriangleMatrix cache
          The distance cache
static int FLOAT_CACHE_MAGIC
          Magic to identify double cache matrices
private static int FLOAT_SIZE
          Storage required for a float value.
static OptionID MATRIX_ID
          Parameter that specifies the name of the distance matrix file.
 
Constructor Summary
DiskCacheBasedFloatDistanceFunction(OnDiskUpperTriangleMatrix cache)
          Constructor.
 
Method Summary
 FloatDistance distance(DBID id1, DBID id2)
          Returns the distance between the two objects specified by their objects ids.
 boolean equals(Object obj)
           
 FloatDistance getDistanceFactory()
          Method to get the distance functions factory.
 
Methods inherited from class de.lmu.ifi.dbs.elki.distance.distancefunction.AbstractDBIDDistanceFunction
getInputTypeRestriction, instantiate, isMetric, isSymmetric
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MATRIX_ID

public static final OptionID MATRIX_ID
Parameter that specifies the name of the distance matrix file.

Key: -distance.matrix


FLOAT_CACHE_MAGIC

public static final int FLOAT_CACHE_MAGIC
Magic to identify double cache matrices

See Also:
Constant Field Values

FLOAT_SIZE

private static final int FLOAT_SIZE
Storage required for a float value.

See Also:
Constant Field Values

cache

private OnDiskUpperTriangleMatrix cache
The distance cache

Constructor Detail

DiskCacheBasedFloatDistanceFunction

public DiskCacheBasedFloatDistanceFunction(OnDiskUpperTriangleMatrix cache)
Constructor.

Parameters:
cache - Distance matrix
Method Detail

distance

public FloatDistance distance(DBID id1,
                              DBID id2)
Returns the distance between the two objects specified by their objects ids. If a cache is used, the distance value is looked up in the cache. If the distance does not yet exists in cache, it will be computed an put to cache. If no cache is used, the distance is computed.

Specified by:
distance in interface DBIDDistanceFunction<FloatDistance>
Specified by:
distance in class AbstractDBIDDistanceFunction<FloatDistance>
Parameters:
id1 - first object id
id2 - second object id
Returns:
the distance between the two objects specified by their objects ids

getDistanceFactory

public FloatDistance getDistanceFactory()
Description copied from interface: DistanceFunction
Method to get the distance functions factory.

Specified by:
getDistanceFactory in interface DistanceFunction<DBID,FloatDistance>
Specified by:
getDistanceFactory in class AbstractDBIDDistanceFunction<FloatDistance>
Returns:
Factory for distance objects

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

Release 0.4.0 (2011-09-20_1324)