本文整理汇总了Java中org.jruby.RubyRuntimeAdapter类的典型用法代码示例。如果您正苦于以下问题:Java RubyRuntimeAdapter类的具体用法?Java RubyRuntimeAdapter怎么用?Java RubyRuntimeAdapter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RubyRuntimeAdapter类属于org.jruby包,在下文中一共展示了RubyRuntimeAdapter类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: map
import org.jruby.RubyRuntimeAdapter; //导入依赖的package包/类
@Override
public void map(LongWritable key, Text value,
OutputCollector<Text, Text> outputCollector, Reporter arg3) throws IOException {
Ruby runtime = Ruby.getGlobalRuntime();
RubyRuntimeAdapter adapter = JavaEmbedUtils.newRuntimeAdapter();
IRubyObject receiver = adapter.eval(runtime, mapper_code);
IRubyObject rubyKey = JavaUtil.convertJavaToRuby(runtime, key);
IRubyObject rubyValue = JavaUtil.convertJavaToRuby(runtime, value);
MapleRoadCollector collector =
new MapleRoadCollector(keyText, valueText, outputCollector);
IRubyObject rubyCollector = JavaUtil.convertJavaToRuby(runtime, collector);
Helpers.invoke(runtime.getCurrentContext(), receiver, "map", rubyKey, rubyValue, rubyCollector);
}
示例2: reduce
import org.jruby.RubyRuntimeAdapter; //导入依赖的package包/类
@Override
public void reduce(Text key, Iterator<IntWritable> values,
OutputCollector<Text, IntWritable> outputCollector, Reporter arg3) throws IOException {;
Ruby runtime = Ruby.getGlobalRuntime();
RubyRuntimeAdapter adapter = JavaEmbedUtils.newRuntimeAdapter();
IRubyObject receiver = adapter.eval(runtime, reducer_code);
IRubyObject rubyKey = JavaUtil.convertJavaToRuby(runtime, key);
IRubyObject rubyValues = JavaUtil.convertJavaToRuby(runtime, values);
MapleRoadCollectorTextInt collector =
new MapleRoadCollectorTextInt(keyText, valueInt, outputCollector);
IRubyObject rubyCollector = JavaUtil.convertJavaToRuby(runtime, collector);
Helpers.invoke(runtime.getCurrentContext(), receiver, "reduce", rubyKey, rubyValues, rubyCollector);
}
示例3: map
import org.jruby.RubyRuntimeAdapter; //导入依赖的package包/类
@Override
public void map(LongWritable key, Text value,
OutputCollector<Text, IntWritable> outputCollector, Reporter arg3) throws IOException {
Ruby runtime = Ruby.getGlobalRuntime();
RubyRuntimeAdapter adapter = JavaEmbedUtils.newRuntimeAdapter();
IRubyObject receiver = adapter.eval(runtime, mapper_code);
IRubyObject rubyKey = JavaUtil.convertJavaToRuby(runtime, key);
IRubyObject rubyValue = JavaUtil.convertJavaToRuby(runtime, value);
MapleRoadCollectorTextInt collector =
new MapleRoadCollectorTextInt(keyText, valueInt, outputCollector);
IRubyObject rubyCollector = JavaUtil.convertJavaToRuby(runtime, collector);
Helpers.invoke(runtime.getCurrentContext(), receiver, "map", rubyKey, rubyValue, rubyCollector);
}
示例4: reduce
import org.jruby.RubyRuntimeAdapter; //导入依赖的package包/类
@Override
public void reduce(Text key, Iterator<Text> values,
OutputCollector<Text, Text> outputCollector, Reporter arg3) throws IOException {;
Ruby runtime = Ruby.getGlobalRuntime();
RubyRuntimeAdapter adapter = JavaEmbedUtils.newRuntimeAdapter();
IRubyObject receiver = adapter.eval(runtime, reducer_code);
IRubyObject rubyKey = JavaUtil.convertJavaToRuby(runtime, key);
IRubyObject rubyValues = JavaUtil.convertJavaToRuby(runtime, values);
MapleRoadCollector collector =
new MapleRoadCollector(keyText, valueText, outputCollector);
IRubyObject rubyCollector = JavaUtil.convertJavaToRuby(runtime, collector);
Helpers.invoke(runtime.getCurrentContext(), receiver, "reduce", rubyKey, rubyValues, rubyCollector);
}
示例5: DefaultCssResolver
import org.jruby.RubyRuntimeAdapter; //导入依赖的package包/类
public DefaultCssResolver(Ruby runtime, RubyRuntimeAdapter evaler) {
this.runtime = runtime;
this.evaler = evaler;
}