本文整理汇总了Java中org.apache.hadoop.fs.GlobPattern类的典型用法代码示例。如果您正苦于以下问题:Java GlobPattern类的具体用法?Java GlobPattern怎么用?Java GlobPattern使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GlobPattern类属于org.apache.hadoop.fs包,在下文中一共展示了GlobPattern类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepare
import org.apache.hadoop.fs.GlobPattern; //导入依赖的package包/类
@Override
public void prepare() throws IOException {
String argPattern = getArgument(1);
if (!caseSensitive) {
argPattern = StringUtils.toLowerCase(argPattern);
}
globPattern = new GlobPattern(argPattern);
}
示例2: init
import org.apache.hadoop.fs.GlobPattern; //导入依赖的package包/类
void init(String filePattern, PathFilter filter) throws IOException {
try {
userFilter = filter;
pattern = new GlobPattern(filePattern);
} catch (PatternSyntaxException e) {
throw new IOException("Illegal file pattern: " + e.getMessage(), e);
}
}
示例3: getFirstMatch
import org.apache.hadoop.fs.GlobPattern; //导入依赖的package包/类
public static Path getFirstMatch(FileSystem fs, Path path, String globPatternStr, boolean recursive)
throws IOException
{
RemoteIterator<LocatedFileStatus> files = fs.listFiles(path, recursive);
GlobPattern globPattern = new GlobPattern(globPatternStr);
while (files.hasNext())
{
Path aFile = files.next().getPath();
if(globPattern.matches(aFile.getName()))
return aFile;
}
return null;
}
示例4: compile
import org.apache.hadoop.fs.GlobPattern; //导入依赖的package包/类
@Override
protected Pattern compile(String s) {
return GlobPattern.compile(s);
}
示例5: shouldUseFlatGlob
import org.apache.hadoop.fs.GlobPattern; //导入依赖的package包/类
/**
* Determines based on config settings and suitability of {@code fixedPath} whether to use
* flat globbing logic where we use a single large listing during globStatus to then perform
* the core globbing logic in-memory.
*/
@VisibleForTesting
boolean shouldUseFlatGlob(Path fixedPath) {
// Config setting overrides all else.
if (!enableFlatGlob) {
return false;
}
// Only works for filesystems where the base Hadoop Path scheme matches the underlying URI
// scheme for GCS.
if (!getUri().getScheme().equals(GoogleCloudStorageFileSystem.SCHEME)) {
LOG.debug(
"Flat glob is on, but doesn't work for scheme '{}'; using default behavior.",
getUri().getScheme());
return false;
}
// The full pattern should have a wildcard, otherwise there's no point doing the flat glob.
GlobPattern fullPattern = new GlobPattern(fixedPath.toString());
if (!fullPattern.hasWildcard()) {
LOG.debug(
"Flat glob is on, but Path '{}' has no wildcard; using default behavior.",
fixedPath);
return false;
}
// To use a flat glob, there must be an authority defined.
if (Strings.isNullOrEmpty(fixedPath.toUri().getAuthority())) {
LOG.info(
"Flat glob is on, but Path '{}' has a empty authority, using default behavior.",
fixedPath);
return false;
}
// And the authority must not contain a wildcard.
GlobPattern authorityPattern = new GlobPattern(fixedPath.toUri().getAuthority());
if (authorityPattern.hasWildcard()) {
LOG.info(
"Flat glob is on, but Path '{}' has a wildcard authority, using default behavior.",
fixedPath);
return false;
}
return true;
}
示例6: compile
import org.apache.hadoop.fs.GlobPattern; //导入依赖的package包/类
/**
* Compile glob pattern string
*
* @param globPattern the glob pattern
* @return the pattern object
*/
public static Pattern compile(String globPattern) {
return new GlobPattern(globPattern).compiled();
}