/** * Compile glob pattern string * @param globPattern the glob pattern * @return the pattern object */ public static Pattern compile(String globPattern) { return new GlobPattern(globPattern).compiled(); }
/** * A helper to determine if the path description of this {@link DatasetDescriptor} is a superset of paths * accepted by the other {@link DatasetDescriptor}. If the path description of the other {@link DatasetDescriptor} * is a glob pattern, we return false. * * @param otherPath a glob pattern that describes a set of paths. * @return true if the glob pattern described by the otherPath matches the path in this {@link DatasetDescriptor}. */ private boolean isPathContaining(String otherPath) { if (otherPath == null) { return false; } if (DatasetDescriptorConfigKeys.DATASET_DESCRIPTOR_CONFIG_ANY.equals(this.getPath())) { return true; } if (PathUtils.isGlob(new Path(otherPath))) { return false; } GlobPattern globPattern = new GlobPattern(this.getPath()); return globPattern.matches(otherPath); }
@Override protected Pattern compile(String s) { return GlobPattern.compile(s); } }
void init(String filePattern, PathFilter filter) throws IOException { try { userFilter = filter; pattern = new GlobPattern(filePattern); } catch (PatternSyntaxException e) { // Existing code expects IOException startWith("Illegal file pattern") throw new IOException("Illegal file pattern: "+ e.getMessage(), e); } }
@Override public boolean accept(Path path) { return pattern.matches(path.getName()) && userFilter.accept(path); } }
GlobPattern pathGlob = new GlobPattern((new Path(root, name)).toString()); if (pathGlob.hasWildcard()) { String patternAppliedName = name + DotDrillType.getDrillFileGlobPattern(types); FileStatus[] status = fs.globStatus(new Path(root, patternAppliedName));
public boolean hasPattern() { return pattern.hasWildcard(); }
/** * Construct the glob pattern object with a glob pattern string * @param globPattern the glob pattern string */ public GlobPattern(String globPattern) { set(globPattern); }
@Override public void prepare() throws IOException { String argPattern = getArgument(1); if (!caseSensitive) { argPattern = StringUtils.toLowerCase(argPattern); } globPattern = new GlobPattern(argPattern); }
@Override public Result apply(PathData item, int depth) throws IOException { String name = getPath(item).getName(); if (!caseSensitive) { name = StringUtils.toLowerCase(name); } if (globPattern.matches(name)) { return Result.PASS; } else { return Result.FAIL; } }
GlobPattern fullPattern = new GlobPattern(fixedPath.toString()); if (!fullPattern.hasWildcard()) { logger.atFine().log( "Flat glob is on, but Path '%s' has no wildcard; using default behavior.", fixedPath); GlobPattern authorityPattern = new GlobPattern(fixedPath.toUri().getAuthority()); if (authorityPattern.hasWildcard()) { logger.atInfo().log( "Flat glob is on, but Path '%s' has a wildcard authority, using default behavior.",
boolean hasPattern() { return pattern.hasWildcard(); }
/** * Construct the glob pattern object with a glob pattern string * @param globPattern the glob pattern string */ public GlobPattern(String globPattern) { set(globPattern); }
/** * Compile glob pattern string * @param globPattern the glob pattern * @return the pattern object */ public static Pattern compile(String globPattern) { return new GlobPattern(globPattern).compiled(); }
private void assertMatch(boolean yes, String glob, String...input) { GlobPattern pattern = new GlobPattern(glob); for (String s : input) { boolean result = pattern.matches(s); assertTrue(glob +" should"+ (yes ? "" : " not") +" match "+ s, yes ? result : !result); } }
void init(String filePattern, PathFilter filter) throws IOException { try { userFilter = filter; pattern = new GlobPattern(filePattern); } catch (PatternSyntaxException e) { // Existing code expects IOException startWith("Illegal file pattern") throw new IOException("Illegal file pattern: "+ e.getMessage(), e); } }
public ConfigurableGlobDatasetFinder(FileSystem fs, Properties jobProps, Config config) { for (String property : requiredProperties()) { Preconditions.checkArgument(config.hasPath(property) || config.hasPath(DEPRECATIONS.get(property)), String.format("Missing required property %s", property)); } if (ConfigUtils.hasNonEmptyPath(config, DATASET_BLACKLIST_KEY)) { this.blacklist = Optional.of(Pattern.compile(config.getString(DATASET_BLACKLIST_KEY))); } else if (ConfigUtils.hasNonEmptyPath(config, DATASET_FINDER_BLACKLIST_KEY)) { this.blacklist = Optional.of(Pattern.compile(config.getString(DATASET_FINDER_BLACKLIST_KEY))); } else { this.blacklist = Optional.absent(); } if (ConfigUtils.hasNonEmptyPath(config, DATASET_FINDER_GLOB_BLACKLIST_KEY)) { this.globPatternBlacklist = Optional.of(GlobPattern.compile(config.getString(DATASET_FINDER_GLOB_BLACKLIST_KEY))); } else { this.globPatternBlacklist = Optional.absent(); } this.fs = fs; Path tmpDatasetPattern; if (config.hasPath(DATASET_FINDER_PATTERN_KEY)) { tmpDatasetPattern = new Path(config.getString(DATASET_FINDER_PATTERN_KEY)); } else { tmpDatasetPattern = new Path(config.getString(DATASET_PATTERN_KEY)); } this.datasetPattern = tmpDatasetPattern.isAbsolute() ? tmpDatasetPattern : new Path(this.fs.getWorkingDirectory(), tmpDatasetPattern); this.commonRoot = PathUtils.deepestNonGlobPath(this.datasetPattern); this.props = jobProps; }
@Override public boolean accept(Path path) { return pattern.matches(path.getName()) && userFilter.accept(path); } }