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


##########
java/vector/src/main/java/org/apache/arrow/vector/BaseValueVector.java:
##########
@@ -143,6 +147,43 @@ 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 type of the reader implementation to 
instantiate the reader properly.
+   *
+   * @return Returns the implementation class type of the vector's reader.
+   */
+  protected abstract Class<? extends FieldReader> getReaderImplClass();
+
+  /**
+   * Default implementation to create a reader for the vector. Depends on the 
individual vector
+   * class' implementation of `getReaderImpl()` to initialize the reader 
appropriately.
+   *
+   * @return Concrete instance of FieldReader by using lazy initialization.
+   */
+  public FieldReader getReader() {
+    FieldReader reader = fieldReader;
+
+    if (reader != null) {
+      return reader;
+    }
+    synchronized (this) {
+      if (fieldReader == null) {
+        try {
+          fieldReader =
+              (FieldReader) 
Class.forName(getReaderImplClass().getName()).getConstructor(getClass())

Review Comment:
   Well returning a `FieldReader` instance would mean that I'd need to 
construct it. I want to do that in the `synchronized` block so I was returning 
the class type to construct an instance out of.
   
   Out of curiosity, what is the advantage of returning a `Function` type over 
the current implementation? 



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