Skip to content

Commit 4a1eec3

Browse files
committed
remove unnecessary type para in PrimitiveArrayGenerator.
1 parent 4622497 commit 4a1eec3

File tree

2 files changed

+11
-21
lines changed

2 files changed

+11
-21
lines changed

datafusion/core/tests/fuzz_cases/aggregation_fuzzer/data_generator.rs

+2-14
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ macro_rules! generate_string_array {
226226
}
227227

228228
macro_rules! generate_primitive_array {
229-
($SELF:ident, $NUM_ROWS:ident, $BATCH_GEN_RNG:ident, $ARRAY_GEN_RNG:ident, $DATA_TYPE:ident, $ARROW_TYPE:ident) => {
229+
($SELF:ident, $NUM_ROWS:ident, $BATCH_GEN_RNG:ident, $ARRAY_GEN_RNG:ident, $ARROW_TYPE:ident) => {
230230
paste::paste! {{
231231
let null_pct_idx = $BATCH_GEN_RNG.gen_range(0..$SELF.candidate_null_pcts.len());
232232
let null_pct = $SELF.candidate_null_pcts[null_pct_idx];
@@ -243,7 +243,7 @@ macro_rules! generate_primitive_array {
243243
rng: $ARRAY_GEN_RNG,
244244
};
245245

246-
generator.gen_data::<$DATA_TYPE, $ARROW_TYPE>()
246+
generator.gen_data::<$ARROW_TYPE>()
247247
}}}
248248
}
249249

@@ -301,7 +301,6 @@ impl RecordBatchGenerator {
301301
num_rows,
302302
batch_gen_rng,
303303
array_gen_rng,
304-
i8,
305304
Int8Type
306305
)
307306
}
@@ -311,7 +310,6 @@ impl RecordBatchGenerator {
311310
num_rows,
312311
batch_gen_rng,
313312
array_gen_rng,
314-
i16,
315313
Int16Type
316314
)
317315
}
@@ -321,7 +319,6 @@ impl RecordBatchGenerator {
321319
num_rows,
322320
batch_gen_rng,
323321
array_gen_rng,
324-
i32,
325322
Int32Type
326323
)
327324
}
@@ -331,7 +328,6 @@ impl RecordBatchGenerator {
331328
num_rows,
332329
batch_gen_rng,
333330
array_gen_rng,
334-
i64,
335331
Int64Type
336332
)
337333
}
@@ -341,7 +337,6 @@ impl RecordBatchGenerator {
341337
num_rows,
342338
batch_gen_rng,
343339
array_gen_rng,
344-
u8,
345340
UInt8Type
346341
)
347342
}
@@ -351,7 +346,6 @@ impl RecordBatchGenerator {
351346
num_rows,
352347
batch_gen_rng,
353348
array_gen_rng,
354-
u16,
355349
UInt16Type
356350
)
357351
}
@@ -361,7 +355,6 @@ impl RecordBatchGenerator {
361355
num_rows,
362356
batch_gen_rng,
363357
array_gen_rng,
364-
u32,
365358
UInt32Type
366359
)
367360
}
@@ -371,7 +364,6 @@ impl RecordBatchGenerator {
371364
num_rows,
372365
batch_gen_rng,
373366
array_gen_rng,
374-
u64,
375367
UInt64Type
376368
)
377369
}
@@ -381,7 +373,6 @@ impl RecordBatchGenerator {
381373
num_rows,
382374
batch_gen_rng,
383375
array_gen_rng,
384-
f32,
385376
Float32Type
386377
)
387378
}
@@ -391,7 +382,6 @@ impl RecordBatchGenerator {
391382
num_rows,
392383
batch_gen_rng,
393384
array_gen_rng,
394-
f64,
395385
Float64Type
396386
)
397387
}
@@ -401,7 +391,6 @@ impl RecordBatchGenerator {
401391
num_rows,
402392
batch_gen_rng,
403393
array_gen_rng,
404-
i32,
405394
Date32Type
406395
)
407396
}
@@ -411,7 +400,6 @@ impl RecordBatchGenerator {
411400
num_rows,
412401
batch_gen_rng,
413402
array_gen_rng,
414-
i64,
415403
Date64Type
416404
)
417405
}

test-utils/src/array_gen/primitive.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,10 @@ pub struct PrimitiveArrayGenerator {
3636

3737
// TODO: support generating more primitive arrays
3838
impl PrimitiveArrayGenerator {
39-
pub fn gen_data<N, A>(&mut self) -> ArrayRef
39+
pub fn gen_data<A>(&mut self) -> ArrayRef
4040
where
41-
A: ArrowPrimitiveType<Native = N>,
42-
N: std::marker::Sync + std::marker::Send,
43-
Standard: Distribution<N>,
41+
A: ArrowPrimitiveType,
42+
Standard: Distribution<<A as ArrowPrimitiveType>::Native>,
4443
{
4544
// table of primitives from which to draw
4645
let distinct_primitives: PrimitiveArray<A> = (0..self.num_distinct_primitives)
@@ -56,16 +55,19 @@ impl PrimitiveArrayGenerator {
5655
| DataType::UInt64
5756
| DataType::Float32
5857
| DataType::Float64
59-
| DataType::Date32 => self.rng.gen::<N>(),
58+
| DataType::Date32 => self.rng.gen::<A::Native>(),
6059

6160
DataType::Date64 => {
6261
// TODO: constrain this range to valid dates if necessary
6362
let date_value = self.rng.gen_range(i64::MIN..=i64::MAX);
6463
let millis_per_day: i64 = 86_400_000;
6564
let adjusted_value = date_value - (date_value % millis_per_day);
66-
// SAFETY: here we can convert i64 to N safely since we determine that the type N is i64
65+
// SAFETY: here we can convert i64 to A::Native safely since we determine that
66+
// the type A::Native is i64
6767
unsafe {
68-
std::ptr::read(&adjusted_value as *const i64 as *const N)
68+
std::ptr::read(
69+
&adjusted_value as *const i64 as *const A::Native,
70+
)
6971
}
7072
}
7173

0 commit comments

Comments
 (0)