liyafan82 commented on pull request #9187:
URL: https://github.com/apache/arrow/pull/9187#issuecomment-764200223


   > @liyafan82 But, I don't agree. See this section comment in source code:
   > 
https://github.com/apache/arrow/blob/691286975f277f00586cabc6d834ff1efd8caf8c/java/vector/src/main/java/org/apache/arrow/vector/ValueVector.java#L163
   > 
   > ```
   >   /**
   >    * Returns the number of bytes that is used by this vector if it holds 
the given number
   >    * of values. The result will be the same as if setValueCount() were 
called, followed
   >    * by calling getBufferSize(), but without any of the closing 
side-effects that setValueCount()
   >    * implies wrt finishing off the population of a vector. Some operations 
might wish to use
   >    * this to determine how much memory has been used by a vector so far, 
even though it is
   >    * not finished being populated.
   >    *
   >    * @param valueCount the number of values to assume this vector contains
   >    * @return the buffer size if this vector is holding valueCount values
   >    */
   >   int getBufferSizeFor(int valueCount);
   > ```
   > 
   > The `getBufferSizeFor` is designed for the case: when `setValueCount` 
haven't been called.
   > It also definitely say `setValueCount()` will bring "closing side-effects" 
(implies wrt finishing off the population of a vector)
   
   @WeichenXu123 Please note that the JavaDoc is overriden when the 
`BaseVariableWidthVector` overrides the method in the super interface:
   
   
https://github.com/apache/arrow/blob/master/java/vector/src/main/java/org/apache/arrow/vector/BaseVariableWidthVector.java#L598-L603
   
   The reason is that, for variable width vectors, it is not possible to 
estimate the buffer size without actually filling up the vector. (The varchars 
can be large or small, depending on the actual values).
   
   If the documentation is not clearly enough, can we revise it?
   


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

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


Reply via email to