Out of Memory when reading large parquet file
- 主要言語
- Java
- スター
- 3.1k
- フォーク
- 1.6k
- 平均マージ
- 3日 12時間
- マージ済み PR(30日)
- 33
説明
Hi,
We are successfully reading parquet files block by block, and are running into a JVM out of memory issue in a certain edge case. Consider the following scenario:
Parquet file has one column and one block and is 10 GB
Our JVM is 5 GB
Is there any way to read such a file? Below is our implementation/stack trace
```java
Caused by: java.lang.OutOfMemoryError: Java heap space
at org.apache.parquet.hadoop.ParquetFileReader$ConsecutiveChunkList.readAll(ParquetFileReader.java:778)
at org.apache.parquet.hadoop.ParquetFileReader.readNextRowGroup(ParquetFileReader.java:511)
try {
ParquetMetadata readFooter = ParquetFileReader.readFooter(hfsConfig, path,
ParquetMetadataConverter.NO_FILTER);
MessageType schema = readFooter.getFileMetaData().getSchema();
long a = readFooter.getBlocks().stream().
reduce(0L, (left, right) -> left >
right.getTotalByteSize() ? left : right.getTotalByteSize(),
(leftl, rightl) -> leftl > rightl ? leftl : rightl);
for (BlockMetaData block : readFooter.getBlocks()) {
try {
fileReader = new ParquetFileReader(hfsConfig,
readFooter.getFileMetaData(), path, Collections
.singletonList(block), schema.getColumns());
PageReadStore pages;
while (null != (pages = fileReader.readNextRowGroup())) {
//exception gets thrown here on blocks larger than jvm memory
final long rows = pages.getRowCount();
final MessageColumnIO columnIO = new
ColumnIOFactory().getColumnIO(schema);
final RecordReader recordReader =
columnIO.getRecordReader(pages, new GroupRecordConverter(schema));
for (int i = 0; i < rows; i++) {
final Group group = recordReader.read();
int fieldCount = group.getType().getFieldCount();
for (int field = 0; field < fieldCount; field++) {
int valueCount = group.getFieldRepetitionCount(field);
Type fieldType = group.getType().getType(field);
String fieldName = fieldType.getName();
for (int index = 0; index < valueCount; index++) {
// Process data
}
}
}
}
} catch (IOException e) {
...
} finally {
...
}
}
```
**Reporter**: [Ryan Sachs](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=sachsry)
**Note**: *This issue was originally created as [PARQUET-1359](https://issues.apache.org/jira/browse/PARQUET-1359). Please see the [migration documentation](https://issues.apache.org/jira/browse/PARQUET-2502) for further details.*
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
まず、5 GB の JVM で 1 列・10 GB の Parquet 読み取りを再現し、スタックトレースに示されている箇所である ParquetFileReader.readNextRowGroup から ConsecutiveChunkList.readAll までを追跡します。reader がヒープより大きい row group を処理することを想定されているかどうかを確認し、報告された out-of-memory failure を回避する、文書化またはテストされた動作を完了条件とします。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- java
- 領域
- data-engineering
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100