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

AVRO-3835: [Rust] Get rid of byteorder and zerocopy dependencies #2455

Merged
merged 1 commit into from
Aug 18, 2023

Conversation

martin-g
Copy link
Member

Use standard APIs for converting integers to/from byte arrays. Get rid of byteorder and zerocopy dependencies.

What is the purpose of the change

  • Replace usage of byteorder and zerocopy dependencies with standard APIs

Verifying this change

  • All tests should still pass

Documentation

  • Does this pull request introduce a new feature? no

@martin-g martin-g requested a review from clesaec August 18, 2023 13:37
@github-actions github-actions bot added the Rust label Aug 18, 2023
@martin-g martin-g force-pushed the avro-3835-get-rid-of-byteorder-and-zerocopy branch from 70c6f81 to e02a65b Compare August 18, 2023 13:44
Copy link
Contributor

@clesaec clesaec left a comment

Choose a reason for hiding this comment

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

LGTM, Just one suggestion.

let mut encoded: Vec<u8> = vec![0; snap::raw::max_compress_len(stream.len())];
let compressed_size = snap::raw::Encoder::new()
.compress(&stream[..], &mut encoded[..])
.map_err(Error::SnappyCompress)?;
encoded.truncate(compressed_size);
Copy link
Contributor

Choose a reason for hiding this comment

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

As we know we will add u32 checksum, wouldn't it be more efficient with
encoded.truncate(compressed_size + 4);

Copy link
Member Author

Choose a reason for hiding this comment

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

Good suggestion! Thanks!

@@ -28,83 +24,77 @@ pub struct Duration {
}

#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub struct Months(U32<LittleEndian>);
pub struct Months(u32);
Copy link
Contributor

Choose a reason for hiding this comment

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

Strange duration concept, that is not even Comparable, and Eq is false between 1 month, 0 day and 0 months 30 days ... And some month are 31 days ...
But this PR indeed enhance this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Use standard APIs for converting integers to/from byte arrays.
Get rid of byteorder and zerocopy dependencies.

Signed-off-by: Martin Tzvetanov Grigorov <mgrigorov@apache.org>
@martin-g martin-g force-pushed the avro-3835-get-rid-of-byteorder-and-zerocopy branch from e02a65b to 954a527 Compare August 18, 2023 20:22
@martin-g martin-g merged commit 426c593 into master Aug 18, 2023
15 checks passed
@martin-g martin-g deleted the avro-3835-get-rid-of-byteorder-and-zerocopy branch August 18, 2023 20:35
martin-g added a commit that referenced this pull request Aug 18, 2023
Use standard APIs for converting integers to/from byte arrays.
Get rid of byteorder and zerocopy dependencies.

Signed-off-by: Martin Tzvetanov Grigorov <mgrigorov@apache.org>
(cherry picked from commit 426c593)
RanbirK pushed a commit to RanbirK/avro that referenced this pull request May 13, 2024
…che#2455)

Use standard APIs for converting integers to/from byte arrays.
Get rid of byteorder and zerocopy dependencies.

Signed-off-by: Martin Tzvetanov Grigorov <mgrigorov@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants