/** * Replace a null or empty dataset URN with {@link #DEFAULT_DATASET_URN}, and replaces illegal HDFS * characters with '_'. */ private static String sanitizeDatasetUrn(String datasetUrn) { return Strings.isNullOrEmpty(datasetUrn) ? DEFAULT_DATASET_URN : HadoopUtils.sanitizePath(datasetUrn, "_"); }
/** * Remove illegal HDFS path characters from the given path. Illegal characters will be replaced * with the given substitute. */ public static Path sanitizePath(Path path, String substitute) { return new Path(sanitizePath(path.toString(), substitute)); }
private Path getErrFilePath(RowLevelPolicy policy) { String errFileName = HadoopUtils.sanitizePath(policy.toString(), "-"); if (!Strings.isNullOrEmpty(this.stateId)) { errFileName += "-" + this.stateId; } errFileName += ".err"; return new Path(policy.getErrFileLocation(), errFileName); }
String sanitizedName = HadoopUtils.sanitizePath(field.name(), "_"); String sanitizedValue = HadoopUtils.sanitizePath(record.get(field.name()).toString(), "_"); if (replacePathSeparators) { sanitizedName = sanitizedName.replaceAll(Path.SEPARATOR, "_");
@Test public void testSanitizePath() throws Exception { Assert.assertEquals(HadoopUtils.sanitizePath("/A:B/::C:::D\\", "abc"), "/AabcB/abcabcCabcabcabcDabc"); Assert.assertEquals(HadoopUtils.sanitizePath(":\\:\\/", ""), "/"); try { HadoopUtils.sanitizePath("/A:B/::C:::D\\", "a:b"); throw new RuntimeException(); } catch (RuntimeException e) { Assert.assertTrue(e.getMessage().contains("substitute contains illegal characters")); } }
/** * Replace a null or empty dataset URN with {@link #DEFAULT_DATASET_URN}, and replaces illegal HDFS * characters with '_'. */ private static String sanitizeDatasetUrn(String datasetUrn) { return Strings.isNullOrEmpty(datasetUrn) ? DEFAULT_DATASET_URN : HadoopUtils.sanitizePath(datasetUrn, "_"); }
/** * Remove illegal HDFS path characters from the given path. Illegal characters will be replaced * with the given substitute. */ public static Path sanitizePath(Path path, String substitute) { return new Path(sanitizePath(path.toString(), substitute)); }
private Path getErrFilePath(RowLevelPolicy policy) { String errFileName = HadoopUtils.sanitizePath(policy.toString(), "-"); if (!Strings.isNullOrEmpty(this.stateId)) { errFileName += "-" + this.stateId; } errFileName += ".err"; return new Path(policy.getErrFileLocation(), errFileName); }
String sanitizedName = HadoopUtils.sanitizePath(field.name(), "_"); String sanitizedValue = HadoopUtils.sanitizePath(record.get(field.name()).toString(), "_"); if (replacePathSeparators) { sanitizedName = sanitizedName.replaceAll(Path.SEPARATOR, "_");