Github user paul-rogers commented on a diff in the pull request: https://github.com/apache/drill/pull/824#discussion_r115105413 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/Metadata.java --- @@ -526,6 +534,48 @@ private void writeFile(ParquetTableMetadataDirs parquetTableMetadataDirs, Path p } /** + * Serializer for ParquetPath. Writes the path relative to the root path + */ + private static class ParquetPathSerializer extends StdSerializer<ParquetPath> { + private final String rootPath; + + ParquetPathSerializer(String rootPath) { + super(ParquetPath.class); + this.rootPath = rootPath; + } + + @Override + public void serialize(ParquetPath parquetPath, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException, JsonGenerationException { + Preconditions.checkState(parquetPath.getFullPath().startsWith(rootPath), String.format("Path %s is not a subpath of %s", parquetPath.getFullPath(), rootPath)); + String relativePath = parquetPath.getFullPath().replaceFirst(rootPath, ""); --- End diff -- Java defines a Path abstraction that will compute relative paths. An [old fashioned way](http://stackoverflow.com/questions/204784/how-to-construct-a-relative-path-in-java-from-two-absolute-paths-or-urls): ``` String relative = new File(base).toURI().relativize(new File(path).toURI()).getPath(); ``` From the same post, the Java 7 way: ``` Path pathAbsolute = Paths.get("/var/data/stuff/xyz.dat"); Path pathBase = Paths.get("/var/data"); Path pathRelative = pathBase.relativize(pathAbsolute); ``` Hadoop's path may have something similar.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---