@Override protected void reduce( BytesWritable key, Iterable<NullWritable> values, Context context ) throws IOException, InterruptedException { context.write(key, NullWritable.get()); } }
/** * Merges the IP addresses of same Status. */ @Override protected void reduce(Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException { Set<String> addressSet = new HashSet<>(); for (Text val : values) { addressSet.add(val.toString()); } context.write(key, new Text(String.join(" ", addressSet))); } }
@Override public void doReduce(SelfDefineSortableKey key, Iterable<Text> values, Context context) throws IOException, InterruptedException { // for hll, each key only has one output, no need to do local combine; // for normal col, values are empty text context.write(key, values.iterator().next()); }
@Override protected void reduce(Text word, Iterable<IntWritable> counts, Context context) throws IOException, InterruptedException { int sum = 0; for (IntWritable count : counts) { sum += count.get(); } context.write(word, new IntWritable(sum)); } }
@Override protected void reduce(Text token, Iterable<IntWritable> docids, Context context) throws IOException, InterruptedException { List<Integer> hitlist = new ArrayList<>(); for (IntWritable docid : docids) { hitlist.add(docid.get()); } context.write(token, new AvroValue<>(hitlist)); } }
@Override protected void reduce(AvroKey<TextStats> key, Iterable<NullWritable> ignore, Context context) throws IOException, InterruptedException { context.write(key, NullWritable.get()); } }
@Override protected void reduce(Text key, Iterable<IntWritable> counts, Context context) throws IOException, InterruptedException { int sum = 0; for (IntWritable count : counts) { sum += count.get(); } context.write(new AvroKey<>(key.toString()), new AvroValue<>(sum)); } }
/** {@inheritDoc} */ @Override protected void reduce(Text key, Iterable<IntWritable> values, Context ctx) throws IOException, InterruptedException { int lineCnt = 0; for (IntWritable value : values) { lineCnt += value.get(); X.println("___ rdcr: " + value.get()); } sum.set(lineCnt); ctx.write(key, sum); X.println("___ RDCR SUM: " + lineCnt); totalLineCnt.addAndGet(lineCnt); } }
@Override protected void doReduce(IntWritable key, Iterable<Text> values, Context context) throws IOException, InterruptedException { for (Text text : values) { String value = text.toString(); String[] splited = StringUtil.split(value, "="); if (splited != null && splited.length == 2) { logger.info("Dictionary for col {}, save at {}", splited[0], splited[1]); context.write(new Text(splited[0]), new Text(splited[1])); } } } }
@Override protected void reduce(LongWritable key, Iterable<DoubleWritable> values, Context context) throws IOException, InterruptedException { double totalRate = 0; int activeMappers = 0; for (DoubleWritable value : values) { totalRate += value.get(); activeMappers++; } context.write(key, new Text(String.format("%f\t%d", totalRate, activeMappers))); } }
public void reduce(Text key, Iterable<IntWritable> values, Context context ) throws IOException, InterruptedException { int sum = 0; for (IntWritable val : values) { sum += val.get(); } result.set(sum); context.write(key, result); } }
@Override public void doReduce(RowKeyWritable row, Iterable<KeyValue> kvs, Context context) throws java.io.IOException, InterruptedException { for (KeyValue kv : kvs) { immutableBytesWritable.set(kv.getKey()); context.write(immutableBytesWritable, kv); } } }
/** {@inheritDoc} */ @Override public void reduce(Text key, Iterable<IntWritable> values, Context ctx) throws IOException, InterruptedException { assert wasConfigured : "Reducer should be configured"; assert wasSetUp : "Reducer should be set up"; int wordCnt = 0; for (IntWritable value : values) wordCnt += value.get(); totalWordCnt.set(wordCnt); ctx.write(key, totalWordCnt); reduceError(); }
/** {@inheritDoc} */ @Override protected void reduce(Text key, Iterable<IntWritable> values, Context ctx) throws IOException, InterruptedException { int s = 0; for (IntWritable val : values) s += val.get(); System.out.println(">>>> Reduced: " + s); ctx.write(line, new IntWritable(s)); } }
/** {@inheritDoc} */ @Override public void reduce(Text key, Iterable<IntWritable> values, Context ctx) throws IOException, InterruptedException { ctx.getCounter(TestCounter.COUNTER1).increment(1); ctx.getCounter(TestCounter.COUNTER2).increment(1); int sum = 0; for (IntWritable value : values) sum += value.get(); ctx.write(key, new IntWritable(sum)); } }
/** {@inheritDoc} */ @Override protected void reduce(Text key, Iterable<IntWritable> values, Context ctx) throws IOException, InterruptedException { int lineCnt = 0; for (IntWritable value : values) lineCnt += value.get(); sum.set(lineCnt); X.println("___ combo: " + lineCnt); ctx.write(key, sum); } }
/** {@inheritDoc} */ @Override public void reduce(Text key, Iterable<IntWritable> values, Context ctx) throws IOException, InterruptedException { while (reduceLockFile.exists()) Thread.sleep(50); int wordCnt = 0; for (IntWritable value : values) wordCnt += value.get(); totalWordCnt.set(wordCnt); ctx.write(key, totalWordCnt); } }
/** {@inheritDoc} */ @Override protected void reduce(UUID key, Iterable<NullWritable> vals, Context ctx) throws IOException, InterruptedException { // X.printerrln("___ rdc: " + key); text.set(key.toString()); ctx.write(text, NullWritable.get()); } }
public void reduce(Key key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException { int sum = 0; for (IntWritable val : values) { sum += val.get(); } result.set(sum); context.write(key, result); } }
private void flushIndexToContextAndClose(BytesWritable key, IncrementalIndex index, Context context) throws IOException, InterruptedException { final List<String> dimensions = index.getDimensionNames(); Iterator<Row> rows = index.iterator(); while (rows.hasNext()) { context.progress(); Row row = rows.next(); InputRow inputRow = getInputRowFromRow(row, dimensions); // reportParseExceptions is true as any unparseable data is already handled by the mapper. InputRowSerde.SerializeResult serializeResult = InputRowSerde.toBytes(typeHelperMap, inputRow, combiningAggs); context.write( key, new BytesWritable(serializeResult.getSerializedRow()) ); } index.close(); }