Package org.apache.parquet.hadoop
Class ParquetFileReader
java.lang.Object
org.apache.parquet.hadoop.ParquetFileReader
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
CompressionConverter.TransParquetFileReader
Internal implementation of the Parquet file reader as a block container
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.apache.parquet.io.SeekableInputStreamstatic final longstatic final String -
Constructor Summary
ConstructorsConstructorDescriptionParquetFileReader(org.apache.hadoop.conf.Configuration configuration, org.apache.hadoop.fs.Path filePath, List<BlockMetaData> blocks, List<org.apache.parquet.column.ColumnDescriptor> columns) Deprecated.will be removed in 2.0.0.ParquetFileReader(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path file, ParquetMetadataConverter.MetadataFilter filter) Deprecated.will be removed in 2.0.0.ParquetFileReader(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path file, ParquetMetadata footer) Deprecated.will be removed in 2.0.0.ParquetFileReader(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path file, ParquetMetadata footer, ParquetReadOptions options) ParquetFileReader(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path file, ParquetMetadata footer, ParquetReadOptions options, org.apache.parquet.io.SeekableInputStream f) ParquetFileReader(org.apache.hadoop.conf.Configuration configuration, FileMetaData fileMetaData, org.apache.hadoop.fs.Path filePath, List<BlockMetaData> blocks, List<org.apache.parquet.column.ColumnDescriptor> columns) Deprecated.will be removed in 2.0.0.ParquetFileReader(org.apache.parquet.io.InputFile file, ParquetMetadata footer, ParquetReadOptions options, org.apache.parquet.io.SeekableInputStream f) ParquetFileReader(org.apache.parquet.io.InputFile file, ParquetReadOptions options) ParquetFileReader(org.apache.parquet.io.InputFile file, ParquetReadOptions options, org.apache.parquet.io.SeekableInputStream f) -
Method Summary
Modifier and TypeMethodDescriptionvoidappendTo(ParquetFileWriter writer) voidclose()voidExplicitly detach the the input stream for the file to avoid being closed viaclose().getBloomFilterDataReader(int blockIndex) org.apache.parquet.internal.filter2.columnindex.ColumnIndexStoregetColumnIndexStore(int blockIndex) intReturns the 0-based index of the row group that was last read viareadNextRowGroup()orreadNextFilteredRowGroup().org.apache.parquet.hadoop.DictionaryPageReadergetDictionaryReader(int blockIndex) org.apache.parquet.hadoop.DictionaryPageReadergetDictionaryReader(BlockMetaData block) getFile()longorg.apache.parquet.column.page.DictionaryPageReadStoreReturns aDictionaryPageReadStorefor the row group that would be returned by callingreadNextRowGroup()or skipped by callingskipNextRowGroup().org.apache.hadoop.fs.PathgetPath()Deprecated.will be removed in 2.0.0; usegetFile()insteadlongorg.apache.parquet.filter2.columnindex.RowRangesgetRowRanges(int blockIndex) Computes theRowRangeswithin the given row group that may pass the configured filter (set viaParquetReadOptionsorParquetInputFormat.setFilterPredicate(org.apache.hadoop.conf.Configuration, org.apache.parquet.filter2.predicate.FilterPredicate)).static ParquetFileReaderopen(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path file) Deprecated.will be removed in 2.0.0; useopen(InputFile)static ParquetFileReaderopen(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path file, ParquetMetadataConverter.MetadataFilter filter) Deprecated.will be removed in 2.0.0; useopen(InputFile, ParquetReadOptions)static ParquetFileReaderopen(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path file, ParquetMetadata footer) Deprecated.will be removed in 2.0.0static ParquetFileReaderopen(org.apache.parquet.io.InputFile file) Open afile.static ParquetFileReaderopen(org.apache.parquet.io.InputFile file, ParquetMetadata footer, ParquetReadOptions options, org.apache.parquet.io.SeekableInputStream f) static ParquetFileReaderopen(org.apache.parquet.io.InputFile file, ParquetReadOptions options) Open afilewithoptions.static ParquetFileReaderopen(org.apache.parquet.io.InputFile file, ParquetReadOptions options, org.apache.parquet.io.SeekableInputStream f) Open afilewithoptions.readAllFootersInParallel(org.apache.hadoop.conf.Configuration configuration, List<org.apache.hadoop.fs.FileStatus> partFiles) Deprecated.metadata files are not recommended and will be removed in 2.0.0readAllFootersInParallel(org.apache.hadoop.conf.Configuration configuration, List<org.apache.hadoop.fs.FileStatus> partFiles, boolean skipRowGroups) Deprecated.will be removed in 2.0.0; useopen(InputFile, ParquetReadOptions)readAllFootersInParallel(org.apache.hadoop.conf.Configuration configuration, org.apache.hadoop.fs.FileStatus fileStatus) Deprecated.will be removed in 2.0.0; useopen(InputFile, ParquetReadOptions)readAllFootersInParallel(org.apache.hadoop.conf.Configuration configuration, org.apache.hadoop.fs.FileStatus fileStatus, boolean skipRowGroups) Deprecated.will be removed in 2.0.0; useopen(InputFile, ParquetReadOptions)readAllFootersInParallelUsingSummaryFiles(org.apache.hadoop.conf.Configuration configuration, Collection<org.apache.hadoop.fs.FileStatus> partFiles, boolean skipRowGroups) Deprecated.metadata files are not recommended and will be removed in 2.0.0readAllFootersInParallelUsingSummaryFiles(org.apache.hadoop.conf.Configuration configuration, List<org.apache.hadoop.fs.FileStatus> partFiles) Deprecated.metadata files are not recommended and will be removed in 2.0.0org.apache.parquet.column.values.bloomfilter.BloomFilterReads Bloom filter data for the given column chunk.org.apache.parquet.internal.column.columnindex.ColumnIndexreadColumnIndex(ColumnChunkMetaData column) Class should be considered privateorg.apache.parquet.column.page.PageReadStorereadFilteredRowGroup(int blockIndex) Reads all the columns requested from the specified row group.org.apache.parquet.hadoop.ColumnChunkPageReadStorereadFilteredRowGroup(int blockIndex, org.apache.parquet.filter2.columnindex.RowRanges rowRanges) Reads all the columns requested from the specified row group.org.apache.parquet.hadoop.ColumnChunkPageReadStorereadFilteredRowGroup(int blockIndex, org.apache.parquet.internal.filter2.columnindex.RowRanges rowRanges) Deprecated.usereadFilteredRowGroup(int, RowRanges)withRowRangesinstead.static final ParquetMetadatareadFooter(org.apache.hadoop.conf.Configuration configuration, org.apache.hadoop.fs.FileStatus file) Deprecated.will be removed in 2.0.0; useopen(InputFile, ParquetReadOptions)static final ParquetMetadatareadFooter(org.apache.hadoop.conf.Configuration configuration, org.apache.hadoop.fs.FileStatus file, ParquetMetadataConverter.MetadataFilter filter) Deprecated.will be removed in 2.0.0; useopen(InputFile, ParquetReadOptions)static final ParquetMetadatareadFooter(org.apache.hadoop.conf.Configuration configuration, org.apache.hadoop.fs.Path file) Deprecated.will be removed in 2.0.0; useopen(InputFile, ParquetReadOptions)static ParquetMetadatareadFooter(org.apache.hadoop.conf.Configuration configuration, org.apache.hadoop.fs.Path file, ParquetMetadataConverter.MetadataFilter filter) Deprecated.will be removed in 2.0.0; useopen(InputFile, ParquetReadOptions)static final ParquetMetadatareadFooter(org.apache.parquet.io.InputFile file, ParquetMetadataConverter.MetadataFilter filter) Deprecated.will be removed in 2.0.0; useopen(InputFile, ParquetReadOptions)static final ParquetMetadatareadFooter(org.apache.parquet.io.InputFile file, ParquetReadOptions options, org.apache.parquet.io.SeekableInputStream f) readFooters(org.apache.hadoop.conf.Configuration configuration, org.apache.hadoop.fs.FileStatus pathStatus) Deprecated.will be removed in 2.0.0; useopen(InputFile, ParquetReadOptions)readFooters(org.apache.hadoop.conf.Configuration configuration, org.apache.hadoop.fs.FileStatus pathStatus, boolean skipRowGroups) Deprecated.will be removed in 2.0.0; useopen(InputFile, ParquetReadOptions)readFooters(org.apache.hadoop.conf.Configuration configuration, org.apache.hadoop.fs.Path path) Deprecated.will be removed in 2.0.0; useopen(InputFile, ParquetReadOptions)org.apache.parquet.column.page.PageReadStoreReads all the columns requested from the row group at the current file position.org.apache.parquet.column.page.PageReadStoreReads all the columns requested from the row group at the current file position.org.apache.parquet.internal.column.columnindex.OffsetIndexreadOffsetIndex(ColumnChunkMetaData column) Class should be considered privateorg.apache.parquet.column.page.PageReadStorereadRowGroup(int blockIndex) Reads all the columns requested from the row group at the specified block.readSummaryFile(org.apache.hadoop.conf.Configuration configuration, org.apache.hadoop.fs.FileStatus summaryStatus) Deprecated.metadata files are not recommended and will be removed in 2.0.0voidsetRequestedSchema(List<org.apache.parquet.column.ColumnDescriptor> columns) voidsetRequestedSchema(org.apache.parquet.schema.MessageType projection) boolean
-
Field Details
-
PARQUET_READ_PARALLELISM
- See Also:
-
HADOOP_VECTORED_READ_TIMEOUT_SECONDS
public static final long HADOOP_VECTORED_READ_TIMEOUT_SECONDS- See Also:
-
f
protected org.apache.parquet.io.SeekableInputStream f
-
-
Constructor Details
-
ParquetFileReader
@Deprecated public ParquetFileReader(org.apache.hadoop.conf.Configuration configuration, org.apache.hadoop.fs.Path filePath, List<BlockMetaData> blocks, List<org.apache.parquet.column.ColumnDescriptor> columns) throws IOException Deprecated.will be removed in 2.0.0.- Parameters:
configuration- the Hadoop conffilePath- Path for the parquet fileblocks- the blocks to readcolumns- the columns to read (their path)- Throws:
IOException- if the file can not be opened
-
ParquetFileReader
@Deprecated public ParquetFileReader(org.apache.hadoop.conf.Configuration configuration, FileMetaData fileMetaData, org.apache.hadoop.fs.Path filePath, List<BlockMetaData> blocks, List<org.apache.parquet.column.ColumnDescriptor> columns) throws IOException Deprecated.will be removed in 2.0.0.- Parameters:
configuration- the Hadoop conffileMetaData- fileMetaData for parquet filefilePath- Path for the parquet fileblocks- the blocks to readcolumns- the columns to read (their path)- Throws:
IOException- if the file can not be opened
-
ParquetFileReader
@Deprecated public ParquetFileReader(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path file, ParquetMetadataConverter.MetadataFilter filter) throws IOException Deprecated.will be removed in 2.0.0.- Parameters:
conf- the Hadoop Configurationfile- Path to a parquet filefilter- aParquetMetadataConverter.MetadataFilterfor selecting row groups- Throws:
IOException- if the file can not be opened
-
ParquetFileReader
@Deprecated public ParquetFileReader(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path file, ParquetMetadata footer) throws IOException Deprecated.will be removed in 2.0.0.- Parameters:
conf- the Hadoop Configurationfile- Path to a parquet filefooter- aParquetMetadatafooter already read from the file- Throws:
IOException- if the file can not be opened
-
ParquetFileReader
public ParquetFileReader(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path file, ParquetMetadata footer, ParquetReadOptions options) throws IOException - Parameters:
conf- the Hadoop Configurationfile- Path to a parquet filefooter- aParquetMetadatafooter already read from the fileoptions-ParquetReadOptions- Throws:
IOException- if the file can not be opened
-
ParquetFileReader
public ParquetFileReader(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path file, ParquetMetadata footer, ParquetReadOptions options, org.apache.parquet.io.SeekableInputStream f) throws IOException - Parameters:
conf- the Hadoop Configurationfile- Path to a parquet filefooter- aParquetMetadatafooter already read from the fileoptions-ParquetReadOptionsf- aSeekableInputStreamfor the parquet file- Throws:
IOException- if the file can not be opened
-
ParquetFileReader
public ParquetFileReader(org.apache.parquet.io.InputFile file, ParquetReadOptions options) throws IOException - Throws:
IOException
-
ParquetFileReader
public ParquetFileReader(org.apache.parquet.io.InputFile file, ParquetReadOptions options, org.apache.parquet.io.SeekableInputStream f) throws IOException - Parameters:
file- Path to a parquet fileoptions-ParquetReadOptionsf- aSeekableInputStreamfor the parquet file- Throws:
IOException- if the file can not be opened
-
ParquetFileReader
public ParquetFileReader(org.apache.parquet.io.InputFile file, ParquetMetadata footer, ParquetReadOptions options, org.apache.parquet.io.SeekableInputStream f) throws IOException - Parameters:
file- Path to a parquet filefooter- aParquetMetadatafooter already read from the fileoptions-ParquetReadOptionsf- aSeekableInputStreamfor the parquet file- Throws:
IOException- if the file can not be opened
-
-
Method Details
-
readSummaryFile
@Deprecated public static List<Footer> readSummaryFile(org.apache.hadoop.conf.Configuration configuration, org.apache.hadoop.fs.FileStatus summaryStatus) throws IOException Deprecated.metadata files are not recommended and will be removed in 2.0.0Specifically reads a given summary file- Parameters:
configuration- a configurationsummaryStatus- file status for a summary file- Returns:
- the metadata translated for each file
- Throws:
IOException- if an exception is thrown while reading the summary file
-
open
@Deprecated public static ParquetFileReader open(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path file) throws IOException Deprecated.will be removed in 2.0.0; useopen(InputFile)- Parameters:
conf- a configurationfile- a file path to open- Returns:
- a parquet file reader
- Throws:
IOException- if there is an error while opening the file
-
open
@Deprecated public static ParquetFileReader open(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path file, ParquetMetadataConverter.MetadataFilter filter) throws IOException Deprecated.will be removed in 2.0.0; useopen(InputFile, ParquetReadOptions)- Parameters:
conf- a configurationfile- a file path to openfilter- a metadata filter- Returns:
- a parquet file reader
- Throws:
IOException- if there is an error while opening the file
-
open
@Deprecated public static ParquetFileReader open(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path file, ParquetMetadata footer) throws IOException Deprecated.will be removed in 2.0.0- Parameters:
conf- a configurationfile- a file path to openfooter- a footer for the file if already loaded- Returns:
- a parquet file reader
- Throws:
IOException- if there is an error while opening the file
-
open
Open afile.- Parameters:
file- an input file- Returns:
- an open ParquetFileReader
- Throws:
IOException- if there is an error while opening the file
-
open
public static ParquetFileReader open(org.apache.parquet.io.InputFile file, ParquetReadOptions options) throws IOException Open afilewithoptions.- Parameters:
file- an input fileoptions- parquet read options- Returns:
- an open ParquetFileReader
- Throws:
IOException- if there is an error while opening the file
-
open
public static ParquetFileReader open(org.apache.parquet.io.InputFile file, ParquetReadOptions options, org.apache.parquet.io.SeekableInputStream f) throws IOException Open afilewithoptions.- Parameters:
file- an input fileoptions- parquet read optionsf- the input stream for the file- Returns:
- an open ParquetFileReader
- Throws:
IOException- if there is an error while opening the file
-
open
public static ParquetFileReader open(org.apache.parquet.io.InputFile file, ParquetMetadata footer, ParquetReadOptions options, org.apache.parquet.io.SeekableInputStream f) throws IOException - Parameters:
file- an input filefooter- aParquetMetadatafooter already read from the fileoptions- parquet read optionsf- the input stream for the file- Returns:
- an open ParquetFileReader
- Throws:
IOException- if there is an error while opening the file
-
getFileMetaData
-
getRecordCount
public long getRecordCount() -
getFilteredRecordCount
public long getFilteredRecordCount() -
getPath
Deprecated.will be removed in 2.0.0; usegetFile()instead- Returns:
- the path for this file
-
getFile
-
getRowGroups
-
getCurrentRowGroupIndex
public int getCurrentRowGroupIndex()Returns the 0-based index of the row group that was last read viareadNextRowGroup()orreadNextFilteredRowGroup(). Returns -1 if no row group has been read yet. -
setRequestedSchema
-
setRequestedSchema
public void setRequestedSchema(org.apache.parquet.schema.MessageType projection) -
appendTo
- Throws:
IOException
-
readRowGroup
Reads all the columns requested from the row group at the specified block.- Parameters:
blockIndex- the index of the requested block- Returns:
- the PageReadStore which can provide PageReaders for each column.
- Throws:
IOException- if an error occurs while reading
-
readNextRowGroup
Reads all the columns requested from the row group at the current file position.- Returns:
- the PageReadStore which can provide PageReaders for each column.
- Throws:
IOException- if an error occurs while reading
-
readFilteredRowGroup
public org.apache.parquet.column.page.PageReadStore readFilteredRowGroup(int blockIndex) throws IOException Reads all the columns requested from the specified row group. It may skip specific pages based on the column indexes according to the actual filter. As the rows are not aligned among the pages of the different columns row synchronization might be required. See the documentation of the class SynchronizingColumnReader for details.- Parameters:
blockIndex- the index of the requested block- Returns:
- the PageReadStore which can provide PageReaders for each column or null if there are no rows in this block
- Throws:
IOException- if an error occurs while reading
-
readFilteredRowGroup
public org.apache.parquet.hadoop.ColumnChunkPageReadStore readFilteredRowGroup(int blockIndex, org.apache.parquet.filter2.columnindex.RowRanges rowRanges) throws IOException Reads all the columns requested from the specified row group. It may skip specific pages based on therowRangespassed in. As the rows are not aligned among the pages of the different columns row synchronization might be required. See the documentation of the class SynchronizingColumnReader for details.- Parameters:
blockIndex- the index of the requested blockrowRanges- the row ranges to be read from the requested block- Returns:
- the PageReadStore which can provide PageReaders for each column or null if there are no rows in this block
- Throws:
IOException- if an error occurs while readingIllegalArgumentException- if theblockIndexis invalid or therowRangesis null
-
readFilteredRowGroup
@Deprecated public org.apache.parquet.hadoop.ColumnChunkPageReadStore readFilteredRowGroup(int blockIndex, org.apache.parquet.internal.filter2.columnindex.RowRanges rowRanges) throws IOException Deprecated.usereadFilteredRowGroup(int, RowRanges)withRowRangesinstead. This overload is retained for backward compatibility and will be removed in 2.0.- Parameters:
blockIndex- the index of the requested blockrowRanges- the row ranges to be read from the requested block- Returns:
- the PageReadStore which can provide PageReaders for each column or null if there are no rows in this block
- Throws:
IOException- if an error occurs while readingIllegalArgumentException- if theblockIndexis invalid or therowRangesis null
-
readNextFilteredRowGroup
Reads all the columns requested from the row group at the current file position. It may skip specific pages based on the column indexes according to the actual filter. As the rows are not aligned among the pages of the different columns row synchronization might be required. See the documentation of the class SynchronizingColumnReader for details.- Returns:
- the PageReadStore which can provide PageReaders for each column
- Throws:
IOException- if an error occurs while reading
-
getColumnIndexStore
public org.apache.parquet.internal.filter2.columnindex.ColumnIndexStore getColumnIndexStore(int blockIndex) -
getRowRanges
public org.apache.parquet.filter2.columnindex.RowRanges getRowRanges(int blockIndex) Computes theRowRangeswithin the given row group that may pass the configured filter (set viaParquetReadOptionsorParquetInputFormat.setFilterPredicate(org.apache.hadoop.conf.Configuration, org.apache.parquet.filter2.predicate.FilterPredicate)). If no filter is configured, returns aRowRangescovering all rows in the row group. If the row group has no rows, returnsRowRanges.EMPTY.This computation is metadata-only: it consults each filter-referenced column's column index from the file footer; no column data is read from disk. The result can be passed to
readFilteredRowGroup(int, RowRanges)(intersected with any caller-supplied row ranges if desired) to read only the matching pages.- Parameters:
blockIndex- the row group (block) index- Returns:
- row ranges within the block that may pass the configured filter
- Throws:
IllegalArgumentException- ifblockIndexis out of range
-
skipNextRowGroup
public boolean skipNextRowGroup() -
getNextDictionaryReader
public org.apache.parquet.column.page.DictionaryPageReadStore getNextDictionaryReader()Returns aDictionaryPageReadStorefor the row group that would be returned by callingreadNextRowGroup()or skipped by callingskipNextRowGroup().- Returns:
- a DictionaryPageReadStore for the next row group
-
getDictionaryReader
public org.apache.parquet.hadoop.DictionaryPageReader getDictionaryReader(int blockIndex) -
getDictionaryReader
-
getBloomFilterDataReader
-
getBloomFilterDataReader
-
readBloomFilter
public org.apache.parquet.column.values.bloomfilter.BloomFilter readBloomFilter(ColumnChunkMetaData meta) throws IOException Reads Bloom filter data for the given column chunk.- Parameters:
meta- a column's ColumnChunkMetaData to read the dictionary from- Returns:
- an BloomFilter object.
- Throws:
IOException- if there is an error while reading the Bloom filter.
-
readColumnIndex
public org.apache.parquet.internal.column.columnindex.ColumnIndex readColumnIndex(ColumnChunkMetaData column) throws IOException Class should be considered private- Parameters:
column- the column chunk which the column index is to be returned for- Returns:
- the column index for the specified column chunk or
nullif there is no index - Throws:
IOException- if any I/O error occurs during reading the file
-
readOffsetIndex
public org.apache.parquet.internal.column.columnindex.OffsetIndex readOffsetIndex(ColumnChunkMetaData column) throws IOException Class should be considered private- Parameters:
column- the column chunk which the offset index is to be returned for- Returns:
- the offset index for the specified column chunk or
nullif there is no index - Throws:
IOException- if any I/O error occurs during reading the file
-
detachFileInputStream
public void detachFileInputStream()Explicitly detach the the input stream for the file to avoid being closed viaclose(). -
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException