如何在独立的 Java 代码中读取镶木地板文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28615511/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 06:31:34  来源:igfitidea点击:

how to read a parquet file, in a standalone java code?

javaparquet

提问by teddy teddy

the parquet docs from cloudera shows examples of integration with pig/hive/impala. but in many cases I want to read the parquet file itself for debugging purposes.

cloudera 的 parquet 文档显示了与 pig/hive/impala 集成的示例。但在许多情况下,我想读取镶木地板文件本身以进行调试。

is there a straightforward java reader api to read a parquet file ?

是否有一个简单的 java reader api 来读取 parquet 文件?

Thanks Yang

谢谢杨

回答by kostya

You can use AvroParquetReaderfrom parquet-avro library to read a parquet file as a set of AVRO GenericRecordobjects.

您可以使用AvroParquetReader来自 parquet-avro 库的 Parquet 文件作为一组 AVROGenericRecord对象读取。

回答by rishiehari

Old method: (deprecated)

旧方法:(已弃用)

AvroParquetReader<GenericRecord> reader = new AvroParquetReader<GenericRecord>(file);
GenericRecord nextRecord = reader.read();

New method:

新方法:

ParquetReader<GenericRecord> reader = AvroParquetReader.<GenericRecord>builder(file).build();
GenericRecord nextRecord = reader.read();

I got this from hereand have used this in my test cases successfully.

我从这里得到了这个,并成功地在我的测试用例中使用了它。