Package com.jerolba.carpet
Class CarpetWriter<T>
java.lang.Object
com.jerolba.carpet.CarpetWriter<T>
- Type Parameters:
T
- The type of records to write.
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Consumer<T>
A Parquet file writer for writing java records of type T to a file or output
stream. The writer is also a consumer that can be used with Java 8 streams.
Creates a ParquetWriter with this configuration:
.withWriteMode(Mode.OVERWRITE)
.withCompressionCodec(CompressionCodecName.SNAPPY)
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionCarpetWriter
(OutputStream outputSrream, Class<T> recordClass) Constructs a CarpetWriter that writes records of type T to the specified OutputStream.CarpetWriter
(org.apache.parquet.io.OutputFile outputFile, Class<T> recordClass) Constructs a CarpetWriter that writes records of type T to the specified OutputFile. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Writes the specified Java object to a Parquet file implementing Consumervoid
close()
void
write
(Collection<T> collection) Writes the specified collection of Java objects to a Parquet file.void
Writes the specified stream of Java objects to a Parquet file.void
Writes the specified Java object to a Parquet file
-
Constructor Details
-
CarpetWriter
public CarpetWriter(org.apache.parquet.io.OutputFile outputFile, Class<T> recordClass) throws IOException Constructs a CarpetWriter that writes records of type T to the specified OutputFile.- Parameters:
outputFile
- The output file to write to.recordClass
- The class of the records to write.- Throws:
IOException
- If an I/O error occurs while creating the Parquet writer.
-
CarpetWriter
Constructs a CarpetWriter that writes records of type T to the specified OutputStream.- Parameters:
outputSrream
- An OutputStream to write to, of any type.recordClass
- The class of the records to write.- Throws:
IOException
- If an I/O error occurs while creating the Parquet writer.
-
-
Method Details
-
write
Writes the specified collection of Java objects to a Parquet file.- Parameters:
collection
- the collection of objects to write- Throws:
IOException
- if an error occurs while writing the records
-
write
Writes the specified Java object to a Parquet file- Parameters:
value
- object to write- Throws:
IOException
- if an error occurs while writing the records
-
accept
Writes the specified Java object to a Parquet file implementing Consumer- Specified by:
accept
in interfaceConsumer<T>
- Parameters:
value
- object to write- Throws:
UncheckedIOException
- if an error occurs while writing the records
-
write
Writes the specified stream of Java objects to a Parquet file.- Parameters:
stream
- the stream of objects to write- Throws:
IOException
- if an error occurs while writing the records
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-