Java Code Examples for org.apache.hadoop.mapreduce.TaskInputOutputContext#write()

The following examples show how to use org.apache.hadoop.mapreduce.TaskInputOutputContext#write() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DistSum.java    From hadoop with Apache License 2.0 6 votes vote down vote up
/** Compute sigma */
static void compute(Summation sigma,
    TaskInputOutputContext<?, ?, NullWritable, TaskResult> context
    ) throws IOException, InterruptedException {
  String s;
  LOG.info(s = "sigma=" + sigma);
  context.setStatus(s);

  final long start = System.currentTimeMillis();
  sigma.compute();
  final long duration = System.currentTimeMillis() - start;
  final TaskResult result = new TaskResult(sigma, duration);

  LOG.info(s = "result=" + result);
  context.setStatus(s);
  context.write(NullWritable.get(), result);
}
 
Example 2
Source File: DistSum.java    From big-c with Apache License 2.0 6 votes vote down vote up
/** Compute sigma */
static void compute(Summation sigma,
    TaskInputOutputContext<?, ?, NullWritable, TaskResult> context
    ) throws IOException, InterruptedException {
  String s;
  LOG.info(s = "sigma=" + sigma);
  context.setStatus(s);

  final long start = System.currentTimeMillis();
  sigma.compute();
  final long duration = System.currentTimeMillis() - start;
  final TaskResult result = new TaskResult(sigma, duration);

  LOG.info(s = "result=" + result);
  context.setStatus(s);
  context.write(NullWritable.get(), result);
}
 
Example 3
Source File: BulkContextWriter.java    From datawave with Apache License 2.0 5 votes vote down vote up
@Override
protected void flush(Multimap<BulkIngestKey,Value> entries, TaskInputOutputContext<?,?,BulkIngestKey,Value> context) throws IOException,
                InterruptedException {
    for (Map.Entry<BulkIngestKey,Value> entry : entries.entries()) {
        context.write(entry.getKey(), entry.getValue());
    }
}
 
Example 4
Source File: AggregatingReducer.java    From datawave with Apache License 2.0 5 votes vote down vote up
/**
 * This method is called once for each key. Most applications will define their reduce class by overriding this method. The default implementation is an
 * identity function.
 */
@SuppressWarnings("unchecked")
public void doReduce(IK key, Iterable<IV> values, TaskInputOutputContext<?,?,OK,OV> context) throws IOException, InterruptedException {
    for (IV value : values) {
        context.write((OK) key, (OV) value);
    }
}
 
Example 5
Source File: LiveContextWriter.java    From datawave with Apache License 2.0 4 votes vote down vote up
protected void writeToContext(TaskInputOutputContext<?,?,Text,Mutation> context, Map.Entry<BulkIngestKey,Value> entry) throws IOException,
                InterruptedException {
    context.write(entry.getKey().getTableName(), getMutation(entry.getKey().getKey(), entry.getValue()));
}
 
Example 6
Source File: AggregatingReducer.java    From datawave with Apache License 2.0 2 votes vote down vote up
/**
 * Write the output to the context
 * 
 * @param key
 * @param value
 * @param ctx
 * @throws IOException
 * @throws InterruptedException
 */
protected void writeToContext(OK key, OV value, TaskInputOutputContext<?,?,OK,OV> ctx) throws IOException, InterruptedException {
    ctx.write(key, value);
}