public void reduce(Text key, Iterable<MyArrayWritable> value, Context context) throws IOException, InterruptedException { int[] maxminval = new int[2]; for (MyArrayWritable val : value) { maxminval[0] = val.getintarray()[0]; maxminval[1] = val.getintarray()[1]; } emitkey.set(key); emitvalue.set(maxminval[0] + " " + maxminval[1]); context.write(emitkey, emitvalue); }
public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException { String[] columns = new String[27]; String line = ""; int[] maxmin = new int[2]; int i = 0; int max = 0; int min = 9999; line = value.toString(); StringTokenizer strtoken = new StringTokenizer(line); System.out.println(line); if (strtoken.hasMoreTokens()) { System.out.println("has more elements"); } else { System.out.println("no elements"); } while (strtoken.hasMoreTokens()) { columns[i] = strtoken.nextElement().toString(); if (i > 27) { break; } System.out.println("i is " + i); if (i >= 3) { columns[i] = columns[i].replace("S", "").replace("C", "").replace("P", ""); System.out.println("inside i > 3"); max = Math.max(max, Integer.parseInt(columns[i])); min = Math.min(min, Integer.parseInt(columns[i])); } i++; } maxmin[0] = min; maxmin[1] = max; emitkey.set(columns[0].toString() + columns[1].toString() + columns[2].toString()); emitvalue.setintarray(maxmin); context.write(emitkey, emitvalue); i = 0; // System.out.println("arrat value" + emitvalue.getintarray()[0]); }