RandomSeedGenerator { private RandomSeedGenerator() { } private  RandomSeedGenerator(); static Path buildRandom(Configuration conf,
                                 Path input,
                                 Path output,
                                 int k,
                                 DistanceMeasure measure); static final String K; }
@Test public void testRandomSeedGenerator() throws Exception { List<VectorWritable> points = getPoints(); Job job = new Job(); Configuration conf = job.getConfiguration(); job.setMapOutputValueClass(VectorWritable.class); Path input = getTestTempFilePath("random-input"); Path output = getTestTempDirPath("random-output"); ClusteringTestUtils.writePointsToFile(points, input, fs, conf); RandomSeedGenerator.buildRandom(conf, input, output, 4, new ManhattanDistanceMeasure()); int clusterCount = 0; Collection<Integer> set = new HashSet<Integer>(); for (AbstractCluster value : new SequenceFileValueIterable<AbstractCluster>(new Path(output, "part-randomSeed"), true, conf)) { clusterCount++; int id = value.getId(); assertTrue(set.add(id)); Vector v = value.getCenter(); assertVectorEquals(RAW[id], v); } assertEquals(4, clusterCount); }
@Test public void testRandomSeedGenerator() throws Exception { List<VectorWritable> points = getPoints(); Job job = new Job(); Configuration conf = job.getConfiguration(); job.setMapOutputValueClass(VectorWritable.class); Path input = getTestTempFilePath("random-input"); Path output = getTestTempDirPath("random-output"); ClusteringTestUtils.writePointsToFile(points, input, fs, conf); RandomSeedGenerator.buildRandom(conf, input, output, 4, new ManhattanDistanceMeasure()); int clusterCount = 0; Collection<Integer> set = new HashSet<Integer>(); for (Cluster value : new SequenceFileValueIterable<Cluster>(new Path(output, "part-randomSeed"), true, conf)) { clusterCount++; int id = value.getId(); assertTrue(set.add(id)); Vector v = value.getCenter(); assertVectorEquals(RAW[id], v); } assertEquals(4, clusterCount); }