*
* @throws Exception
*/
@Test
public void testEigencutsAffinityCutsMapper() throws Exception {
EigencutsAffinityCutsMapper mapper = new EigencutsAffinityCutsMapper();
Configuration conf = new Configuration();
conf.setInt(EigencutsKeys.AFFINITY_DIMENSIONS, this.affinity.length);
// set up the writer
DummyRecordWriter<Text, VertexWritable> writer =
new DummyRecordWriter<Text, VertexWritable>();
Mapper<IntWritable, VectorWritable, Text, VertexWritable>.Context context =
DummyRecordWriter.build(mapper, conf, writer);
// perform the maps
for (int i = 0; i < this.affinity.length; i++) {
VectorWritable aff = new VectorWritable(new DenseVector(this.affinity[i]));
VectorWritable sens = new VectorWritable(new DenseVector(this.sensitivity[i]));
IntWritable key = new IntWritable(i);
mapper.map(key, aff, context);
mapper.map(key, sens, context);
}
// were the vertices constructed correctly? if so, then for two 4x4
// matrices, there should be 10 unique keys with 56 total entries
assertEquals("Number of keys", 10, writer.getKeys().size());