-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GH-44626: [Java] fix SplitAndTransfer throws for empty MapVector #44627
base: main
Are you sure you want to change the base?
Conversation
final int relativeOffset = | ||
offsetBuffer.getInt((startIndex + i) * OFFSET_WIDTH) - startPoint; | ||
to.offsetBuffer.setInt(i * OFFSET_WIDTH, relativeOffset); | ||
if (length > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we just return if length=0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can do though my personal preference would be to avoid multiple returns. Current implementation is in keeping with how splitAndTransfer
is implemented for other complex types (e.g. ListVector).
ListVector toListVector = (ListVector) transferPair.getTo(); | ||
|
||
assertEquals(valueCount, toListVector.getValueCount()); | ||
fromListVector.clear(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: use try-with-resources
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that there're several closeable resources here and toListVector
cannot be constructed inside the same try
as fromListVector
. This is just to say that there'd be some ugly nesting if using try.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. Sure.
@lidavidm need some help to run the CIs. |
Signed-off-by: Maksim Yegorov <[email protected]>
Rationale for this change
Empty MapVector.splitAndTransfer throws
java.lang.IndexOutOfBoundsException
. Details in #44626What changes are included in this PR?
Fixed for MapVector as for other vector types in #41066
Are these changes tested?
Added unit test mimicking the scenario we've observed where MapVector's offset buffer capacity is 0.