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

[Rust] Add capacity field in Buffer #21816

Closed
asfimport opened this issue May 16, 2019 · 5 comments
Closed

[Rust] Add capacity field in Buffer #21816

asfimport opened this issue May 16, 2019 · 5 comments

Comments

@asfimport
Copy link
Collaborator

Currently Buffer only has len, but no capacity. We should add both.

Reporter: Chao Sun / @sunchao
Assignee: Chao Sun / @sunchao

PRs and other links:

Note: This issue was originally created as ARROW-5357. Please see the migration documentation for further details.

@asfimport
Copy link
Collaborator Author

Paddy Horan / @paddyhoran:
What do you think of introducing capacity in addition to len, we can then use capacity in flatbuffers?

@asfimport
Copy link
Collaborator Author

Chao Sun / @sunchao:
Yes we can perhaps do that - this is how C++ does anyway.

Originally the problem was: when I compare a buffer I created via Buffer::from(&[1, 2, 3]) versus a buffer created from flatbuffer with the same data, it will fail because on the left hand side the len is less than capacity, but on the right hand side len = capacity.

However thinking on it more, maybe we should not compare buffer directly without other contexts, such as how many valid elements are stored in the buffer. Also, unless we always zero-out the padded bytes in a buffer, comparison on buffer will likely to fail.

@asfimport
Copy link
Collaborator Author

Paddy Horan / @paddyhoran:

"Also, unless we always zero-out the padded bytes in a buffer, comparison on buffer will likely to fail."

Yea and I don't think we want to guarantee that the padded bytes will be 0 as certain algorithms will be easier to implement such as SIMD operations.

@asfimport
Copy link
Collaborator Author

Chao Sun / @sunchao:
Re-purposing this Jira to add capacity info in Buffer struct.

@asfimport
Copy link
Collaborator Author

Paddy Horan / @paddyhoran:
Issue resolved by pull request 4331
#4331

@asfimport asfimport added this to the 0.17.0 milestone Jan 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants