[ 
https://issues.apache.org/jira/browse/ARROW-5357?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16841825#comment-16841825
 ] 

Chao Sun commented on ARROW-5357:
---------------------------------

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.

> [Rust] Change Buffer::len to represent total bytes instead of used bytes
> ------------------------------------------------------------------------
>
>                 Key: ARROW-5357
>                 URL: https://issues.apache.org/jira/browse/ARROW-5357
>             Project: Apache Arrow
>          Issue Type: Improvement
>          Components: Rust
>            Reporter: Chao Sun
>            Assignee: Chao Sun
>            Priority: Major
>
> Currently {{Buffer::len}} records the number of used bytes, as opposed to the 
> number of total bytes. This poses a problem when converting from buffers 
> defined in flatbuffer, where the length is actually the number of allocated 
> bytes for the buffer. 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to