读取镶木地板文件正在工作,但使用缩进格式而不是所需的 JSON 输出格式。有任何想法吗?我在想我可能需要更改 GroupRecordConverter 但找不到太多文档。如果可以指出我,也会有所帮助。非常感谢您的帮助。long num = numLines;try { ParquetMetadata readFooter = ParquetFileReader.readFooter(conf, path, ParquetMetadataConverter.NO_FILTER); MessageType schema = readFooter.getFileMetaData().getSchema(); ParquetFileReader r = new ParquetFileReader(conf,path,readFooter); PageReadStore pages = null; try{ while(null != (pages = r.readNextRowGroup())) { final long rows = pages.getRowCount(); System.out.println("Number of rows: " + rows); final MessageColumnIO columnIO = new ColumnIOFactory().getColumnIO(schema); final RecordReader recordReader = columnIO.getRecordReader(pages, new GroupRecordConverter(schema)); String sTemp = ""; for(int i=0; i<rows && num-->0; i++) { System.out.println(recordReader.read().toString()) } } }}当前缩进输出:data1: value1data2: value2models map key: data3 value array: value3 map key: data4 value array: value4data5: value5...所需的 JSON 输出:"data1": "value1","data2": "value2","models": { "data3": [ "value3" ], "data4": [ "value4" ]},"data5": "value5"...
2 回答
繁星淼淼
TA贡献1775条经验 获得超11个赞
我修改了 SimpleRecord toJsonObject 方法的源码
protected Object toJsonObject() {
Map<String, Object> result = Maps.newLinkedHashMap();
if (arrayElement()) {
return handleArrayElement(result);
}
for (NameValue value : values) {
result.put(value.getName(), toJsonValue(value.getValue()));
}
return result;
}
添加回答
举报
0/150
提交
取消