@Override public void map(long recordNum, Record record, TaskContext context) throws IOException { key.set("user_id", record.getString(0)); key.set("brand_id", record.getString(1)); value.set("type", record.getString(2)); value.set("visit_datetime", record.getString(3)); context.write(key, value); // hashmap ? }
/** Writes all keys and values directly to output. */ @Override public void reduce(Record key, Iterator<Record> values, TaskContext context) throws IOException { result.set(0, key.get(0)); while (values.hasNext()) { Record val = values.next(); result.set(1, val.get(0)); context.write(result); } }
@Override public void setup(TaskContext context) throws IOException { result = context.createOutputRecord(); }
@Override public void map(long recordNum, Record record, TaskContext context) throws IOException { key.set(new Object[] {(Long) record.get(0)}); value.set(new Object[] {(Long) record.get(1)}); context.write(key, value); }
@Override public void setup(TaskContext context) throws IOException { key = context.createMapOutputKeyRecord(); value = context.createMapOutputValueRecord(); }