use of org.apache.drill.exec.store.parquet.metadata.Metadata_V4.ColumnMetadata_v4 in project drill by apache.
the class Metadata method writeFile.
/**
* Serialize parquet metadata to json and write to a file.
*
* @param parquetMetadata parquet table or directory metadata
* @param p file path
* @param fs Drill file system
* @throws IOException if metadata can't be serialized
*/
private void writeFile(Object parquetMetadata, Path p, FileSystem fs) throws IOException {
JsonFactory jsonFactory = new JsonFactory();
jsonFactory.configure(Feature.AUTO_CLOSE_TARGET, false);
jsonFactory.configure(JsonParser.Feature.AUTO_CLOSE_SOURCE, false);
ObjectMapper mapper = new ObjectMapper(jsonFactory);
SimpleModule module = new SimpleModule();
module.addSerializer(Path.class, new PathSerDe.Se());
if (parquetMetadata instanceof Metadata_V4.FileMetadata) {
module.addSerializer(ColumnMetadata_v4.class, new ColumnMetadata_v4.Serializer());
}
mapper.registerModule(module);
OutputStream os = fs.create(p);
mapper.writerWithDefaultPrettyPrinter().writeValue(os, parquetMetadata);
os.flush();
os.close();
}
Aggregations