Uh oh!
There was an error while loading. Please reload this page.
ARROW-5357: [Rust] Change Buffer::len to represent total bytes instead of used bytes - #4331
ARROW-5357: [Rust] Change Buffer::len to represent total bytes instead of used bytes#4331sunchao wants to merge 4 commits into
Conversation
sunchao
commented
May 17, 2019
After discussing with @paddyhoran on the JIRA, I'm now inclined to keep both @nevi-me let me know if this sounds good to you. |
nevi-me
commented
May 17, 2019
I saw the conversation, would we be able to use capacity when writing to IPC from the current |
sunchao
commented
May 17, 2019
Yes, both reading and writing to IPC buffer will use |
nevi-me
commented
May 22, 2019
Apologies for not responding sooner @sunchao It's only mutable buffer that has capacity, and when we freeze it to create a buffer, we 'lose' the capacity. #[derive(PartialEq,Debug)]pubstructBuffer{/// Reference-counted pointer to the internal byte buffer.data:Arc<BufferData>,/// The offset into the buffer.offset:usize,}structBufferData{ptr:*constu8,len:usize,// no capacity} |
sunchao
commented
May 22, 2019
@nevi-me yes that's right. As I mentioned above, I think it's better to keep both I'm currently working on https://issues.apache.org/jira/browse/ARROW-5358 which hopefully will allow us to compare |
nevi-me
commented
May 22, 2019
ed180da to
85fe336Comparecodecov-io
commented
Jul 28, 2019
Codecov Report
@@ Coverage Diff @@## master #4331 +/- ##
===========================================
- Coverage 87.5% 82.57% -4.93%
===========================================
Files 998 86 -912 Lines 141784 24935 -116849 Branches 1418 0 -1418 ===========================================
- Hits 124065 20591 -103474 + Misses 17357 4344 -13013 + Partials 362 0 -362
Continue to review full report at Codecov.
|
paddyhoran
commented
Sep 9, 2019
sunchao
commented
Sep 9, 2019
I think it is ready for review. It'd be great if you can take a look. |
paddyhoran
commented
Sep 9, 2019
Yep, sounds good. I'll take a look when I get a chance. |
There was a problem hiding this comment.
I'm not against the current implementation, but I wonder if we should only compare the "meaningful" data?
There was a problem hiding this comment.
I agree. It seems wrong that on one hand the memcmp is comparing up to len and we bypass that if there is a mismatch on capacity
There was a problem hiding this comment.
Thanks guys! I'm slightly confused - here we are comparing meaningful data, no? and if capacity mismatch then it is considered not equal and we skip comparing the data content.
The equality is defined as: 1) both length should be equal, 2) both capacity should be equal, and 3) data content up to length should be equal. Let me know if this definition sounds good to you.
There was a problem hiding this comment.
To me if two arrays only differ by the amount of padding that they have then I would consider them equal. When I perform operations using these two arrays I will get the same answer (because the padding, or rather amount of padding, does not impact the result). However:
- I am focused on computation, maybe there are other implication in IPC, etc.
- In practice, this probably won't come up as we round up padding to a multiple of 64 bytes, but it could happen.
There was a problem hiding this comment.
Array equality is defined separately in array/equal.rs and yes, it does take account on what you said (it compares buffer content with data()). In the current context we are discussing equality of buffers though, which IMO, when looking at in isolation, should consider both len and capacity.
There was a problem hiding this comment.
We should also check that we are padded to 64 bytes. We assume this in the SIMD implementations and it's recommended here.
There was a problem hiding this comment.
We should probably test for this also.
There was a problem hiding this comment.
I agree. It seems wrong that on one hand the memcmp is comparing up to len and we bypass that if there is a mismatch on capacity
There was a problem hiding this comment.
Same issue .. memcmp compares up to len so it doesn't matter if the capacities match or not
nevi-me
commented
Dec 29, 2019
I initially thought this would be a blocker for IPC, but I've managed to implement the reader and writer without this. I'd vote for closing this PR @sunchao. |
paddyhoran
commented
Dec 30, 2019
I would actually like to see this PR merged (maybe after further review). Length and capacity are two distinct concepts in Arrow and having capacity be explicit is easier to understand especially for newcomers. I also think it will be useful when converting from other libraries to Arrow. In these cases, we will have to check the alignment and padding (capacity) of the data that is passed to us. |
sunchao
commented
Dec 31, 2019
Yes I think it is still useful to have size and capacity as two separate properties of buffer. @andygrove could you take another look on this? I think your concern has been addressed via the comments. |
emkornfield
commented
Feb 3, 2020
@andygrove want to take look? |
paddyhoran
commented
Feb 14, 2020
@sunchao can you rebase this if you get a chance (or let me know if you are stuck for time and I will)? It turns out that this PR fixes UB as pointed out by @jturner314 on #6397. I'll re-review early next week and hopefully we can get this merged. |
sunchao
commented
Feb 15, 2020
Sure @paddyhoran . Updated. |
paddyhoran
left a comment
There was a problem hiding this comment.
LGTM - @andygrove you requested changes previously, do you want to re-review or can I merge this one?
andygrove
commented
Feb 20, 2020
Apologies for missing the earlier mentions. I really need to figure out a better way of managing all the emails I get so that these mentions stand out. |
wesm
commented
Feb 20, 2020
@andygrove the easiest thing is to set up a gmail filter that sends any GitHub e-mail with "you were mentioned" directly to Inbox (vice versa, to auto-archive any GitHub e-mail that does not contain this). A separate filter rule should be used to apply a label unconditionally to Arrow-related GitHub e-mails |
No description provided.