SequenceFile.Reader reader = new SequenceFile.Reader(fs, path, conf);
try {
Writable key = reader.getKeyClass().asSubclass(Writable.class).newInstance();
Writable value = reader.getValueClass().asSubclass(Writable.class).newInstance();
while (reader.next(key, value)) {
Cluster cluster = (Cluster) value;
String fmtStr = useJSON ? cluster.asJsonString() : cluster.asFormatString(dictionary);
if (subString > 0 && fmtStr.length() > subString) {
writer.write(':');
writer.write(fmtStr, 0, Math.min(subString, fmtStr.length()));
} else {
writer.write(fmtStr);
}
writer.write('\n');
if (dictionary != null) {
String topTerms = getTopFeatures(cluster.getCenter(), dictionary, numTopFeatures);
writer.write("\tTop Terms: ");
writer.write(topTerms);
writer.write('\n');
}
List<WeightedVectorWritable> points = clusterIdToPoints.get(cluster.getId());
if (points != null) {
writer.write("\tWeight: Point:\n\t");
for (Iterator<WeightedVectorWritable> iterator = points.iterator(); iterator.hasNext();) {
WeightedVectorWritable point = iterator.next();
writer.write(String.valueOf(point.getWeight()));