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


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

Review Comment:
   Changed.



##########
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:
   Could you please clarify what you mean by return a factory function? I can 
change the usage to `getReaderImplClass().getInstance` if that is preferable. I 
just used `Class.forName` since I am more familiar with that option is all. 



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