Skip to content
This repository has been archived by the owner on Jan 11, 2021. It is now read-only.

Upgraded rand 0.4 -> 0.5 #167

Merged
merged 2 commits into from
Oct 8, 2018
Merged

Upgraded rand 0.4 -> 0.5 #167

merged 2 commits into from
Oct 8, 2018

Conversation

xrl
Copy link
Contributor

@xrl xrl commented Oct 6, 2018

I was starting a new project with dependencies that dragged in rand 0.5. This was breaking parquet-rs. I don't know the rand library very well but it looks like there has been a change for how the Standard/Distribution work and it creeped in to parquet-rs.

Should fix: #166
And should answer my question at: rust-random/rand#626

@coveralls
Copy link

coveralls commented Oct 6, 2018

Pull Request Test Coverage Report for Build 628

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.8%) to 94.768%

Totals Coverage Status
Change from base Build 624: -0.8%
Covered Lines: 634
Relevant Lines: 669

💛 - Coveralls

Copy link
Collaborator

@sadikovi sadikovi left a comment

Choose a reason for hiding this comment

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

Thanks for the patch. parquet-rs uses rand 0.4.3 and the issue could have been a changed behaviour in rust nightly - parquet-rs 0.3.0 was building okay with rust 1.28. It sounds strange that your project having dependency on rand 0.5 would affect parquet-rs. Anyway, I left some minor questions and suggestions. Thanks again!

@@ -497,7 +497,8 @@ impl RleDecoder {
#[cfg(test)]
mod tests {
use super::*;
use rand::{self, thread_rng, Rng, SeedableRng};
use rand::{self, thread_rng, Rng, SeedableRng };
Copy link
Collaborator

Choose a reason for hiding this comment

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

Whitespace at the end.

let seed = rng.gen_iter::<usize>().take(seed_len).collect::<Vec<usize>>();
let mut gen = rand::StdRng::from_seed(&seed[..]);
let seed_vec : Vec<u8> = Standard.sample_iter(&mut rng).take(seed_len).collect();
let seed_slice = &seed_vec[0..32];
Copy link
Collaborator

Choose a reason for hiding this comment

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

You might want to use seed_len, or just pass slice directly into copy_from_slice.

@@ -22,6 +22,9 @@ use errors::{ParquetError, Result};
use util::bit_packing::unpack32;
use util::memory::ByteBufferPtr;

#[cfg(test)]
use rand::distributions::{ Distribution, Standard };
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why can't you move that under mod tests?

src/util/test_common.rs Show resolved Hide resolved
src/lib.rs Outdated
@@ -142,7 +142,6 @@ extern crate lz4;
extern crate num_bigint;
extern crate zstd;

#[cfg(test)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why did you remove it?

@@ -767,7 +768,7 @@ mod tests {

#[test]
fn test_random() {
let seed_len = 10;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do you need to change from 10 to 32?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question, I went with 32 because I thought I needed 32 u8's to seed the PRNG. Again, I'm not very familiar with the library, but here's the error I see with an array of size 10:

   Compiling parquet v0.3.0 (/Users/xlange/code/rust/parquet-rs)
error[E0308]: mismatched types
   --> src/encodings/rle.rs:783:45
    |
783 |       let mut gen = rand::StdRng::from_seed(seed);
    |                                             ^^^^ expected an array with a fixed size of 32 elements, found one with 10 elements
    |
    = note: expected type `[u8; 32]`
               found type `[u8; 10]`

@sunchao sunchao mentioned this pull request Oct 7, 2018
@xrl
Copy link
Contributor Author

xrl commented Oct 7, 2018

Hey, thanks for the thorough review. All great feedback, I was definitely a little sloppy while hacking on this. I agree, it doesn't make sense that just having a mix of rand 0.4 and rand 0.5 in a project would cause an issue, but the type errors made me think it was a mix up. In any case, maybe this is just helpful in general to the project.

@xrl xrl force-pushed the rand-update branch 2 times, most recently from e36ee73 to f33fc63 Compare October 7, 2018 23:15
Copy link
Collaborator

@sadikovi sadikovi left a comment

Choose a reason for hiding this comment

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

LGTM.

@sunchao sunchao merged commit 9935834 into sunchao:master Oct 8, 2018
@sunchao
Copy link
Owner

sunchao commented Oct 8, 2018

Merged. Thanks @xrl for the PR and @sadikovi for the review!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parquet-rs 0.3.0 no longer builds with latest Rust nightly
4 participants