Skip to content

Commit 34b2184

Browse files
authored
Revert "Update rand requirement from 0.8 to 0.9 (#7045)" (#7125)
* Revert "Update rand requirement from 0.8 to 0.9 (#7045)" This reverts commit 69eeee3. * downgrade API
1 parent d3a875f commit 34b2184

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+390
-424
lines changed

arrow-array/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ ffi = ["arrow-schema/ffi", "arrow-data/ffi"]
5555
force_validate = []
5656

5757
[dev-dependencies]
58-
rand = { version = "0.9", default-features = false, features = ["std", "std_rng", "thread_rng"] }
58+
rand = { version = "0.8", default-features = false, features = ["std", "std_rng"] }
5959
criterion = { version = "0.5", default-features = false }
6060

6161
[build-dependencies]

arrow-array/benches/fixed_size_list_array.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
use arrow_array::{Array, FixedSizeListArray, Int32Array};
1919
use arrow_schema::Field;
2020
use criterion::*;
21-
use rand::{rng, Rng};
21+
use rand::{thread_rng, Rng};
2222
use std::sync::Arc;
2323

2424
fn gen_fsl(len: usize, value_len: usize) -> FixedSizeListArray {
25-
let mut rng = rng();
25+
let mut rng = thread_rng();
2626
let values = Arc::new(Int32Array::from(
27-
(0..len).map(|_| rng.random::<i32>()).collect::<Vec<_>>(),
27+
(0..len).map(|_| rng.gen::<i32>()).collect::<Vec<_>>(),
2828
));
2929
let field = Arc::new(Field::new_list_field(values.data_type().clone(), true));
3030
FixedSizeListArray::new(field, value_len as i32, values, None)

arrow-array/benches/occupancy.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use arrow_array::types::Int32Type;
1919
use arrow_array::{DictionaryArray, Int32Array};
2020
use arrow_buffer::NullBuffer;
2121
use criterion::*;
22-
use rand::{rng, Rng};
22+
use rand::{thread_rng, Rng};
2323
use std::sync::Arc;
2424

2525
fn gen_dict(
@@ -28,11 +28,11 @@ fn gen_dict(
2828
occupancy: f64,
2929
null_percent: f64,
3030
) -> DictionaryArray<Int32Type> {
31-
let mut rng = rng();
31+
let mut rng = thread_rng();
3232
let values = Int32Array::from(vec![0; values_len]);
3333
let max_key = (values_len as f64 * occupancy) as i32;
34-
let keys = (0..len).map(|_| rng.random_range(0..max_key)).collect();
35-
let nulls = (0..len).map(|_| !rng.random_bool(null_percent)).collect();
34+
let keys = (0..len).map(|_| rng.gen_range(0..max_key)).collect();
35+
let nulls = (0..len).map(|_| !rng.gen_bool(null_percent)).collect();
3636

3737
let keys = Int32Array::new(keys, Some(NullBuffer::new(nulls)));
3838
DictionaryArray::new(keys, Arc::new(values))

arrow-array/benches/union_array.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,27 @@ use arrow_array::{Array, ArrayRef, Int32Array, UnionArray};
2424
use arrow_buffer::{NullBuffer, ScalarBuffer};
2525
use arrow_schema::{DataType, Field, UnionFields};
2626
use criterion::*;
27-
use rand::{rng, Rng};
27+
use rand::{thread_rng, Rng};
2828

2929
fn array_with_nulls() -> ArrayRef {
30-
let mut rng = rng();
30+
let mut rng = thread_rng();
3131

32-
let values = ScalarBuffer::from_iter(repeat_with(|| rng.random()).take(4096));
32+
let values = ScalarBuffer::from_iter(repeat_with(|| rng.gen()).take(4096));
3333

3434
// nulls with at least one null and one valid
3535
let nulls: NullBuffer = [true, false]
3636
.into_iter()
37-
.chain(repeat_with(|| rng.random()))
37+
.chain(repeat_with(|| rng.gen()))
3838
.take(4096)
3939
.collect();
4040

4141
Arc::new(Int32Array::new(values.clone(), Some(nulls)))
4242
}
4343

4444
fn array_without_nulls() -> ArrayRef {
45-
let mut rng = rng();
45+
let mut rng = thread_rng();
4646

47-
let values = ScalarBuffer::from_iter(repeat_with(|| rng.random()).take(4096));
47+
let values = ScalarBuffer::from_iter(repeat_with(|| rng.gen()).take(4096));
4848

4949
Arc::new(Int32Array::new(values.clone(), None))
5050
}

arrow-array/src/array/boolean_array.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ impl From<BooleanBuffer> for BooleanArray {
479479
mod tests {
480480
use super::*;
481481
use arrow_buffer::Buffer;
482-
use rand::{rng, Rng};
482+
use rand::{thread_rng, Rng};
483483

484484
#[test]
485485
fn test_boolean_fmt_debug() {
@@ -667,11 +667,11 @@ mod tests {
667667
#[test]
668668
#[cfg_attr(miri, ignore)] // Takes too long
669669
fn test_true_false_count() {
670-
let mut rng = rng();
670+
let mut rng = thread_rng();
671671

672672
for _ in 0..10 {
673673
// No nulls
674-
let d: Vec<_> = (0..2000).map(|_| rng.random_bool(0.5)).collect();
674+
let d: Vec<_> = (0..2000).map(|_| rng.gen_bool(0.5)).collect();
675675
let b = BooleanArray::from(d.clone());
676676

677677
let expected_true = d.iter().filter(|x| **x).count();
@@ -680,7 +680,7 @@ mod tests {
680680

681681
// With nulls
682682
let d: Vec<_> = (0..2000)
683-
.map(|_| rng.random_bool(0.5).then(|| rng.random_bool(0.5)))
683+
.map(|_| rng.gen_bool(0.5).then(|| rng.gen_bool(0.5)))
684684
.collect();
685685
let b = BooleanArray::from(d.clone());
686686

arrow-array/src/array/run_array.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -662,8 +662,8 @@ where
662662

663663
#[cfg(test)]
664664
mod tests {
665-
use rand::rng;
666665
use rand::seq::SliceRandom;
666+
use rand::thread_rng;
667667
use rand::Rng;
668668

669669
use super::*;
@@ -691,7 +691,7 @@ mod tests {
691691
];
692692
let mut result: Vec<Option<i32>> = Vec::with_capacity(size);
693693
let mut ix = 0;
694-
let mut rng = rng();
694+
let mut rng = thread_rng();
695695
// run length can go up to 8. Cap the max run length for smaller arrays to size / 2.
696696
let max_run_length = 8_usize.min(1_usize.max(size / 2));
697697
while result.len() < size {
@@ -700,7 +700,7 @@ mod tests {
700700
seed.shuffle(&mut rng);
701701
}
702702
// repeat the items between 1 and 8 times. Cap the length for smaller sized arrays
703-
let num = max_run_length.min(rand::rng().random_range(1..=max_run_length));
703+
let num = max_run_length.min(rand::thread_rng().gen_range(1..=max_run_length));
704704
for _ in 0..num {
705705
result.push(seed[ix]);
706706
}
@@ -1000,7 +1000,7 @@ mod tests {
10001000
let mut logical_indices: Vec<u32> = (0_u32..(logical_len as u32)).collect();
10011001
// add same indices once more
10021002
logical_indices.append(&mut logical_indices.clone());
1003-
let mut rng = rng();
1003+
let mut rng = thread_rng();
10041004
logical_indices.shuffle(&mut rng);
10051005

10061006
let physical_indices = run_array.get_physical_indices(&logical_indices).unwrap();
@@ -1036,7 +1036,7 @@ mod tests {
10361036
let mut logical_indices: Vec<u32> = (0_u32..(slice_len as u32)).collect();
10371037
// add same indices once more
10381038
logical_indices.append(&mut logical_indices.clone());
1039-
let mut rng = rng();
1039+
let mut rng = thread_rng();
10401040
logical_indices.shuffle(&mut rng);
10411041

10421042
// test for offset = 0 and slice length = slice_len

arrow-array/src/run_iterator.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ where
172172

173173
#[cfg(test)]
174174
mod tests {
175-
use rand::{rng, seq::SliceRandom, Rng};
175+
use rand::{seq::SliceRandom, thread_rng, Rng};
176176

177177
use crate::{
178178
array::{Int32Array, StringArray},
@@ -200,7 +200,7 @@ mod tests {
200200
];
201201
let mut result: Vec<Option<i32>> = Vec::with_capacity(size);
202202
let mut ix = 0;
203-
let mut rng = rng();
203+
let mut rng = thread_rng();
204204
// run length can go up to 8. Cap the max run length for smaller arrays to size / 2.
205205
let max_run_length = 8_usize.min(1_usize.max(size / 2));
206206
while result.len() < size {
@@ -209,7 +209,7 @@ mod tests {
209209
seed.shuffle(&mut rng);
210210
}
211211
// repeat the items between 1 and 8 times. Cap the length for smaller sized arrays
212-
let num = max_run_length.min(rand::rng().random_range(1..=max_run_length));
212+
let num = max_run_length.min(rand::thread_rng().gen_range(1..=max_run_length));
213213
for _ in 0..num {
214214
result.push(seed[ix]);
215215
}

arrow-avro/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,5 @@ crc = { version = "3.0", optional = true }
5151

5252

5353
[dev-dependencies]
54-
rand = { version = "0.9", default-features = false, features = ["std", "std_rng", "thread_rng"] }
54+
rand = { version = "0.8", default-features = false, features = ["std", "std_rng"] }
55+

arrow-buffer/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ half = { version = "2.1", default-features = false }
4040

4141
[dev-dependencies]
4242
criterion = { version = "0.5", default-features = false }
43-
rand = { version = "0.9", default-features = false, features = ["std", "std_rng", "thread_rng"] }
43+
rand = { version = "0.8", default-features = false, features = ["std", "std_rng"] }
4444

4545
[build-dependencies]
4646

arrow-buffer/benches/i256.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,16 @@ fn criterion_benchmark(c: &mut Criterion) {
4747

4848
let numerators: Vec<_> = (0..SIZE)
4949
.map(|_| {
50-
let high = rng.random_range(1000..i128::MAX);
51-
let low = rng.random();
50+
let high = rng.gen_range(1000..i128::MAX);
51+
let low = rng.gen();
5252
i256::from_parts(low, high)
5353
})
5454
.collect();
5555

5656
let divisors: Vec<_> = numerators
5757
.iter()
5858
.map(|n| {
59-
let quotient = rng.random_range(1..100_i32);
59+
let quotient = rng.gen_range(1..100_i32);
6060
n.wrapping_div(i256::from(quotient))
6161
})
6262
.collect();
@@ -70,7 +70,7 @@ fn criterion_benchmark(c: &mut Criterion) {
7070
});
7171

7272
let divisors: Vec<_> = (0..SIZE)
73-
.map(|_| i256::from(rng.random_range(1..100_i32)))
73+
.map(|_| i256::from(rng.gen_range(1..100_i32)))
7474
.collect();
7575

7676
c.bench_function("i256_div_rem small divisor", |b| {

0 commit comments

Comments
 (0)