edgarRd commented on a change in pull request #139: ORC support integration for
Spark 2.4.0
URL: https://github.com/apache/incubator-iceberg/pull/139#discussion_r281427455
##########
File path: orc/src/main/java/org/apache/iceberg/orc/OrcFileAppender.java
##########
@@ -34,36 +38,39 @@
/**
* Create a file appender for ORC.
*/
-public class OrcFileAppender implements FileAppender<VectorizedRowBatch> {
- private final Writer writer;
+class OrcFileAppender<D> implements FileAppender<D> {
+ private final static int BATCH_SIZE = 1024;
+
private final TypeDescription orcSchema;
private final ColumnIdMap columnIds = new ColumnIdMap();
private final Path path;
+ private final Writer writer;
+ private final VectorizedRowBatch batch;
+ private final OrcValueWriter<D> valueWriter;
private boolean isClosed = false;
- public static final String COLUMN_NUMBERS_ATTRIBUTE = "iceberg.column.ids";
+ static final String COLUMN_NUMBERS_ATTRIBUTE = "iceberg.column.ids";
- OrcFileAppender(Schema schema,
- OutputFile file,
- OrcFile.WriterOptions options,
- Map<String,byte[]> metadata) {
- orcSchema = TypeConversion.toOrc(schema, columnIds);
- options.setSchema(orcSchema);
+ OrcFileAppender(TypeDescription schema, OutputFile file,
+ Function<TypeDescription, OrcValueWriter<?>>
createWriterFunc,
+ OrcFile.WriterOptions options, Map<String, byte[]> metadata)
{
+ orcSchema = schema;
path = new Path(file.location());
- try {
- writer = OrcFile.createWriter(path, options);
- } catch (IOException e) {
- throw new RuntimeException("Can't create file " + path, e);
- }
- writer.addUserMetadata(COLUMN_NUMBERS_ATTRIBUTE, columnIds.serialize());
- metadata.forEach(
- (key,value) -> writer.addUserMetadata(key, ByteBuffer.wrap(value)));
+ batch = orcSchema.createRowBatch(BATCH_SIZE);
Review comment:
I've added a configuration setting for this value.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]