本文整理汇总了Java中cascading.tap.Tap.openForWrite方法的典型用法代码示例。如果您正苦于以下问题:Java Tap.openForWrite方法的具体用法?Java Tap.openForWrite怎么用?Java Tap.openForWrite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cascading.tap.Tap
的用法示例。
在下文中一共展示了Tap.openForWrite方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: openTrapForWrite
import cascading.tap.Tap; //导入方法依赖的package包/类
@Override
public TupleEntryCollector openTrapForWrite(Tap trap) throws IOException {
if (trap instanceof Hfs) {
JobConf jobConf = new JobConf(this.getConfigCopy());
int stepNum = jobConf.getInt( "cascading.flow.step.num", 0 );
int nodeNum = jobConf.getInt( "cascading.flow.node.num", 0 );
String partname = String.format( "-%05d-%05d-%05d", stepNum, nodeNum, this.getCurrentSliceNum() );
jobConf.set( "cascading.tapcollector.partname", "%s%spart" + partname );
String value = String.format( "attempt_%012d_0000_m_%06d_0", (int) Math.rint( System.currentTimeMillis() ), this.getCurrentSliceNum() );
jobConf.set( "mapred.task.id", value );
jobConf.set( "mapreduce.task.id", value );
return trap.openForWrite( new FlinkFlowProcess( jobConf ), null);
}
else {
throw new UnsupportedOperationException("Only Hfs taps are supported as traps");
}
}
示例2: writeToLocalTap
import cascading.tap.Tap; //导入方法依赖的package包/类
private void writeToLocalTap(Tap<?, ?, ?> tap) throws IOException {
@SuppressWarnings("unchecked")
Tap<Properties, ?, ?> localTap = (Tap<Properties, ?, ?>) tap;
Properties conf = new Properties();
LocalFlowProcess flowProcess = new LocalFlowProcess(conf);
flowProcess.setStepStats(new LocalStepStats(new NullFlowStep(), NullClientState.INSTANCE));
localTap.sinkConfInit(flowProcess, conf);
TupleEntryCollector collector = localTap.openForWrite(flowProcess);
for (TupleEntry tuple : data.asTupleEntryList()) {
collector.add(tuple);
}
collector.close();
localTap.commitResource(conf);
}
示例3: writeToHadoopTap
import cascading.tap.Tap; //导入方法依赖的package包/类
private void writeToHadoopTap(Tap<?, ?, ?> tap) throws IOException {
@SuppressWarnings("unchecked")
Tap<JobConf, ?, ?> hadoopTap = (Tap<JobConf, ?, ?>) tap;
JobConf conf = new JobConf();
HadoopFlowProcess flowProcess = new HadoopFlowProcess(conf);
hadoopTap.sinkConfInit(flowProcess, conf);
TupleEntryCollector collector = hadoopTap.openForWrite(flowProcess);
for (TupleEntry tuple : data.asTupleEntryList()) {
collector.add(tuple);
}
collector.close();
}
示例4: openTapForWrite
import cascading.tap.Tap; //导入方法依赖的package包/类
@Override
public TupleEntryCollector openTapForWrite(Tap tap) throws IOException {
return tap.openForWrite( this, null ); // do not honor sinkmode as this may be opened across tasks
}