apache / apache/parquet-java

ParquetWriter.getDataSize NullPointerException after closed

Aperta
#2,037 6 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Component: Java Component: Parquet Priority: Major Type: bug
Lingua principale
Java
Stelle
3.1k
Fork
1.6k
Merge medio
3g 12h
PR unite (30g)
33

Descrizione

When I run `ParquetWriter.getDataSize()`, it works normally. But after I call `ParquetWriter.close()`, subsequent calls to ParquetWriter.getDataSize result in a NullPointerException.

```
java.lang.NullPointerException
at org.apache.parquet.hadoop.InternalParquetRecordWriter.getDataSize(InternalParquetRecordWriter.java:132)
at org.apache.parquet.hadoop.ParquetWriter.getDataSize(ParquetWriter.java:314)
at FileBufferState.getFileSizeInBytes(FileBufferState.scala:83)
```

The reason for the NPE appears to be in `InternalParquetRecordWriter.getDataSize`, where it assumes that `columnStore` is not null.

But the `close()` method calls `flushRowGroupToStore()` which sets `columnStore = null`.

I'm guessing that once the file is closed, we can just return `lastRowGroupEndPos` since there should be no more buffered data, but I don't fully understand how this class works.

**Environment**: Linux prim 4.8.13-1-ARCH #1 SMP PREEMPT Fri Dec 9 07:24:34 CET 2016 x86_64 GNU/Linux

openjdk version "1.8.0_112"
OpenJDK Runtime Environment (build 1.8.0_112-b15)
OpenJDK 64-Bit Server VM (build 25.112-b15, mixed mode)

**Reporter**: [Mike Mintz](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=mikemintz)
#### Related issues:
- [Add accessor to ParquetWriter to get current data size](https://github.com/apache/parquet-java/issues/1833) (relates to)

**Note**: *This issue was originally created as [PARQUET-860](https://issues.apache.org/jira/browse/PARQUET-860). Please see the [migration documentation](https://issues.apache.org/jira/browse/PARQUET-2502) for further details.*

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Start with InternalParquetRecordWriter.getDataSize() and the close path through ParquetWriter.close(), focusing on how columnStore and lastRowGroupEndPos change when the writer is closed. Reproduce the post-close call described in the issue and inspect existing writer tests for suitable regression coverage. Done means getDataSize() no longer throws a NullPointerException after close and returns the intended size.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java
Ambito
data-engineering
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.