Path path = new Path(output, "clusters-0-final/part-r-00000");
FileSystem fs = FileSystem.get(path.toUri(), config);
SequenceFile.Reader reader = new SequenceFile.Reader(fs, path, config);
try {
Writable key = new Text();
ClusterWritable clusterWritable = new ClusterWritable();
assertTrue("more to come", reader.next(key, clusterWritable));
assertEquals("1st key", "C-0", key.toString());
List<Pair<Double,Double>> refCenters = Lists.newArrayList();
refCenters.add(new Pair<Double,Double>(1.5,1.5));
refCenters.add(new Pair<Double,Double>(4.333333333333334,4.333333333333334));
Pair<Double,Double> c = new Pair<Double,Double>(clusterWritable.getValue() .getCenter().get(0),
clusterWritable.getValue().getCenter().get(1));
assertTrue("center "+c+" not found", findAndRemove(c, refCenters, EPSILON));
assertTrue("more to come", reader.next(key, clusterWritable));
assertEquals("2nd key", "C-1", key.toString());
c = new Pair<Double,Double>(clusterWritable.getValue().getCenter().get(0),
clusterWritable.getValue().getCenter().get(1));
assertTrue("center "+c+" not found", findAndRemove(c, refCenters, EPSILON));
assertFalse("more to come", reader.next(key, clusterWritable));
} finally {
Closeables.close(reader, true);
}