@Override public boolean equalToReference(Record candidate) { for (int i = 0; i < this.keyFields.length; i++) { final Key<?> k = candidate.getField(this.keyFields[i], this.transientKeyHolders[i]); if (k == null) { throw new NullKeyFieldException(this.keyFields[i]); } else if (!k.equals(this.keyHolders[i])) { return false; } } return true; }
@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 jn2, Collector<Record> out) throws Exception { int p = jn2.getField(1, IntValue.class).getValue(); for (Record z : zs) { if (z.getField(0, StringValue.class).getValue().equals(jn2.getField(0, StringValue.class).getValue())) { if (p % z.getField(1, IntValue.class).getValue() != 0) { out.collect(jn2); } } } } }
@Override public void writeRecord(Record record) throws IOException { record.getField(0, TeraKey.class).copyToBuffer(this.buffer); record.getField(1, TeraValue.class).copyToBuffer(this.buffer); this.buffer[TeraKey.KEY_SIZE + TeraValue.VALUE_SIZE] = '\n'; this.stream.write(buffer, 0, buffer.length); }
@Override public void join(Record newVertexWithComponent, Record currentVertexWithComponent, Collector<Record> out){ long candidateComponentID = newVertexWithComponent.getField(1, LongValue.class).getValue(); long currentComponentID = currentVertexWithComponent.getField(1, LongValue.class).getValue(); if (candidateComponentID < currentComponentID) { out.collect(newVertexWithComponent); } } }
@Override public void map(Record record, Collector<Record> collector) { int currentSum = Integer.parseInt(record.getField(0, StringValue.class).getValue()); if(currentSum < 21) collector.collect(record); } }
@Override public void join(Record value1, Record value2, Collector<Record> out) throws Exception { Thread.sleep(WAIT_TIME_PER_RECORD); value1.setField(1, value2.getField(0, IntValue.class)); out.collect(value1); } }
@Override public void map(Record record, Collector<Record> collector) { int currentSum = Integer.parseInt(record.getField(0, StringValue.class).getValue()); if(currentSum < 22) collector.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 join(Record input1, Record input2, Collector<Record> out) { input1.setField(2, input2.getField(1, IntValue.class)); out.collect(input1); } }
@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 reduce(Iterator<Record> it, Collector<Record> out) { // Compute the sum int sum = 0; while (it.hasNext()) { sum += Integer.parseInt(it.next().getField(0, StringValue.class).getValue()) + 1; } out.collect(new Record(new StringValue(Integer.toString(sum)))); } }
@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); } } }
@Override public void map(Record record, Collector<Record> collector) { String line = record.getField(0, StringValue.class).getValue(); String [] element = line.split(" "); String word = element[0]; int count = Integer.parseInt(element[1]); if (stringList.contains(word)) { collector.collect(new Record(new StringValue(word), new IntValue(count))); } } }
@Test public void testSetNullInt() { try { Record record = this.generateFilledDenseRecord(58); record.setNull(42); assertTrue(record.getNumFields() == 58); assertTrue(record.getField(42, IntValue.class) == null); } catch (Throwable t) { Assert.fail("Test failed due to an exception: " + t.getMessage()); } }