文件模式:
在某个单一操作中处理一系列文件。例如一个日志处理的MapReduce作业可能要分析一个月的日志量。如果一个文件一个文件或者一个目录一个目录的声明那就太麻烦了,可以使用通配符(wild card)来匹配多个文件(这个操作也叫做globbing)。
Hadoop提供了两种方法来处理文件组:
public FileStatus[] globStatus(Path pathPattern) throws IOException;
public FileStatus[] globStatus(Path pathPattern, PathFilter filter) throws IOException;
PathFilter
FileSystem的listStatus()和globStatus()方法提供了一个可选参数:PathFilter——它允许一些更细化的控制匹配:例如排除某个特定文件。
package org.apache.hadoop.fs;
public interface PathFilter
{
boolean accept(Path path);
}
hadoop的匹配符
描述:
利用通配符和PathFilter 对象,将本地多种格式的文件上传至 HDFS文件系统,并过滤掉 txt文本格式以外的文件。
数据: