rdblue commented on a change in pull request #1888:
URL: https://github.com/apache/iceberg/pull/1888#discussion_r538813022
##########
File path: core/src/main/java/org/apache/iceberg/io/BaseTaskWriter.java
##########
@@ -75,6 +79,113 @@ public WriteResult complete() throws IOException {
.build();
}
+ /**
+ * Base delta writer to write both insert records and equality-deletes.
+ */
+ protected abstract class BaseDeltaWriter implements Closeable {
+ private RollingFileWriter dataWriter;
+ private RollingEqDeleteWriter eqDeleteWriter;
+ private SortedPosDeleteWriter<T> posDeleteWriter;
+ private StructLikeMap<PathOffset> insertedRowMap;
+
+ public BaseDeltaWriter(PartitionKey partition, Schema eqDeleteSchema) {
+ Preconditions.checkNotNull(eqDeleteSchema, "equality-delete schema could
not be null.");
+
+ this.dataWriter = new RollingFileWriter(partition);
+
+ this.eqDeleteWriter = new RollingEqDeleteWriter(partition);
+ this.insertedRowMap = StructLikeMap.create(eqDeleteSchema.asStruct());
+
+ this.posDeleteWriter = new SortedPosDeleteWriter<>(appenderFactory,
fileFactory, format, partition);
+ }
+
+ /**
+ * Make the generic data could be read as a {@link StructLike}.
+ */
+ protected abstract StructLike asStructLike(T data);
+
+ protected abstract StructLike asCopiedKey(T row);
Review comment:
I think this could be removed from the API because this already has
`asStructLike`. Rather than relying on the implementation to create the
projection and copy it, this could be implemented here like this:
```java
protected StructLike asCopiedKey(T row) {
return structProjection.copy().wrap(asStructLike(row));
}
```
We would need to create `StructProjection` in this class, but it would be
fairly easy.
----------------------------------------------------------------
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]