@@ -215,36 +215,35 @@ public void test(Configuration config, ByteBufferAllocator allocator) throws Exc
215215
216216 {
217217 ParquetMetadata footer = ParquetFileReader .readFooter (conf , file , NO_FILTER );
218- ParquetFileReader reader = new ParquetFileReader (
219- config , footer .getFileMetaData (), file , footer .getBlocks (), schema .getColumns ());
220- PageReadStore rowGroup = reader .readNextRowGroup ();
221- PageReader pageReader = rowGroup .getPageReader (col );
222- DataPageV2 page = (DataPageV2 ) pageReader .readPage ();
223- assertEquals (rowCount , page .getRowCount ());
224- assertEquals (nullCount , page .getNullCount ());
225- assertEquals (valueCount , page .getValueCount ());
226- assertEquals (d , intValue (page .getDefinitionLevels ()));
227- assertEquals (r , intValue (page .getRepetitionLevels ()));
228- assertEquals (dataEncoding , page .getDataEncoding ());
229- assertEquals (v , intValue (page .getData ()));
218+ try ( ParquetFileReader reader = new ParquetFileReader (
219+ config , footer .getFileMetaData (), file , footer .getBlocks (), schema .getColumns ())) {
220+ PageReadStore rowGroup = reader .readNextRowGroup ();
221+ PageReader pageReader = rowGroup .getPageReader (col );
222+ DataPageV2 page = (DataPageV2 ) pageReader .readPage ();
223+ assertEquals (rowCount , page .getRowCount ());
224+ assertEquals (nullCount , page .getNullCount ());
225+ assertEquals (valueCount , page .getValueCount ());
226+ assertEquals (d , intValue (page .getDefinitionLevels ()));
227+ assertEquals (r , intValue (page .getRepetitionLevels ()));
228+ assertEquals (dataEncoding , page .getDataEncoding ());
229+ assertEquals (v , intValue (page .getData ()));
230230
231- // Checking column/offset indexes for the one page
232- ColumnChunkMetaData column = footer .getBlocks ().get (0 ).getColumns ().get (0 );
233- ColumnIndex columnIndex = reader .readColumnIndex (column );
234- assertArrayEquals (
235- statistics .getMinBytes (), columnIndex .getMinValues ().get (0 ).array ());
236- assertArrayEquals (
237- statistics .getMaxBytes (), columnIndex .getMaxValues ().get (0 ).array ());
238- assertEquals (
239- statistics .getNumNulls (), columnIndex .getNullCounts ().get (0 ).longValue ());
240- assertFalse (columnIndex .getNullPages ().get (0 ));
241- OffsetIndex offsetIndex = reader .readOffsetIndex (column );
242- assertEquals (1 , offsetIndex .getPageCount ());
243- assertEquals (pageSize , offsetIndex .getCompressedPageSize (0 ));
244- assertEquals (0 , offsetIndex .getFirstRowIndex (0 ));
245- assertEquals (pageOffset , offsetIndex .getOffset (0 ));
246-
247- reader .close ();
231+ // Checking column/offset indexes for the one page
232+ ColumnChunkMetaData column = footer .getBlocks ().get (0 ).getColumns ().get (0 );
233+ ColumnIndex columnIndex = reader .readColumnIndex (column );
234+ assertArrayEquals (
235+ statistics .getMinBytes (), columnIndex .getMinValues ().get (0 ).array ());
236+ assertArrayEquals (
237+ statistics .getMaxBytes (), columnIndex .getMaxValues ().get (0 ).array ());
238+ assertEquals (
239+ statistics .getNumNulls (), columnIndex .getNullCounts ().get (0 ).longValue ());
240+ assertFalse (columnIndex .getNullPages ().get (0 ));
241+ OffsetIndex offsetIndex = reader .readOffsetIndex (column );
242+ assertEquals (1 , offsetIndex .getPageCount ());
243+ assertEquals (pageSize , offsetIndex .getCompressedPageSize (0 ));
244+ assertEquals (0 , offsetIndex .getFirstRowIndex (0 ));
245+ assertEquals (pageOffset , offsetIndex .getOffset (0 ));
246+ }
248247 }
249248 }
250249
0 commit comments