rdblue commented on a change in pull request #227: ORC column map fix
URL: https://github.com/apache/incubator-iceberg/pull/227#discussion_r296331713
 
 

 ##########
 File path: orc/src/main/java/org/apache/iceberg/orc/ColumnMap.java
 ##########
 @@ -33,11 +35,48 @@
  * Keep the API limited to Map rather than a concrete type so that we can
  * change it later.
  */
-public class ColumnIdMap implements Map<TypeDescription, Integer> {
+public final class ColumnMap implements Map<TypeDescription, 
ColumnMap.IcebergColumn> {
 
-  private final IdentityHashMap<TypeDescription, Integer> idMap =
+  private final IdentityHashMap<TypeDescription, IcebergColumn> idMap =
       new IdentityHashMap<>();
 
+  static class IcebergColumn {
+
+    private final int id;
+    private final boolean required;
+
+    private IcebergColumn(int id, boolean isRequired) {
+      this.id = id;
+      this.required = isRequired;
+    }
+
+    public boolean isRequired() {
+      return required;
+    }
+
+    public int getId() {
+      return id;
+    }
+
+    @Override
+    public int hashCode() {
+      return Objects.hashCode(this.id, this.required);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
 
 Review comment:
   Iceberg column equality is based on ID alone. I like that this also captures 
whether the field was required when the data was written, but I'm concerned 
about using this as the key of a map to look up columns by ID if equality 
includes required.

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

Reply via email to