Hadoop的PathFilter使用
来源:互联网 发布:哪些是应用层网络协议 编辑:程序博客网 时间:2024/05/01 02:19
Hadoop的PathFilter使用
源码接口定义:
public interface PathFilter { /** * Tests whether or not the specified abstract pathname should be * included in a pathname list. * * @param path The abstract pathname to be tested * @return <code>true</code> if and only if <code>pathname</code> * should be included */ boolean accept(Path path);}
用法:
static class TextPathFilter extends Configured implements PathFilter {@Overridepublic boolean accept(Path path) {FileSystem fs;try {fs = FileSystem.get(getConf());FileStatus fstatus = fs.getFileStatus(path);List<String> lstName = new ArrayList<String>();lstName.add("input1");lstName.add("input2");lstName.add("input3");lstName.add("input4");if(fstatus.isDirectory()) { //是目录的话返回truereturn true;}if(fstatus.isFile() && lstName.contains(fstatus.getPath().getParent().getName())) { //是文件的话且满足过滤条件返回truereturn true;}} catch (IOException e) {e.printStackTrace();}return false;}}
Driver类写的:
FileInputFormat.addInputPath(job, new Path(otherArgs[0])); //输入路径FileInputFormat.setInputDirRecursive(job, true);// 递归输入FileInputFormat.setInputPathFilter(job, TextPathFilter.class); //指定pathfilter类
0 0
- Hadoop的PathFilter使用
- hadoop的 pathfilter使用
- Hadoop的PathFilter使用
- hadoop在使用PathFilter时遇到的问题
- hadoop 之 PathFilter -- 输入文件过滤器
- hadoop 之 PathFilter -- 输入文件过滤器
- [Hadoop]输入路径过滤,通配符与PathFilter
- 利用PathFilter上传多个本地的文件
- Hadoop的MultipleOutputFormat使用
- hadoop的使用
- hadoop的使用记录
- Hadoop HPROF 的使用
- hadoop的使用命令
- hadoop CombineFileInputFormat的使用
- Hadoop的MultipleOutputFormat使用
- Hadoop DBOutputFormat的使用
- hadoop的libhdfs使用
- Hadoop HPROF 的使用
- Android开发-fragment切换、hide、show、fragmentmanager的基础应用
- Spring@Autowired注解与自动装配
- 使用OpenSSL生成RSA公钥和私钥
- 阻塞队列BlockingQueue用法
- New Reform
- Hadoop的PathFilter使用
- 阻塞队列--LinkedBlockingQueue
- unity UGUI Toggle事件管理
- ARM Linux 3.x的设备树(Device Tree)
- Javascript中的apply与call详解
- javascript获取网页中指定节点的父节点、子节点的方法小结
- log4j基础知识&Log4j.properties配置讲解
- PHP实现301重定向
- Java UOOK 课程学习笔记 1