本文整理汇总了Java中cascading.pipe.assembly.CountBy类的典型用法代码示例。如果您正苦于以下问题:Java CountBy类的具体用法?Java CountBy怎么用?Java CountBy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CountBy类属于cascading.pipe.assembly包,在下文中一共展示了CountBy类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import cascading.pipe.assembly.CountBy; //导入依赖的package包/类
public static void main(String[] args) {
if (args.length < 2) {
throw new IllegalArgumentException("Please specify input and ouput paths as arguments.");
}
Fields token = new Fields( "token", String.class );
Fields text = new Fields( "text" );
RegexSplitGenerator splitter = new RegexSplitGenerator( token, "\\s+" );
// only returns "token"
Pipe docPipe = new Each( "token", text, splitter, Fields.RESULTS );
Pipe wcPipe = new Pipe( "wc", docPipe );
wcPipe = new AggregateBy( wcPipe, token, new CountBy(new Fields("count")));
Tap inTap = new Hfs(new TextDelimited(text, "\n" ), args[0]);
Tap outTap = new Hfs(new TextDelimited(false, "\n"), args[1], SinkMode.REPLACE);
FlowDef flowDef = FlowDef.flowDef().setName( "wc" )
.addSource( docPipe, inTap )
.addTailSink( wcPipe, outTap );
FlowConnector flowConnector = new FlinkConnector();
Flow wcFlow = flowConnector.connect( flowDef );
wcFlow.complete();
}
示例2: main
import cascading.pipe.assembly.CountBy; //导入依赖的package包/类
public static void main(String[] args) {
String salesPath = args[0];
String storePath = args[1];
String outPath = args[2];
String date = "2452229";
Properties properties = new Properties();
AppProps.setApplicationJarClass(properties, Main.class);
HadoopFlowConnector flowConnector = new HadoopFlowConnector(properties);
Tap salesTap = new Hfs(new ORCFile(null, "0,7"), salesPath);
Tap storeTap = new Hfs(new AvroScheme(), storePath);
Tap outTap = new Hfs(new TextDelimited(true, "\t"), outPath);
Pipe salesPipe = new Each("sales", new Fields("solddatesk"), new DateFilter(Integer.valueOf(date)));
Pipe storePipe = new Pipe("store");
Pipe joinPipe = new HashJoin(salesPipe, new Fields("storesk"), storePipe, new Fields("storeSk"));
// _col24 is state_name
Pipe countPipe = new CountBy(joinPipe, new Fields("state"),
new Fields("item_count"));
FlowDef flowDef = FlowDef.flowDef().setName("count")
.addSource(salesPipe, salesTap)
.addSource(storePipe, storeTap)
.addTailSink(countPipe, outTap);
//.addTailSink(joinPipe, outTap);
Flow countFlow = flowConnector.connect(flowDef);
countFlow.complete();
}