本文整理汇总了Java中org.jruby.RubyHash.keySet方法的典型用法代码示例。如果您正苦于以下问题:Java RubyHash.keySet方法的具体用法?Java RubyHash.keySet怎么用?Java RubyHash.keySet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jruby.RubyHash
的用法示例。
在下文中一共展示了RubyHash.keySet方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setHashParameters
import org.jruby.RubyHash; //导入方法依赖的package包/类
private void setHashParameters(Transformer transformer, RubyHash hash) {
Set<String> keys = hash.keySet();
for (String key : keys) {
String value = (String)hash.get(key);
transformer.setParameter(key, unparseValue(value));
}
}
示例2: toJavaHash
import org.jruby.RubyHash; //导入方法依赖的package包/类
public static Map<?, ?> toJavaHash(RubyHash rubyHash) {
HashMap<Object, Object> map = new HashMap<Object, Object>();
Set<?> keySet = rubyHash.keySet();
for (Object rubyKey : keySet) {
Object rubyValue = rubyHash.get(rubyKey);
Object javaKey = toJavaObject(rubyKey);
Object javaValue = toJavaObject(rubyValue);
map.put(javaKey, javaValue);
}
return map;
}
示例3: toDocuments
import org.jruby.RubyHash; //导入方法依赖的package包/类
@Override
protected LWDocument[] toDocuments(LongWritable key, Text value, Reporter reporter,
Configuration conf) throws IOException {
Map<String, Object> params = new HashMap<String, Object>();
params.put(LOG_RUBY_PARAM, value.toString());
params.put(FILTERS_ARRAY_RUBY_PARAM, filters);
List<String> toRemoveList = new ArrayList<String>();
toRemoveList.add(LOG_RUBY_PARAM);
toRemoveList.add(FILTERS_ARRAY_RUBY_PARAM);
Object response = executeScript(MATCHER_RUBY_CLASS, params, toRemoveList);
try {
RubyHash hash = (RubyHash) response;
if (response != null) {
Set<String> keys = hash.keySet();
LWDocument document = createDocument();
for (String currentKey : keys) {
document.addField(currentKey, hash.get(currentKey));
}
// Adding the file where this log was taken
FileSplit fileSplit = (FileSplit) reporter.getInputSplit();
String originalLogFilePath = fileSplit.getPath().toUri().getPath();
document.addField(PATH_FIELD_NAME, originalLogFilePath);
// Adding offset value
document.addField(BYTE_OFFSET_FIELD_NAME, key.toString());
// Set ID
document.setId(originalLogFilePath + "-" + key.toString() + "-" + System.currentTimeMillis());
return new LWDocument[] {document};
} else {
return null;
}
} catch (Exception e) {
log.error("Error: " + e.getMessage());
throw new RuntimeException("Error executing ruby script");
}
}