本文整理汇总了Java中cascading.scheme.SourceCall.getIncomingEntry方法的典型用法代码示例。如果您正苦于以下问题:Java SourceCall.getIncomingEntry方法的具体用法?Java SourceCall.getIncomingEntry怎么用?Java SourceCall.getIncomingEntry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cascading.scheme.SourceCall
的用法示例。
在下文中一共展示了SourceCall.getIncomingEntry方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: source
import cascading.scheme.SourceCall; //导入方法依赖的package包/类
/**
* Populates the {@link Corc} with the next value from the {@link RecordReader}. Then copies the values into the
* incoming {@link TupleEntry}.
*/
@Override
public boolean source(FlowProcess<? extends Configuration> flowProcess, SourceCall<Corc, RecordReader> sourceCall)
throws IOException {
Corc corc = sourceCall.getContext();
@SuppressWarnings("unchecked")
boolean next = sourceCall.getInput().next(NullWritable.get(), corc);
if (!next) {
return false;
}
TupleEntry tupleEntry = sourceCall.getIncomingEntry();
for (Comparable<?> fieldName : tupleEntry.getFields()) {
if (ROW_ID_NAME.equals(fieldName)) {
tupleEntry.setObject(ROW_ID_NAME, corc.getRecordIdentifier());
} else {
tupleEntry.setObject(fieldName, corc.get(fieldName.toString()));
}
}
return true;
}
示例2: source
import cascading.scheme.SourceCall; //导入方法依赖的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;
}
示例3: source
import cascading.scheme.SourceCall; //导入方法依赖的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;
}
示例4: source
import cascading.scheme.SourceCall; //导入方法依赖的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;
}
boolean isJSON = (Boolean) sourceCall.getContext()[SRC_CTX_OUTPUT_JSON];
TupleEntry entry = sourceCall.getIncomingEntry();
Map<String, Object> data;
if (isJSON) {
data = new HashMap<String, Object>(1);
data.put("data", query.next()[1]);
} else {
data = (Map<String, Object>) query.next()[1];
}
FieldAlias alias = (FieldAlias) sourceCall.getContext()[SRC_CTX_ALIASES];
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;
}
示例5: source
import cascading.scheme.SourceCall; //导入方法依赖的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[SRC_CTX_KEY], context[1])) {
return false;
}
boolean isJSON = (Boolean) context[SRC_CTX_OUTPUT_JSON];
TupleEntry entry = sourceCall.getIncomingEntry();
Map data;
if (isJSON) {
data = new HashMap(1);
data.put(new Text("data"), context[SRC_CTX_VALUE]);
} else {
data = (Map) context[SRC_CTX_VALUE];
}
FieldAlias alias = (FieldAlias) context[SRC_CTX_ALIASES];
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;
}