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


##########
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:
   Huh I guess the construction would only happen when I call `.apply` which 
would in the synchronized block. That does seem nicer...
   
   Any chance I could clean that up in a follow up ticket? Or would you prefer 
I make the changes here? 



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