public static Pair<URIPattern, Map<String, String>> lookupDatasetPattern(URI uri) { for (URIPattern pattern : DATASET_PATTERNS.keySet()) { Map<String, String> match = pattern.getMatch(uri); if (match != null) { return Pair.of(pattern, match); } } throw new IllegalArgumentException("Unknown dataset URI pattern: dataset:" + uri); }
public static Pair<URIPattern, Map<String, String>> lookupPatternByRepoUri(URI uri) { for (URIPattern pattern : REPO_TO_DATASET_PATTERNS.keySet()) { Map<String, String> match = pattern.getMatch(uri); if (match != null) { URIPattern datasetPattern = REPO_TO_DATASET_PATTERNS.get(pattern); return Pair.of(datasetPattern, match); } } throw new IllegalArgumentException("Unknown repository URI pattern: dataset:" + uri); }
public static TimeDomain get(PartitionStrategy strategy, String source) { return domains.getUnchecked(Pair.of(strategy, source)); }
public static Pair<DatasetRepository, Map<String, String>> lookupRepoUri(URI repoUri) { for (URIPattern pattern : REPO_PATTERNS.keySet()) { Map<String, String> match = pattern.getMatch(repoUri); if (match != null) { return Pair.of(REPO_PATTERNS.get(pattern).getFromOptions(match), match); } } throw new IllegalArgumentException("Unknown repository URI pattern: repo:" + repoUri); }
static List<Pair<Path, Path>> stageMove(FileSystem fs, Path src, Path dest, String ext) { List<Pair<Path, Path>> staged; try { // make sure the destination exists if (!fs.exists(dest)) { fs.mkdirs(dest); } FileStatus[] stats = fs.listStatus(src); staged = Lists.newArrayList(); for (FileStatus stat : stats) { if (stat.isDir()) { continue; } Path srcFile = stat.getPath(); Path dotFile = new Path(dest, "." + srcFile.getName() + "." + ext); Path destFile = new Path(dest, srcFile.getName()); if (fs.rename(srcFile, dotFile)) { staged.add(Pair.of(dotFile, destFile)); } else { throw new IOException( "Failed to rename " + srcFile + " to " + dotFile); } } } catch (IOException e) { throw new DatasetIOException( "Could not move contents of " + src + " to " + dest, e); } return staged; }
public static Pair<DatasetRepository, Map<String, String>> lookupDatasetUri(URI datasetUri) { String scheme = datasetUri.getScheme(); List<String> schemeMatches = Lists.newArrayList(); for (URIPattern pattern : DATASET_PATTERNS.keySet()) { Map<String, String> match = pattern.getMatch(datasetUri); if (match != null) { return Pair.of(DATASET_PATTERNS.get(pattern).getFromOptions(match), match); } else if (pattern.getScheme() != null && pattern.getScheme().equals(scheme)) { schemeMatches.add(pattern.getPatternString()); } } String message = "Unknown dataset URI pattern: dataset:" + datasetUri; if (schemeMatches.isEmpty()) { // no known patterns for the scheme, maybe jars are missing message += "\nCheck that JARs for " + scheme + " datasets are on the classpath"; } else { // show the known patterns in case it's a simple error message += "\nKnown patterns for " + scheme + ":\n dataset:" + Joiner.on("\n dataset:").join(schemeMatches); } throw new DatasetNotFoundException(message); }
current = addProjected(projected, fp.getName(), current); } else if (projected instanceof Range) { compatible.add(Pair.of(fp.getName(), (Range) projected));