Package org.apache.hadoop.ruby.mapred

Source Code of org.apache.hadoop.ruby.mapred.JRubyMapper

package org.apache.hadoop.ruby.mapred;

import java.io.IOException;

import javax.script.ScriptException;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapred.Mapper;
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.hadoop.mapred.Reporter;
import org.apache.hadoop.ruby.JRubyEvaluator;

public class JRubyMapper extends JRubyMapRed implements
    Mapper<LongWritable, Text, Text, IntWritable> {

  public void map(LongWritable key, Text value,
      OutputCollector<Text, IntWritable> output, Reporter reporter)
      throws IOException {
    // invoke "map" method in ruby
    JRubyEvaluator evaluator = getJRubyEvaluator();
    try {
      evaluator.invoke("wrap_map", key, value, output, reporter);
    } catch (ScriptException e) {
      reporter.setStatus(e.getMessage());
    } finally {
      evaluator.checkResource();
    }
  }
}
TOP

Related Classes of org.apache.hadoop.ruby.mapred.JRubyMapper

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.