lidavidm commented on code in PR #34424:
URL: https://github.com/apache/arrow/pull/34424#discussion_r1232308217


##########
java/vector/src/main/java/org/apache/arrow/vector/BaseValueVector.java:
##########
@@ -143,6 +147,35 @@ long computeCombinedBufferSize(int valueCount, int 
typeWidth) {
     return allocator.getRoundingPolicy().getRoundedSize(bufferSize);
   }
 
+  /**
+   * Each vector has a different reader that implements the FieldReader 
interface. Overridden methods must make
+   * sure to return the correct concrete reader implementation.
+   *
+   * @return Returns a lambda that initializes a reader when called.
+   */
+  protected abstract Supplier<FieldReader> getReaderImpl();
+
+  /**
+   * Default implementation to create a reader for the vector. Depends on the 
individual vector
+   * class' implementation of {@link #getReaderImpl} to initialize the reader 
appropriately.
+   *
+   * @return Concrete instance of FieldReader by using double-checked locking.
+   */
+  public FieldReader getReader() {
+    FieldReader reader = fieldReader;
+
+    if (reader != null) {
+      return reader;
+    }
+    synchronized (this) {
+      if (fieldReader == null) {
+        fieldReader = getReaderImpl().get();

Review Comment:
   I'll just point out...if you don't actually need to pass anything, this can 
just be `getReaderInstance()` and you can directly return the constructed 
reader. The whole thing with the class or even the function/supplier isn't 
necessary to make it lazy.



##########
java/vector/src/main/java/org/apache/arrow/vector/ExtensionTypeVector.java:
##########
@@ -130,6 +130,12 @@ public TransferPair makeTransferPair(ValueVector target) {
     return underlyingVector.makeTransferPair(target);
   }
 
+  @Override
+  protected Class<? extends FieldReader> getReaderImplClass() {
+    throw new UnsupportedOperationException("Readers for extension types 
depend on the underlying vector, " +

Review Comment:
   Subclasses of ExtensionTypeVector should override this if needed.



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