cascading helloworld 案例
来源:互联网 发布:游戏原画 培训 知乎 编辑:程序博客网 时间:2024/06/10 17:17
Cascading是一个数据处理的API和查询处理计划,用于定义,共享数据处理工作流,还能在单一计算节点或分布式计算集群上执行数据处理工作流。在单一计算节点,Cascading的本地模式(local mode)可以在部署到集群之前,用于测试代码和处理本地文件。在一个部署了Apache Hadoop的分布式计算集群上,Cascading在hadoop API上增加了一个抽象层,大大简化了Hadoop 应用程序的开发,job的创建和调度。
话不多说直接上代码:
package cascading.project;import java.util.Properties;import cascading.flow.FlowDef;import cascading.flow.hadoop2.Hadoop2MR1FlowConnector;import cascading.pipe.Pipe;import cascading.property.AppProps;import cascading.scheme.hadoop.TextDelimited;import cascading.tap.Tap;import cascading.tap.hadoop.Hfs;/** * A Hello World example app that copies data from one location to another. * <p/> * It assumes the input files are TSV with headers on the first line. */public class MainHadoop { public static void main( String[] args ) { String inPath = args[ 0 ];//输入路径 String outPath = args[ 1 ];//输出路径 Properties properties = new Properties();//设置运行过程中需要的参数 比如reduce的个数等 AppProps.setApplicationJarClass( properties, MainHadoop.class );//main函数 Hadoop2MR1FlowConnector flowConnector = new Hadoop2MR1FlowConnector( properties );//调用mapreduce包装接口 // create the source tap 使用tap包装输入路径 Tap inTap = new Hfs( new TextDelimited( true, "\t" ), inPath ); // create the sink tap使用tap包装输出路径 Tap outTap = new Hfs( new TextDelimited( true, "\t" ), outPath ); // specify a pipe to connect the taps 在输入tap和输出tap之间建立管道 Pipe copyPipe = new Pipe( "copy" ); // connect the taps, pipes, etc., into a flow 将三者连接起来 FlowDef flowDef = FlowDef.flowDef() .addSource( copyPipe, inTap ) .addTailSink( copyPipe, outTap ); // run the flow 运行mapreduce流 flowConnector.connect( flowDef ).complete(); } }
代码的GitHub地址:https://github.com/Cascading/ProjectTemplate
阅读全文
0 0
- cascading helloworld 案例
- EOS案例实现HelloWorld
- 6、HelloWorld案例学习
- Hibernate--HelloWorld案例--(一)
- nodejs案例-HelloWorld
- Struts2入门(HelloWorld案例)
- Maven第一个HelloWorld案例
- 第一个程序:HelloWorld案例
- MFC第一个helloworld案例
- 第一个程序:HelloWorld案例
- fractional cascading
- cascading基本概念
- 关于Cascading
- Cascading介绍
- helloworld:一个完整的WCF案例
- helloworld:一个完整的WCF案例
- SpringMVC开发之HelloWorld案例以及分析
- helloworld:一个完整的WCF案例
- 《深入理解java虚拟机》读书笔记——运行时栈帧结构
- spring事务
- 禅道安装
- hdu2433(最短路径树)
- html / js 代码编写注意事项收集
- cascading helloworld 案例
- Android Studio解决65536Dex超出方法数问题
- UVALive 6455Stealing Harry Potter's Precious(广搜)
- android studio terminal jni 生成头文件命令
- C++ hash_map
- Vim技能修炼教程(2)
- 解决安装WordPress主题及插件需要输入FTP问题
- android 从相册选取图片在小米手机报错的解决办法
- Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.