rdblue commented on a change in pull request #1213:
URL: https://github.com/apache/iceberg/pull/1213#discussion_r459165054



##########
File path: 
core/src/main/java/org/apache/iceberg/taskio/PartitionedFanoutWriter.java
##########
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iceberg.taskio;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.function.Function;
+import org.apache.iceberg.FileFormat;
+import org.apache.iceberg.PartitionKey;
+import org.apache.iceberg.PartitionSpec;
+import org.apache.iceberg.io.FileIO;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+
+public class PartitionedFanoutWriter<T> extends BaseTaskWriter<T> {
+  private final Function<T, PartitionKey> keyGetter;

Review comment:
       Instead of passing a function, I think this should be an abstract method:
   
   ```java
     /**
      * Create a PartitionKey from the values in row.
      * <p>
      * Any PartitionKey returned by this method can be reused by the 
implementation.
      *
      * @param row a data row
      */
     protected abstract PartitionKey partition(T row);
   ```
   
   Passing a function is good if we need to inject behavior that might need to 
be customized, but here the only customization that would be required is to 
partition the objects that this class is already parameterized by. So it will 
be easier just to add a method for subclasses to implement. And that puts the 
responsibility on the implementation instead of on the code that constructs the 
writer.




----------------------------------------------------------------
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]

Reply via email to