/** * Creates a new record containing only a single field, which is the given value. * * @param value The value for the single field of the record. */ public Record(Value value) { setField(0, value); }
@Override public Record nextRecord(Record record) throws IOException{ record.setField(0, this.one); return record; } }
@Override public void reduce(Iterator<Record> records, Collector<Record> out) throws Exception { Record element = null; int sum = 0; while (records.hasNext()) { element = records.next(); int cnt = element.getField(1, IntValue.class).getValue(); sum += cnt; } element.setField(1, new IntValue(sum)); out.collect(element); }
/** * Output Schema: * 0: PARTIAL_COUNT=1 * 1: C_MKTSEGMENT */ @Override public void join(Record order, Record cust, Collector<Record> out) throws Exception { cust.setField(0, one); out.collect(cust); } }
@Override public Record readRecord(Record target, byte[] record, int offset, int numBytes) throws RuntimeException { if (numBytes != (TeraKey.KEY_SIZE + TeraValue.VALUE_SIZE)) { throw new RuntimeException("Malformatted input!"); } this.key.setValue(record, offset); this.value.setValue(record, offset + TeraKey.KEY_SIZE); target.setField(0, this.key); target.setField(1, this.value); return target; } }
@Override public void join(Record input1, Record input2, Collector<Record> out) { input1.setField(2, input2.getField(1, IntValue.class)); out.collect(input1); } }
@Override public void join(Record order, Record lineitem, Collector<Record> out) throws Exception { lineitem.setField(0, order.getField(1, IntValue.class)); out.collect(lineitem); } }
@Override public void join(Record colRecord, Record nation, Collector<Record> out) throws Exception { colRecord.setField(4, nation.getField(1, StringValue.class)); out.collect(colRecord); } }
@Override public void map(Record record, Collector<Record> out) throws Exception { record.setField(1, record.getField(0, LongValue.class)); out.collect(record); }
@Override public void join(Record value1, Record value2, Collector<Record> out) throws Exception { value1.setField(1, value2.getField(0, IntValue.class)); out.collect(value1); } }
@Override public void map(Record record, Collector<Record> out) throws Exception { keyString = record.getField(0, keyString); valueString = record.getField(1, valueString); if (Integer.parseInt(keyString.toString()) + Integer.parseInt(valueString.toString()) < 10) { record.setField(0, valueString); record.setField(1, new IntValue(Integer.parseInt(keyString.toString()) + 10)); out.collect(record); } } }
@Override public void reduce(Iterator<Record> records, Collector<Record> out) throws Exception { Record element = null; int sum = 0; while (records.hasNext()) { element = records.next(); int cnt = element.getField(1, IntValue.class).getValue(); sum += cnt; } element.setField(1, new IntValue(sum)); out.collect(element); }
@Override public void map(Record rec, Collector<Record> out) { CoordVector coord = rec.getField(1, CoordVector.class); double[] vector = coord.getCoordinates(); for (int i = 0; i < vector.length; i++) { vector[i]++; } rec.setField(1, coord); out.collect(rec); } }
@Override public void join(Record custRecord, Record olRecord, Collector<Record> out) throws Exception { final Tuple t = olRecord.getField(1, Tuple.class); final double extPrice = Double.parseDouble(t.getStringValueAt(0)); final double discount = Double.parseDouble(t.getStringValueAt(1)); this.d.setValue(extPrice * (1 - discount)); custRecord.setField(2, this.d); out.collect(custRecord); }
@Override public void map(Record record, Collector<Record> out) throws Exception { Tuple t = record.getField(1, this.tuple); if (t.getStringValueAt(8).equals("R")) { t.project(0x60); // l_extendedprice, l_discount record.setField(1, t); out.collect(record); } } }
/** * Compute the new position (coordinate vector) of a cluster center. */ @Override public void reduce(Iterator<Record> points, Collector<Record> out) { Record sum = sumPointsAndCount(points); sum.setField(1, sum.getField(1, Point.class).div(sum.getField(2, IntValue.class).getValue())); out.collect(sum); }
@Override public void map(Record record, Collector<Record> out) throws Exception { double x = record.getField(1, DoubleValue.class).getValue(); double y = record.getField(2, DoubleValue.class).getValue(); double z = record.getField(3, DoubleValue.class).getValue(); record.setField(1, new Point(x, y, z)); out.collect(record); } }