本文整理汇总了Java中cascading.tuple.Tuple.elements方法的典型用法代码示例。如果您正苦于以下问题:Java Tuple.elements方法的具体用法?Java Tuple.elements怎么用?Java Tuple.elements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cascading.tuple.Tuple
的用法示例。
在下文中一共展示了Tuple.elements方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: source
import cascading.tuple.Tuple; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public boolean source(FlowProcess<Properties> flowProcess, SourceCall<Object[], ScrollQuery> sourceCall) throws IOException {
ScrollQuery query = sourceCall.getInput();
if (!query.hasNext()) {
return false;
}
TupleEntry entry = sourceCall.getIncomingEntry();
Map<String, ?> data = (Map<String, ?>) query.next()[1];
FieldAlias alias = (FieldAlias) sourceCall.getContext()[0];
if (entry.getFields().isDefined()) {
// lookup using writables
for (Comparable<?> field : entry.getFields()) {
Object result = data;
// check for multi-level alias
for (String level : StringUtils.tokenize(alias.toES(field.toString()), ".")) {
result = ((Map) result).get(level);
if (result == null) {
break;
}
}
entry.setObject(field, result);
}
}
else {
// no definition means no coercion
List<Object> elements = Tuple.elements(entry.getTuple());
elements.clear();
elements.addAll(data.values());
}
return true;
}
示例2: source
import cascading.tuple.Tuple; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public boolean source(FlowProcess<JobConf> flowProcess, SourceCall<Object[], RecordReader> sourceCall) throws IOException {
Object[] context = sourceCall.getContext();
if (!sourceCall.getInput().next(context[0], context[1])) {
return false;
}
TupleEntry entry = sourceCall.getIncomingEntry();
Map data = (Map) context[1];
FieldAlias alias = (FieldAlias) context[2];
if (entry.getFields().isDefined()) {
// lookup using writables
Text lookupKey = new Text();
for (Comparable<?> field : entry.getFields()) {
// check for multi-level alias (since ES 1.0)
Object result = data;
for (String level : StringUtils.tokenize(alias.toES(field.toString()), ".")) {
lookupKey.set(level);
result = ((Map) result).get(lookupKey);
if (result == null) {
break;
}
}
CascadingUtils.setObject(entry, field, result);
}
}
else {
// no definition means no coercion
List<Object> elements = Tuple.elements(entry.getTuple());
elements.clear();
elements.addAll(data.values());
}
return true;
}