org.apache.mahout.utils.clustering
Class AbstractClusterWriter
java.lang.Object
org.apache.mahout.utils.clustering.AbstractClusterWriter
- All Implemented Interfaces:
- Closeable, ClusterWriter
- Direct Known Subclasses:
- ClusterDumperWriter, CSVClusterWriter, GraphMLClusterWriter, JsonClusterWriter
public abstract class AbstractClusterWriter
- extends Object
- implements ClusterWriter
Base class for implementing ClusterWriter
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
writer
protected final Writer writer
clusterIdToPoints
protected final Map<Integer,List<WeightedPropertyVectorWritable>> clusterIdToPoints
measure
protected final DistanceMeasure measure
AbstractClusterWriter
protected AbstractClusterWriter(Writer writer,
Map<Integer,List<WeightedPropertyVectorWritable>> clusterIdToPoints,
DistanceMeasure measure)
- Parameters:
writer
- The underlying Writer
to useclusterIdToPoints
- The map between cluster ids Cluster.getId()
and the
points in the clustermeasure
- The DistanceMeasure
used to calculate the distance.
Some writers may wish to use it for calculating weights for display. May be null.
getWriter
protected Writer getWriter()
getClusterIdToPoints
protected Map<Integer,List<WeightedPropertyVectorWritable>> getClusterIdToPoints()
getTopFeatures
public static String getTopFeatures(Vector vector,
String[] dictionary,
int numTerms)
getTopTerms
public static String getTopTerms(Vector vector,
String[] dictionary,
int numTerms)
write
public long write(Iterable<ClusterWritable> iterable)
throws IOException
- Description copied from interface:
ClusterWriter
- Write all values in the Iterable to the output
- Specified by:
write
in interface ClusterWriter
- Parameters:
iterable
- The Iterable
to loop over
- Returns:
- the number of docs written
- Throws:
IOException
- if there was a problem writing
close
public void close()
throws IOException
- Specified by:
close
in interface Closeable
- Throws:
IOException
write
public long write(Iterable<ClusterWritable> iterable,
long maxDocs)
throws IOException
- Description copied from interface:
ClusterWriter
- Write the first
maxDocs
to the output.
- Specified by:
write
in interface ClusterWriter
- Parameters:
iterable
- The Iterable
to loop overmaxDocs
- the maximum number of docs to write
- Returns:
- The number of docs written
- Throws:
IOException
- if there was a problem writing
Copyright © 2008–2014 The Apache Software Foundation. All rights reserved.