lidavidm commented on code in PR #697:
URL: https://github.com/apache/arrow-java/pull/697#discussion_r2026159801


##########
vector/src/main/java/org/apache/arrow/vector/complex/impl/ExtensionTypeWriterFactory.java:
##########
@@ -0,0 +1,23 @@
+/*
+ * 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.arrow.vector.complex.impl;
+
+import org.apache.arrow.vector.ExtensionTypeVector;
+
+public interface ExtensionTypeWriterFactory<T extends AbstractFieldWriter> {

Review Comment:
   Can we document this?



##########
vector/src/main/java/org/apache/arrow/vector/holders/ExtensionHolder.java:
##########
@@ -0,0 +1,21 @@
+/*
+ * 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.arrow.vector.holders;
+
+public abstract class ExtensionHolder implements ValueHolder {

Review Comment:
   Can we document this?



##########
vector/src/test/java/org/apache/arrow/vector/types/pojo/TestExtensionType.java:
##########


Review Comment:
   We may want to just pull the UuidType into a toplevel class now that it's 
being used by multiple tests.



##########
vector/src/test/java/org/apache/arrow/vector/complex/impl/TestPromotableWriter.java:
##########
@@ -776,4 +780,95 @@ public void testPromoteToUnionFromDecimal() throws 
Exception {
       assertEquals(1, intHolder.value);
     }
   }
+
+  @Test
+  public void testExtensionType() throws Exception {
+    try (final NonNullableStructVector container =
+        NonNullableStructVector.empty(EMPTY_SCHEMA_PATH, allocator);
+        final UuidVector v =
+            container.addOrGet("uuid", FieldType.nullable(new UuidType()), 
UuidVector.class);
+        final PromotableWriter writer = new PromotableWriter(v, container)) {
+      UUID u1 = UUID.randomUUID();
+      UUID u2 = UUID.randomUUID();
+      container.allocateNew();
+      container.setValueCount(1);
+      writer.addExtensionTypeFactory(new UuidWriterFactory());
+
+      writer.setPosition(0);
+      writer.writeExtensionType(u1);
+      writer.setPosition(1);
+      writer.writeExtensionType(u2);
+
+      container.setValueCount(2);
+
+      UuidVector uuidVector = (UuidVector) container.getChild("uuid");
+      assertEquals(u1, uuidVector.getObject(0));
+      assertEquals(u2, uuidVector.getObject(1));
+    }
+  }
+
+  public class UuidWriterFactory implements ExtensionTypeWriterFactory {
+
+    @Override
+    public AbstractFieldWriter getWriterImpl(ExtensionTypeVector 
extensionTypeVector) {
+      if (extensionTypeVector instanceof UuidVector) {
+        return new UuidWriterImpl((UuidVector) extensionTypeVector);
+      }
+      return null;
+    }
+  }
+
+  public class UuidWriterImpl extends AbstractFieldWriter {
+    private final UuidVector vector;
+
+    public UuidWriterImpl(UuidVector vector) {
+      this.vector = vector;
+    }
+
+    @Override

Review Comment:
   Is there a way we can provide default implementations for these functions to 
reduce the boilerplate?



##########
vector/src/main/java/org/apache/arrow/vector/complex/impl/ExtensionTypeWriterFactory.java:
##########
@@ -0,0 +1,23 @@
+/*
+ * 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.arrow.vector.complex.impl;
+
+import org.apache.arrow.vector.ExtensionTypeVector;
+
+public interface ExtensionTypeWriterFactory<T extends AbstractFieldWriter> {

Review Comment:
   Does the type bound need to be `AbstractFieldWriter` or can it just be 
`FieldWriter` (the interface)?



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to