Skip to content

Conversation

@jorgecarleitao
Copy link
Member

@jorgecarleitao jorgecarleitao commented Feb 14, 2021

This PR makes Bytes typed.

Bytes is not a public API and therefore this is backward compatible.

Same rational and built on top of #9495

@github-actions
Copy link

@codecov-io
Copy link

Codecov Report

Merging #9496 (e948568) into master (8547c61) will decrease coverage by 0.05%.
The diff coverage is 57.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #9496      +/-   ##
==========================================
- Coverage   82.12%   82.06%   -0.06%     
==========================================
  Files         235      236       +1     
  Lines       54729    54767      +38     
==========================================
+ Hits        44944    44945       +1     
- Misses       9785     9822      +37     
Impacted Files Coverage Δ
rust/arrow/src/alloc/types.rs 0.00% <0.00%> (ø)
rust/arrow/src/alloc/mod.rs 92.68% <92.68%> (ø)
rust/arrow/src/array/array_list.rs 93.40% <100.00%> (ø)
rust/arrow/src/array/raw_pointer.rs 100.00% <100.00%> (ø)
rust/arrow/src/buffer.rs 95.62% <100.00%> (+0.35%) ⬆️
rust/arrow/src/bytes.rs 53.12% <100.00%> (ø)
rust/arrow/src/array/transform/fixed_binary.rs 84.21% <0.00%> (+5.26%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8547c61...e948568. Read the comment docs.

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

I looked at the one new commit: e948568 and it looks great to me

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason to change from // to ///?

@nevi-me nevi-me added the needs-rebase A PR that needs to be rebased by the author label Feb 24, 2021
@nevi-me nevi-me removed the needs-rebase A PR that needs to be rebased by the author label Feb 25, 2021
pub struct Buffer {
/// the internal byte buffer.
data: Arc<Bytes>,
data: Arc<Bytes<u8>>,
Copy link
Contributor

Choose a reason for hiding this comment

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

@jorgecarleitao if Buffer always has Bytes<u8>, I think this alone doesn't address one of the motivations of doing this; being that we'd like to know what boundary to slice buffers in when offsetting arrays.

This would be when using Buffer::offset and Buffer::length on nested arrays.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree.

However, we can't make Buffer<T> because ArrayData force us to use an homogeneous type across all buffers. We can't drop ArrayData because FFI, IPC, CSV, JSON, equality and array/transform depend on it.

This PR was a stop-gap.

Th target design for me is in the proposal. Specifically, for primitive arrays, it would look like this

But because of what I wrote (a lot of dependencies on ArrayData), it requires a large (like +10k lines large) refactor of this crate.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is it worth still pursuing adding more information to Buffer while working separately on the proposal? I'm blocked on some parquet work that I'm doing, because it depends on being able to correctly slice nested arrays.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that any work that unblocks you is worth pursuing :)

A path could be:

  1. Make Buffer support both bit slices and byte slices:
  • Add a new offset_bits to Buffer.
  • Expose a method Buffer::slice_bitmap that increments offset_bits (and panics if called with offset != 0).
  • Make Buffer::slice panic if called with offset_bits != 0.

These will allow us to slice Buffer when it is either holder of bits and a holder of bytes (we just need to use either API independently). This is required because the Boolean array's values are in bits (and thus part of ArrayData::buffers).

  1. Implement a method

pub fn slice(&self, offset: usize, length: usize) -> Self

on every array, that calls slice or slice_bits depending on what the Buffer represents (and also fix the incorrect slicing of arrays with offsets).

  1. make Array::slice call the concrete implementations

  2. Make all calls of get_bit and the like to use Buffer::offset_bits to compute slot nullability and/or values.

Note that I have not tested this and thus this may not work. I also do not know the consequences to IPC and FFI. :/

I am more confident that the proposal works because it passes IPC tests (IPC read and write, little and big endian ;)).

@alamb
Copy link
Contributor

alamb commented Apr 19, 2021

The Apache Arrow Rust community is moving the Rust implementation into its own dedicated github repositories arrow-rs and arrow-datafusion. It is likely we will not merge this PR into this repository

Please see the mailing-list thread for more details

We expect the process to take a few days and will follow up with a migration plan for the in-flight PRs.

@jorgecarleitao jorgecarleitao deleted the typed_bytes branch May 1, 2021 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants