Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

myegorov
Copy link

@myegorov myegorov commented Nov 3, 2024

Rationale for this change

Empty MapVector.splitAndTransfer throws java.lang.IndexOutOfBoundsException. Details in #44626

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

final int relativeOffset =
offsetBuffer.getInt((startIndex + i) * OFFSET_WIDTH) - startPoint;
to.offsetBuffer.setInt(i * OFFSET_WIDTH, relativeOffset);
if (length > 0) {
Copy link
Collaborator

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

Copy link
Author

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

@github-actions github-actions bot added awaiting committer review Awaiting committer review and removed awaiting review Awaiting review labels Nov 3, 2024
ListVector toListVector = (ListVector) transferPair.getTo();

assertEquals(valueCount, toListVector.getValueCount());
fromListVector.clear();
Copy link
Collaborator

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

Copy link
Author

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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. Sure.

@vibhatha
Copy link
Collaborator

vibhatha commented Nov 3, 2024

@lidavidm need some help to run the CIs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants