Skip to content

Commit

Permalink
Upgrade rand dependency.
Browse files Browse the repository at this point in the history
Removed xoshiro256** support.
  • Loading branch information
kennytm committed Nov 25, 2018
1 parent 9e4f06f commit bda0935
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 48 deletions.
13 changes: 8 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,24 @@ structopt = "0.2"
pest = "2.0"
pest_derive = "2.0"
failure = "0.1"
rand = "0.5"
rand = "0.6"
data-encoding = "2.1"
regex-syntax = "0.6"
pbr = "1.0"
num-traits = "0.2"
rayon = "1.0"
zipf = "4.0.1"
zipf = "5.0"
chrono = { version = "0.4", default-features = false }
ryu = "0.2"
pcg_rand = "0.9.3"
xoshiro = "0.0.4"
serde_derive = "1.0"
serde = "1.0"
muldiv = "0.2"
rand_regex = "0.11"
rand_regex = "0.12"
rand_pcg = "0.1"
rand_isaac = "0.1"
rand_chacha = "0.1"
rand_hc = "0.1"
rand_xorshift = "0.1"

[dev-dependencies]
regex = "1.0"
Expand Down
36 changes: 11 additions & 25 deletions src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
//! CLI driver of `dbgen`.
// TODO remove these `extern crate` once racer-rust/racer#916 is closed.
extern crate data_encoding;
extern crate failure;
extern crate pbr;
extern crate pcg_rand;
extern crate rand;
extern crate rayon;
extern crate structopt;
extern crate xoshiro;

use crate::{
eval::{Row, State},
format::{Format, SqlFormat},
Expand All @@ -20,7 +10,10 @@ use data_encoding::{DecodeError, DecodeKind, HEXLOWER_PERMISSIVE};
use failure::{Error, Fail, ResultExt};
use muldiv::MulDiv;
use pbr::{MultiBar, Units};
use rand::{prng, EntropyRng, Rng, RngCore, SeedableRng, StdRng};
use rand::{
rngs::{EntropyRng, StdRng},
Rng, RngCore, SeedableRng,
};
use rayon::{
iter::{IntoParallelIterator, ParallelIterator},
ThreadPoolBuilder,
Expand Down Expand Up @@ -270,10 +263,8 @@ pub enum RngName {
Isaac64,
/// Xorshift
XorShift,
/// PCG32-Oneseq
/// PCG32
Pcg32,
/// xoshiro256**
Xoshiro256StarStar,
}

impl FromStr for RngName {
Expand All @@ -286,7 +277,6 @@ impl FromStr for RngName {
"isaac64" => RngName::Isaac64,
"xorshift" => RngName::XorShift,
"pcg32" => RngName::Pcg32,
"xoshiro256**" => RngName::Xoshiro256StarStar,
_ => failure::bail!("Unsupported RNG {}", name),
})
}
Expand All @@ -295,17 +285,13 @@ impl FromStr for RngName {
impl RngName {
/// Creates an RNG engine given the name. The RNG engine instance will be seeded from `src`.
fn create(self, src: &mut StdRng) -> Box<dyn RngCore + Send> {
use pcg_rand::{seeds::PcgSeeder, Pcg32Oneseq};
use xoshiro::Xoshiro256StarStar;

match self {
RngName::ChaCha => Box::new(prng::ChaChaRng::from_seed(src.gen())),
RngName::Hc128 => Box::new(prng::Hc128Rng::from_seed(src.gen())),
RngName::Isaac => Box::new(prng::IsaacRng::from_seed(src.gen())),
RngName::Isaac64 => Box::new(prng::Isaac64Rng::from_seed(src.gen())),
RngName::XorShift => Box::new(prng::XorShiftRng::from_seed(src.gen())),
RngName::Pcg32 => Box::new(Pcg32Oneseq::from_seed(PcgSeeder::seed(src.gen()))),
RngName::Xoshiro256StarStar => Box::new(Xoshiro256StarStar::from_seed(src.gen())),
RngName::ChaCha => Box::new(rand_chacha::ChaChaRng::from_seed(src.gen())),
RngName::Hc128 => Box::new(rand_hc::Hc128Rng::from_seed(src.gen())),
RngName::Isaac => Box::new(rand_isaac::IsaacRng::from_seed(src.gen())),
RngName::Isaac64 => Box::new(rand_isaac::Isaac64Rng::from_seed(src.gen())),
RngName::XorShift => Box::new(rand_xorshift::XorShiftRng::from_seed(src.gen())),
RngName::Pcg32 => Box::new(rand_pcg::Pcg32::from_seed(src.gen())),
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,15 +333,15 @@ pub fn compile_function(name: Function, args: &[impl AsValue]) -> Result<Compile
}

Function::RandUniform => {
let lower = arg(name, args, 0, None)?;
let upper = arg(name, args, 1, None)?;
let lower = arg::<f64, _>(name, args, 0, None)?;
let upper = arg::<f64, _>(name, args, 1, None)?;
require!(lower < upper, "{} < {}", lower, upper);
Ok(Compiled(C::RandUniformF64(Uniform::new(lower, upper))))
}

Function::RandUniformInclusive => {
let lower = arg(name, args, 0, None)?;
let upper = arg(name, args, 1, None)?;
let lower = arg::<f64, _>(name, args, 0, None)?;
let upper = arg::<f64, _>(name, args, 1, None)?;
require!(lower <= upper, "{} <= {}", lower, upper);
Ok(Compiled(C::RandUniformF64(Uniform::new_inclusive(lower, upper))))
}
Expand Down
15 changes: 1 addition & 14 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,10 @@
rust_2018_idioms
)
)]
#![cfg_attr(feature = "cargo-clippy", allow(clippy::stutter, unused_extern_crates))]
#![cfg_attr(feature = "cargo-clippy", allow(clippy::stutter))]

//! The reusable library powering `dbgen`.
// TODO remove these `extern crate` once racer-rust/racer#916 is closed.
extern crate chrono;
extern crate data_encoding;
extern crate failure;
extern crate num_traits;
extern crate pest;
extern crate rand;
extern crate rand_regex;
extern crate regex_syntax;
extern crate ryu;
extern crate structopt;
extern crate zipf;

pub mod cli;
pub mod error;
pub mod eval;
Expand Down

0 comments on commit bda0935

Please sign in to comment.