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

Add ListView & LargeListView basic construction and validation #5664

Merged
merged 5 commits into from Apr 30, 2024

Conversation

Kikkon
Copy link
Contributor

@Kikkon Kikkon commented Apr 18, 2024

Which issue does this PR close?

A part of #5501

Rationale for this change

What changes are included in this PR?

Add ListView & LargeListView basic ArrayData construction and validation

Are there any user-facing changes?

@github-actions github-actions bot added the arrow Changes to the arrow crate label Apr 18, 2024
@Kikkon Kikkon changed the title feat: list view basic construction and validation Add ListView & LargeListView basic construction and validation Apr 18, 2024
@Kikkon Kikkon marked this pull request as ready for review April 18, 2024 17:03
Comment on lines 953 to 964
if offset > values_length {
return Err(ArrowError::InvalidArgumentError(format!(
"Size {} at index {} is offset {} is out of bounds for {}",
size, i, offset, self.data_type
)));
}
if size > values_length - offset {
return Err(ArrowError::InvalidArgumentError(format!(
"Size {} at index {} is larger than the remaining values for {}",
size, i, self.data_type
)));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This logic does not appear to be correct

From https://arrow.apache.org/docs/format/Columnar.html#listview-layout the variants this should be validating are

0 <= offsets[i] <= length of the child array
0 <= offsets[i] + size[i] <= length of the child array

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since the offset is already greater than 0, there is no boundary check for 0 here. I have adjusted the order for easier understanding.

size, i, offset, self.data_type
)));
}
if size + offset > values_length {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this needs to be checked addition to handle if size and offset were both i64::MAX, perhaps we could get a test of this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why do we need to check if both the offset and size are i64::max here? Are we concerned about exceeding the maximum limit of usize? I don't think either of them should exceed the maximum value of usize, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

The addition could overflow

Comment on lines 953 to 958
if offset > values_length {
return Err(ArrowError::InvalidArgumentError(format!(
"Size {} at index {} is offset {} is out of bounds for {}",
size, i, offset, self.data_type
)));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can probably drop this check in favor of the one below

Copy link
Contributor

@tustvold tustvold left a comment

Choose a reason for hiding this comment

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

This is getting close, thank you for sticking with it

@Kikkon Kikkon requested a review from tustvold April 29, 2024 14:14
@tustvold tustvold merged commit bbd85ed into apache:master Apr 30, 2024
25 checks passed
@tustvold
Copy link
Contributor

Thank you

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

Successfully merging this pull request may close these issues.

None yet

2 participants