Ejemplo n.º 1
0
 public void reduce(Text key, Iterable<LongWritable> values, Context context)
     throws IOException, InterruptedException {
   int sum = 0;
   for (LongWritable val : values) {
     sum += val.get();
   }
   result.set(sum);
   context.write(key, result);
 }
Ejemplo n.º 2
0
  @Override
  public boolean next(LongWritable keyHolder, MapWritable valueHolder) throws IOException {
    SolrDocument doc = cursor.nextDocument();
    if (doc == null) {
      return false;
    }

    keyHolder.set(pos++);

    for (int i = 0; i < readColumns.length; i++) {
      String key = readColumns[i];
      Object vObj = doc.getFieldValue(key);
      Writable value = (vObj == null) ? NullWritable.get() : new Text(vObj.toString());
      valueHolder.put(new Text(key), value);
    }
    return true;
  }