1cascading是什么
cascading是一个架构在Hadoop上的API,用来创建复杂和容错数据处理工作流。它抽象了集群拓扑结构和配置来快速开发复杂分布式的应用,而不用考虑背后的MapReduce。Cascading目前依赖于 Hadoop提供存储和执行架构,但是Cascading API为开发者隔离了Hadoop的技术细节,提供了不需要改变初始流程工作流定义就可以在不同的计算框架内运行的能力。
2为什么要用cascading
cascading使组织能够快速开发复杂的数据处理与Hadoop的应用。cascading使用场景通常有:
1增长的数据量日益增加的计算的线性增长使无法使用单独的计算单元计算,因此需要以hadoop为技术手段的分布式计算。
2 复杂的计算过程,cascading简化了hadoop的使用。使用层叠的api(DSLs)作为查询语言。允许开发者和分析师,数据挖掘和探索的ad-hoc查询。
3helloworld
Properties properties = new Properties();
AppProps.setApplicationJarClass( properties, Main.class );
FlowConnector flowConnector = new HadoopFlowConnector( properties );
Pipe helloPipe= new HelloPipe("HelloPipe" );
String inputPath=args[0];
String outPath=args[1];
Tap inputPathT= new Hfs( new TextLine(), inputPath);
Tap outPathT=new Hfs( new SequenceFile( new Fields( "time", "ip","url" ) ), outPath);
private static class HelloPipe extends SubAssembly{
public HelloPipe(String name) {
RegexSplitter regexSplitter = new RegexSplitter( new Fields("time", "ip","url" ) );
Pipe importPipe = new Each( name, new Fields( "line" ), regexSplitter );
importPipe = new Each( importPipe, new MyFileter (new Fields("time", "ip","url" )) );
setTails( importPipe );
}
}
4主要的类
5 Source and Sink Taps
Schemes
TextLine:text行文本escription | Cascading local platform | Hadoop platform |
Package Name | cascading.scheme.local | cascading.scheme.hadoop |
Read lines of text | TextLine | TextLine |
Read delimited text (CSV, TSV, etc) | TextDelimited | TextDelimited |
Cascading proprietary efficient binary | SequenceFile | |
External Hadoop application binary (custom Writable type) | WritableSequenceFile |
Taps种类:
-
FileTap/LFS
-
本地文件系统上的文件
Hfs
-
分布式文件
-
MultiSourceTap
-
用来把多个水龙头实例作为输入源变成单一输入原。唯一的限制是所有的抽头实例相同的计划传递到一个新的MultiSourceTap 类(不一定是相同的计划实例)。
MultiSinkTap
-
用来把多个水龙头实例作为输出源变成单一输出原。在运行时,每一个元组输出管道组件,每一个孩子点选的MultiSinkTap将下沉的元组。
TemplateTap
-
The
cascading.tap.hadoop.TemplateTap
用来把输出源映射到目录
GlobHfs
-