org.apache.mahout.utils.clustering
Class AbstractClusterWriter

java.lang.Object
  extended by 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


Field Summary
protected  Map<Integer,List<WeightedPropertyVectorWritable>> clusterIdToPoints
           
protected  DistanceMeasure measure
           
protected  Writer writer
           
 
Constructor Summary
protected AbstractClusterWriter(Writer writer, Map<Integer,List<WeightedPropertyVectorWritable>> clusterIdToPoints, DistanceMeasure measure)
           
 
Method Summary
 void close()
           
protected  Map<Integer,List<WeightedPropertyVectorWritable>> getClusterIdToPoints()
           
static String getTopFeatures(Vector vector, String[] dictionary, int numTerms)
           
static String getTopTerms(Vector vector, String[] dictionary, int numTerms)
           
protected  Writer getWriter()
           
 long write(Iterable<ClusterWritable> iterable)
          Write all values in the Iterable to the output
 long write(Iterable<ClusterWritable> iterable, long maxDocs)
          Write the first maxDocs to the output.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.mahout.utils.clustering.ClusterWriter
write
 

Field Detail

writer

protected final Writer writer

clusterIdToPoints

protected final Map<Integer,List<WeightedPropertyVectorWritable>> clusterIdToPoints

measure

protected final DistanceMeasure measure
Constructor Detail

AbstractClusterWriter

protected AbstractClusterWriter(Writer writer,
                                Map<Integer,List<WeightedPropertyVectorWritable>> clusterIdToPoints,
                                DistanceMeasure measure)
Parameters:
writer - The underlying Writer to use
clusterIdToPoints - The map between cluster ids Cluster.getId() and the points in the cluster
measure - The DistanceMeasure used to calculate the distance. Some writers may wish to use it for calculating weights for display. May be null.
Method Detail

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 over
maxDocs - 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.