Package com.jerolba.carpet
Class CarpetReader<T>
java.lang.Object
com.jerolba.carpet.CarpetReader<T>
- Type Parameters:
T- The type of the records being read.
- All Implemented Interfaces:
Iterable<T>
CarpetReader wraps the creation of CarpetParquetReader CarpetReader is an
Iterable and Streamable class that can be used to read a Parquet file and
iterate over its records.
-
Constructor Summary
ConstructorsConstructorDescriptionCarpetReader(File file, Class<T> recordClass) Creates a newCarpetReaderinstance from the specified File and record class.CarpetReader(org.apache.parquet.io.InputFile inputFile, Class<T> recordClass) Creates a newCarpetReaderinstance from the specified InputFile and record class. -
Method Summary
Modifier and TypeMethodDescriptioniterator()Returns anIteratorthat can be used to iterate over the records in the Parquet file.stream()Returns aStreamthat can be used to access the records in the Parquet file.toList()Returns aListcontaining all records in the Parquet file.withFailNarrowingPrimitiveConversion(boolean value) Feature that determines whether coercion from one number type to other number type with less resolutions is allowed or not.withFailOnMissingColumn(boolean value) Feature that determines whether encountering of missed parquet column should result in a failure (by throwing a RecordTypeConversionException) or not.withFailOnNullForPrimitives(boolean value) Feature that determines whether encountering null is an error when deserializing into Java primitive types (like 'int' or 'double').Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
CarpetReader
Creates a newCarpetReaderinstance from the specified InputFile and record class.- Parameters:
inputFile- the input file from which the records will be readrecordClass- the class of the records being read
-
CarpetReader
Creates a newCarpetReaderinstance from the specified File and record class.- Parameters:
file- the File containing the Parquet datarecordClass- the class of the records being read
-
-
Method Details
-
withFailOnMissingColumn
Feature that determines whether encountering of missed parquet column should result in a failure (by throwing a RecordTypeConversionException) or not. Feature is enabled by default.- Parameters:
value- The new value for the failOnMissingColumn flag.- Returns:
- a new instance of CarpetReader
-
withFailOnNullForPrimitives
Feature that determines whether encountering null is an error when deserializing into Java primitive types (like 'int' or 'double'). If it is, a RecordTypeConversionException is thrown to indicate this; if not, default value is used (0 for 'int', 0.0 for double, same defaulting as what JVM uses). Feature is disabled by default.- Parameters:
value- The new value for the failOnNullForPrimitives flag.- Returns:
- a new instance of CarpetReader
-
withFailNarrowingPrimitiveConversion
Feature that determines whether coercion from one number type to other number type with less resolutions is allowed or not. If disabled, coercion truncates value. A narrowing primitive conversion may lose information about the overall magnitude of a numeric value and may also lose precision and range. Narrowing follows Java Language Specification Feature is disabled by default.- Parameters:
value-- Returns:
- a new instance of CarpetReader
-
withFieldMatchingStrategy
-
iterator
Returns anIteratorthat can be used to iterate over the records in the Parquet file.- Specified by:
iteratorin interfaceIterable<T>- Returns:
- an iterator for the records in the Parquet file
- Throws:
UncheckedIOException- if an I/O error occurs
-
stream
Returns aStreamthat can be used to access the records in the Parquet file.- Returns:
- a stream for the records in the Parquet file
- Throws:
IOException- if an I/O error occurs
-
toList
Returns aListcontaining all records in the Parquet file.- Returns:
- a list of all records in the Parquet file
- Throws:
IOException- if an I/O error occurs
-