|
22 | 22 | import static org.apache.parquet.hadoop.ParquetFileWriter.EFMAGIC; |
23 | 23 | import static org.apache.parquet.hadoop.ParquetFileWriter.MAGIC; |
24 | 24 |
|
| 25 | +import com.fasterxml.jackson.core.JsonGenerator; |
25 | 26 | import com.fasterxml.jackson.core.JsonProcessingException; |
| 27 | +import com.fasterxml.jackson.databind.JsonSerializer; |
26 | 28 | import com.fasterxml.jackson.databind.ObjectMapper; |
27 | 29 | import com.fasterxml.jackson.databind.SerializationFeature; |
| 30 | +import com.fasterxml.jackson.databind.SerializerProvider; |
| 31 | +import com.fasterxml.jackson.databind.module.SimpleModule; |
| 32 | +import com.fasterxml.jackson.databind.module.SimpleSerializers; |
28 | 33 | import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; |
29 | 34 | import java.io.IOException; |
30 | 35 | import java.io.InputStream; |
|
34 | 39 | import org.apache.parquet.format.FileMetaData; |
35 | 40 | import org.apache.parquet.format.Util; |
36 | 41 | import org.apache.parquet.io.SeekableInputStream; |
| 42 | +import org.apache.parquet.schema.LogicalTypeAnnotation; |
37 | 43 |
|
38 | 44 | public class RawUtils { |
39 | 45 |
|
@@ -79,6 +85,27 @@ public static ObjectMapper createObjectMapper() { |
79 | 85 | mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); |
80 | 86 | mapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true); |
81 | 87 | mapper.registerModule(new JavaTimeModule()); |
| 88 | + mapper.registerModule(new ParquetModule()); |
82 | 89 | return mapper; |
83 | 90 | } |
| 91 | + |
| 92 | + static class ParquetModule extends SimpleModule { |
| 93 | + |
| 94 | + @Override |
| 95 | + public void setupModule(SetupContext context) { |
| 96 | + super.setupModule(context); |
| 97 | + SimpleSerializers sers = new SimpleSerializers(); |
| 98 | + sers.addSerializer(LogicalTypeAnnotation.class, new LogicalTypeAnnotationJsonSerializer()); |
| 99 | + context.addSerializers(sers); |
| 100 | + } |
| 101 | + } |
| 102 | + |
| 103 | + static class LogicalTypeAnnotationJsonSerializer extends JsonSerializer<LogicalTypeAnnotation> { |
| 104 | + |
| 105 | + @Override |
| 106 | + public void serialize(LogicalTypeAnnotation value, JsonGenerator gen, SerializerProvider serializers) |
| 107 | + throws IOException { |
| 108 | + gen.writeString(value.toString()); |
| 109 | + } |
| 110 | + } |
84 | 111 | } |
0 commit comments