private static final double [][] RAW = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9} };
@Test
public void testUnitVectorizerMapper() throws Exception {
UnitVectorizerMapper mapper = new UnitVectorizerMapper();
Configuration conf = getConfiguration();
// set up the dummy writers
DummyRecordWriter<IntWritable, VectorWritable> writer = new
DummyRecordWriter<IntWritable, VectorWritable>();
Mapper<IntWritable, VectorWritable, IntWritable, VectorWritable>.Context
context = DummyRecordWriter.build(mapper, conf, writer);
// perform the mapping
for (int i = 0; i < RAW.length; i++) {
Vector vector = new RandomAccessSparseVector(RAW[i].length);
vector.assign(RAW[i]);
mapper.map(new IntWritable(i), new VectorWritable(vector), context);
}
// check the results
assertEquals("Number of map results", RAW.length, writer.getData().size());
for (int i = 0; i < RAW.length; i++) {