List of usage examples for org.apache.hadoop.fs GlobPattern GlobPattern
public GlobPattern(String globPattern)
From source file:com.google.cloud.hadoop.fs.gcs.GoogleHadoopFileSystemBase.java
License:Open Source License
/** * 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./*from w ww .j a va2 s .c o m*/ */ @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 '{}'; usig 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; }
From source file:com.ibm.stocator.fs.common.ObjectStoreGlobFilter.java
License:Open Source License
void init(String filePattern, PathFilter filter) throws IOException { try {/*from ww w . j ava 2 s . co m*/ userFilter = filter; pattern = new GlobPattern(filePattern); } catch (PatternSyntaxException e) { throw new IOException("Illegal file pattern: " + e.getMessage(), e); } }
From source file:de.tiqsolutions.hdfs.HadoopFileSystem.java
License:Apache License
@Override public PathMatcher getPathMatcher(String syntaxAndPattern) { String syntax = "glob"; String pattern = syntaxAndPattern; String[] sp = syntaxAndPattern.split(":", 2); if (sp.length == 2) { syntax = sp[0];/*from ww w . j a va 2 s . c om*/ pattern = sp[1]; } if (!"glob".equals(syntax)) throw new UnsupportedOperationException(); final GlobPattern globPattern = new GlobPattern(pattern); return new PathMatcher() { @Override public boolean matches(Path path) { return globPattern.matches(path.toString()); } }; }
From source file:org.apache.gobblin.service.modules.dataset.FSDatasetDescriptor.java
License:Apache License
/** * 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./* ww w .j a va2 s.c o m*/ * * @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}. */ protected 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); }
From source file:org.apache.parquet.thrift.projection.deprecated.PathGlobPattern.java
License:Apache License
/** * Compile glob pattern string/*from ww w. j a v a 2s .co m*/ * * @param globPattern the glob pattern * @return the pattern object */ public static Pattern compile(String globPattern) { return new GlobPattern(globPattern).compiled(); }