de.lmu.ifi.dbs.elki.datasource.parser
Class NumberDistanceParser<D extends NumberDistance<D,N>,N extends Number>

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.datasource.parser.AbstractParser
      extended by de.lmu.ifi.dbs.elki.datasource.parser.NumberDistanceParser<D,N>
Type Parameters:
D - distance type
N - number type
All Implemented Interfaces:
DistanceParser<D>

@Title(value="Number Distance Parser")
@Description(value="Parser for the following line format:\nid1 id2 distanceValue, where id1 and is2 are integers representing the two ids belonging to the distance value.\n The ids and the distance value are separated by whitespace. Empty lines and lines beginning with \"#\" will be ignored.")
public class NumberDistanceParser<D extends NumberDistance<D,N>,N extends Number>
extends AbstractParser
implements DistanceParser<D>

Provides a parser for parsing one distance value per line.

A line must have the following format: id1 id2 distanceValue, where id1 and id2 are integers representing the two ids belonging to the distance value. Lines starting with "#" will be ignored.


Nested Class Summary
static class NumberDistanceParser.Parameterizer<D extends NumberDistance<D,N>,N extends Number>
          Parameterization class.
 
Field Summary
static OptionID DISTANCE_FUNCTION_ID
          Parameter for distance function.
private  DistanceFunction<?,D> distanceFunction
          The distance function.
private static Logging logger
          The logger for this class.
 
Fields inherited from class de.lmu.ifi.dbs.elki.datasource.parser.AbstractParser
ATTRIBUTE_CONCATENATION, COLUMN_SEPARATOR_ID, COMMENT, NUMBER_PATTERN, QUOTE_CHAR, QUOTE_ID, quoteChar, WHITESPACE_PATTERN
 
Constructor Summary
NumberDistanceParser(Pattern colSep, char quoteChar, DistanceFunction<?,D> distanceFunction)
          Constructor.
 
Method Summary
 boolean containsKey(DBID id1, DBID id2, Map<DBIDPair,D> cache)
          Returns true if the specified distance cache contains a distance value for the specified ids.
protected  Logging getLogger()
          Get the logger for this class.
 DistanceParsingResult<D> parse(InputStream in)
          Returns a list of the objects parsed from the specified input stream and a list of the labels associated with the objects.
private  void put(DBID id1, DBID id2, D distance, Map<DBIDPair,D> cache)
          Puts the specified distance value for the given ids to the distance cache.
 
Methods inherited from class de.lmu.ifi.dbs.elki.datasource.parser.AbstractParser
tokenize, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

private static final Logging logger
The logger for this class.


DISTANCE_FUNCTION_ID

public static final OptionID DISTANCE_FUNCTION_ID
Parameter for distance function.


distanceFunction

private DistanceFunction<?,D extends NumberDistance<D,N>> distanceFunction
The distance function.

Constructor Detail

NumberDistanceParser

public NumberDistanceParser(Pattern colSep,
                            char quoteChar,
                            DistanceFunction<?,D> distanceFunction)
Constructor.

Parameters:
colSep -
quoteChar -
distanceFunction -
Method Detail

parse

public DistanceParsingResult<D> parse(InputStream in)
Description copied from interface: DistanceParser
Returns a list of the objects parsed from the specified input stream and a list of the labels associated with the objects.

Specified by:
parse in interface DistanceParser<D extends NumberDistance<D,N>>
Parameters:
in - the stream to parse objects from
Returns:
a list containing those objects parsed from the input stream and their associated labels.

put

private void put(DBID id1,
                 DBID id2,
                 D distance,
                 Map<DBIDPair,D> cache)
Puts the specified distance value for the given ids to the distance cache.

Parameters:
id1 - the first id
id2 - the second id
distance - the distance value
cache - the distance cache

containsKey

public boolean containsKey(DBID id1,
                           DBID id2,
                           Map<DBIDPair,D> cache)
Returns true if the specified distance cache contains a distance value for the specified ids.

Parameters:
id1 - the first id
id2 - the second id
cache - the distance cache
Returns:
true if this cache contains a distance value for the specified ids, false otherwise

getLogger

protected Logging getLogger()
Description copied from class: AbstractParser
Get the logger for this class.

Specified by:
getLogger in class AbstractParser
Returns:
Logger.

Release 0.4.0 (2011-09-20_1324)