本文整理汇总了Java中cascading.scheme.SourceCall类的典型用法代码示例。如果您正苦于以下问题:Java SourceCall类的具体用法?Java SourceCall怎么用?Java SourceCall使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SourceCall类属于cascading.scheme包,在下文中一共展示了SourceCall类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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包/类
@Override
public boolean source(FlowProcess<JobConf> flowProcess, SourceCall<Object[], RecordReader> sourceCall) throws IOException {
Tuple result = new Tuple();
Object key = sourceCall.getContext()[0];
Object value = sourceCall.getContext()[1];
boolean hasNext = sourceCall.getInput().next(key, value);
if (!hasNext) { return false; }
// Skip nulls
if (key == null || value == null) { return true; }
LongWritable keyWritable = (LongWritable) key;
ArrayListTextWritable values = (ArrayListTextWritable) value;
result.add(keyWritable);
for(Text textValue : values)
result.add(textValue);
sourceCall.getIncomingEntry().setTuple(result);
return true;
}
示例3: source
import cascading.scheme.SourceCall; //导入依赖的package包/类
@Override
public boolean source(FlowProcess<JobConf> prcs, SourceCall<Object[], RecordReader> sourceCall)
throws IOException {
Object key = sourceCall.getContext()[0];
Object value = sourceCall.getContext()[1];
boolean result = sourceCall.getInput().next(key, value);
if (!result) {
return false;
}
sourceCall.getIncomingEntry().setTuple(new Tuple(key, value));
return true;
}
示例4: source
import cascading.scheme.SourceCall; //导入依赖的package包/类
@Override
public boolean source(FlowProcess<JobConf> flowProcess,
SourceCall<Object[], RecordReader> sourceCall) throws IOException {
BytesWritable key = (BytesWritable) sourceCall.getContext()[0];
BytesWritable value = (BytesWritable) sourceCall.getContext()[1];
boolean result = sourceCall.getInput().next(key, value);
if (!result) { return false; }
Tuple tuple = sourceCall.getIncomingEntry().getTuple();
tuple.clear();
tuple.add(getBytes(key));
tuple.add(getBytes(value));
return true;
}
示例5: source
import cascading.scheme.SourceCall; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public boolean source(FlowProcess<JobConf> flowProcess, SourceCall<Object[], RecordReader> sourceCall)
throws IOException {
Tuple result = new Tuple();
Object key = sourceCall.getContext()[0];
Object value = sourceCall.getContext()[1];
boolean hasNext = sourceCall.getInput().next(key, value);
if (!hasNext) {
return false;
}
// Skip nulls
if (key == null || value == null) {
return true;
}
ImmutableBytesWritable keyWritable = (ImmutableBytesWritable) key;
Result row = (Result) value;
result.add(keyWritable);
result.add(row);
sourceCall.getIncomingEntry().setTuple(result);
return true;
}
示例6: sourcePrepare
import cascading.scheme.SourceCall; //导入依赖的package包/类
@Override
public void sourcePrepare(FlowProcess<Properties> flowProcess, SourceCall<Object[], ScrollQuery> sourceCall) throws IOException {
super.sourcePrepare(flowProcess, sourceCall);
Object[] context = new Object[1];
Settings settings = HadoopSettingsManager.loadFrom(flowProcess.getConfigCopy()).merge(props);
context[0] = CascadingUtils.alias(settings);
sourceCall.setContext(context);
IS_ES_20 = SettingsUtils.isEs20(settings);
}
示例7: sourceCleanup
import cascading.scheme.SourceCall; //导入依赖的package包/类
@Override
public void sourceCleanup(FlowProcess<Properties> flowProcess, SourceCall<Object[], ScrollQuery> sourceCall) throws IOException {
// in case of a source there's no local client so do all reporting here
report(sourceCall.getInput().stats(), flowProcess);
report(sourceCall.getInput().repository().stats(), flowProcess);
sourceCall.getInput().close();
sourceCall.setContext(null);
// used for consistency
cleanupClient(flowProcess);
}
示例8: 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;
}
示例9: sourcePrepare
import cascading.scheme.SourceCall; //导入依赖的package包/类
@Override
public void sourcePrepare(FlowProcess<JobConf> flowProcess, SourceCall<Object[], RecordReader> sourceCall) throws IOException {
super.sourcePrepare(flowProcess, sourceCall);
Object[] context = new Object[3];
context[0] = sourceCall.getInput().createKey();
context[1] = sourceCall.getInput().createValue();
// as the tuple _might_ vary (some objects might be missing), we use a map rather then a collection
Settings settings = loadSettings(flowProcess.getConfigCopy(), true);
context[2] = CascadingUtils.alias(settings);
sourceCall.setContext(context);
IS_ES_20 = SettingsUtils.isEs20(settings);
}
示例10: 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;
}
示例11: sourcePrepare
import cascading.scheme.SourceCall; //导入依赖的package包/类
@Override
public void sourcePrepare(FlowProcess<JobConf> flowProcess, SourceCall<Object[], RecordReader> sourceCall) throws IOException {
initIndices();
if (sourceCall.getContext() == null) {
sourceCall.setContext(new Object[2]);
}
sourceCall.getContext()[0] = sourceCall.getInput().createKey();
sourceCall.getContext()[1] = sourceCall.getInput().createValue();
}
示例12: sourcePrepare
import cascading.scheme.SourceCall; //导入依赖的package包/类
@Override
public void sourcePrepare( FlowProcess<? extends Configuration> flowProcess, SourceCall<Object[], RecordReader> sourceCall ) {
if( !( flowProcess instanceof FlowProcessWrapper) ) {
throw new RuntimeException( "not a flow process wrapper" );
}
if( !"process-default".equals( flowProcess.getProperty( "default" ) ) ) {
throw new RuntimeException("not default value");
}
if( !"source-replace".equals( flowProcess.getProperty( "replace" ) ) ) {
throw new RuntimeException( "not replaced value" );
}
if( !"node-replace".equals( flowProcess.getProperty( "default-node" ) ) ) {
throw new RuntimeException( "not replaced value" );
}
flowProcess = ( (FlowProcessWrapper) flowProcess ).getDelegate();
if( !"process-default".equals( flowProcess.getProperty( "default" ) ) ) {
throw new RuntimeException( "not default value" );
}
if( !"process-replace".equals( flowProcess.getProperty( "replace" ) ) ) {
throw new RuntimeException( "not replaced value" );
}
super.sourcePrepare( flowProcess, sourceCall );
}
示例13: source
import cascading.scheme.SourceCall; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public boolean source(FlowProcess<JobConf> fp, SourceCall<Object[], RecordReader> sc)
throws IOException {
Container<T> value = (Container<T>) sc.getInput().createValue();
boolean hasNext = sc.getInput().next(null, value);
if (!hasNext) { return false; }
// Skip nulls
if (value == null) { return true; }
sc.getIncomingEntry().setTuple(new Tuple(value.get()));
return true;
}
示例14: source
import cascading.scheme.SourceCall; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public boolean source(FlowProcess<JobConf> fp, SourceCall<Object[], RecordReader> sc)
throws IOException {
Container<Tuple> value = (Container<Tuple>) sc.getInput().createValue();
boolean hasNext = sc.getInput().next(null, value);
if (!hasNext) { return false; }
// Skip nulls
if (value == null) { return true; }
sc.getIncomingEntry().setTuple(value.get());
return true;
}
示例15: source
import cascading.scheme.SourceCall; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public boolean source(FlowProcess<? extends JobConf> fp, SourceCall<Object[], RecordReader> sc)
throws IOException {
Container<T> value = (Container<T>) sc.getInput().createValue();
boolean hasNext = sc.getInput().next(null, value);
if (!hasNext) { return false; }
// Skip nulls
if (value == null) { return true; }
sc.getIncomingEntry().setTuple(new Tuple(value.get()));
return true;
}