MCPcopy Create free account
hub / github.com/apache/datafusion / make_data

Function make_data

datafusion/core/benches/data_utils/mod.rs:198–272  ·  view source on GitHub ↗
(
    partition_cnt: i32,
    sample_cnt: i32,
    asc: bool,
    use_view: bool,
)

Source from the content-addressed store, hash-verified

196#[expect(clippy::allow_attributes)] // some issue where expect(dead_code) doesn't fire properly
197#[allow(dead_code)]
198pub(crate) fn make_data(
199 partition_cnt: i32,
200 sample_cnt: i32,
201 asc: bool,
202 use_view: bool,
203) -> Result<(Arc<Schema>, Vec<Vec<RecordBatch>>), DataFusionError> {
204 // constants observed from trace data
205 let simultaneous_group_cnt = 2000;
206 let fitted_shape = 12f64;
207 let fitted_scale = 5f64;
208 let mean = 0.1;
209 let stddev = 1.1;
210 let pareto = Pareto::new(fitted_scale, fitted_shape).unwrap();
211 let normal = Normal::new(mean, stddev).unwrap();
212 let mut rng = rand::rngs::SmallRng::from_seed([0; 32]);
213
214 // populate data
215 let schema = test_schema(use_view);
216 let mut partitions = vec![];
217 let mut cur_time = 16909000000000i64;
218 for _ in 0..partition_cnt {
219 // Choose the appropriate builder based on use_view.
220 let mut id_builder = if use_view {
221 TraceIdBuilder::Utf8View(StringViewBuilder::new())
222 } else {
223 TraceIdBuilder::Utf8(StringBuilder::new())
224 };
225
226 let mut ts_builder = Int64Builder::new();
227 let gen_id = |rng: &mut rand::rngs::SmallRng| {
228 rng.random::<[u8; 16]>()
229 .iter()
230 .fold(String::new(), |mut output, b| {
231 let _ = write!(output, "{b:02X}");
232 output
233 })
234 };
235 let gen_sample_cnt =
236 |mut rng: &mut rand::rngs::SmallRng| pareto.sample(&mut rng).ceil() as u32;
237 let mut group_ids = (0..simultaneous_group_cnt)
238 .map(|_| gen_id(&mut rng))
239 .collect::<Vec<_>>();
240 let mut group_sample_cnts = (0..simultaneous_group_cnt)
241 .map(|_| gen_sample_cnt(&mut rng))
242 .collect::<Vec<_>>();
243 for _ in 0..sample_cnt {
244 let random_index = rng.random_range(0..simultaneous_group_cnt);
245 let trace_id = &mut group_ids[random_index];
246 let sample_cnt = &mut group_sample_cnts[random_index];
247 *sample_cnt -= 1;
248 if *sample_cnt == 0 {
249 *trace_id = gen_id(&mut rng);
250 *sample_cnt = gen_sample_cnt(&mut rng);
251 }
252
253 id_builder.append_value(trace_id);
254 ts_builder.append_value(cur_time);
255

Callers 3

create_contextFunction · 0.85
run_limit_fuzz_testFunction · 0.85

Calls 9

newFunction · 0.85
test_schemaFunction · 0.70
iterMethod · 0.45
sampleMethod · 0.45
mapMethod · 0.45
append_valueMethod · 0.45
finishMethod · 0.45
cloneMethod · 0.45
pushMethod · 0.45

Tested by 1

run_limit_fuzz_testFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…