@Alias(value="de.lmu.ifi.dbs.elki.distance.distancefunction.external.FileBasedFloatDistanceFunction") public class FileBasedSparseFloatDistanceFunction extends AbstractDBIDRangeDistanceFunction
Note: parsing an ASCII file is rather expensive.
See AsciiDistanceParser
for the default input format.
TODO: use a float[]
instead of the hash map?
Modifier and Type | Class and Description |
---|---|
static class |
FileBasedSparseFloatDistanceFunction.Parameterizer
Parameterization class.
|
AbstractDatabaseDistanceFunction.Instance<O>
Modifier and Type | Field and Description |
---|---|
private it.unimi.dsi.fastutil.longs.Long2FloatOpenHashMap |
cache
The distance cache
|
protected float |
defaultDistance
Distance to return when not defined otherwise.
|
private static Logging |
LOG
Class logger.
|
private java.io.File |
matrixfile
Input file of distance matrix
|
private int |
max
Minimum and maximum IDs seen.
|
private int |
min
Minimum and maximum IDs seen.
|
private DistanceParser |
parser
Distance parser
|
Constructor and Description |
---|
FileBasedSparseFloatDistanceFunction(DistanceParser parser,
java.io.File matrixfile,
float defaultDistance)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
checkRange(DBIDRange range)
Validate the range of DBIDs to use.
|
double |
distance(int i1,
int i2)
Compute the distance for two integer offsets.
|
boolean |
equals(java.lang.Object obj) |
<O extends DBID> |
instantiate(Relation<O> relation)
Instantiate with a database to get the actual distance query.
|
protected void |
loadCache(int size,
java.io.InputStream in)
Fill cache from an input stream.
|
protected static long |
makeKey(int i1,
int i2)
Combine two integer ids into a long value.
|
distance, getInputTypeRestriction
isMetric, isSymmetric
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isMetric, isSquared, isSymmetric
private static final Logging LOG
private it.unimi.dsi.fastutil.longs.Long2FloatOpenHashMap cache
private DistanceParser parser
private java.io.File matrixfile
private int min
private int max
protected float defaultDistance
public FileBasedSparseFloatDistanceFunction(DistanceParser parser, java.io.File matrixfile, float defaultDistance)
parser
- Parsermatrixfile
- input filedefaultDistance
- Default distance (when undefined)public <O extends DBID> DistanceQuery<O> instantiate(Relation<O> relation)
DistanceFunction
instantiate
in interface DistanceFunction<DBID>
instantiate
in class AbstractDBIDRangeDistanceFunction
relation
- The representation to usepublic double distance(int i1, int i2)
DBIDRangeDistanceFunction
i1
- First offseti2
- Second offsetprotected void loadCache(int size, java.io.InputStream in) throws java.io.IOException
size
- Expected sizein
- Input streamjava.io.IOException
protected static final long makeKey(int i1, int i2)
i1
- First idi2
- Second idpublic void checkRange(DBIDRange range)
DBIDRangeDistanceFunction
range
- DBID rangepublic boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
Copyright © 2019 ELKI Development Team. License information.