pavibhai commented on a change in pull request #2543:
URL: https://github.com/apache/hive/pull/2543#discussion_r678549917
##########
File path:
storage-api/src/java/org/apache/hadoop/hive/ql/exec/vector/BytesColumnVector.java
##########
@@ -213,18 +211,17 @@ public void setVal(int elementNum, byte[] sourceBuf) {
* Ensures that we have space allocated for the next value, which has size
* length bytes.
*
- * Updates currentValue, currentOffset, and sharedBufferOffset for this
value.
+ * Updates currentValue and currentOffset for this value.
*
- * Always use before getValPreallocatedBytes, getValPreallocatedStart,
- * and setValPreallocated.
+ * Always use before getValPreallocatedBytes, getValPreallocatedStart.
+ * setValPreallocated must be called to actually reserve the bytes.
*/
public void ensureValPreallocated(int length) {
if ((sharedBufferOffset + length) > sharedBuffer.length) {
currentValue = allocateBuffer(length);
Review comment:
This is unrelated to the fix but feels like only currentValue is getting
assigned while currentOffset is also being changed inside allocateBuffer method.
Since allocateBuffer is private and not used elsewhere, we could move both
the assignments of currentValue and currentOffset into the allocateBuffer
method and have this as
```java
if ((sharedBufferOffset + length) > sharedBuffer.length) {
allocateBuffer(length);
} else {
currentValue = sharedBuffer;
currentOffset = sharedBufferOffset;
}
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]