@Override public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException { String str = "1\t" + value.toString(); Kvector vector = Kvector.fromString(str); int code = -1, d = Integer.MAX_VALUE; for (Kvector e : m_kVectors) { int t = vector.distance(e); if (t < d) { d = t; code = e.code; } } context.write(new KcodeWritable(code), new Text(str)); }