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

Function main

benchmarks/src/bin/gen_wide_data.rs:252–351  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

250}
251
252fn main() -> Result<()> {
253 let cli = Cli::parse();
254 if cli.width_factor == 0 {
255 return Err(exec_datafusion_err!("--width-factor must be >= 1"));
256 }
257 if cli.num_files == 0 {
258 return Err(exec_datafusion_err!("--num-files must be >= 1"));
259 }
260 if cli.rows_per_file == 0 {
261 return Err(exec_datafusion_err!("--rows-per-file must be >= 1"));
262 }
263 if cli.batch_size == 0 {
264 return Err(exec_datafusion_err!("--batch-size must be >= 1"));
265 }
266
267 let raw_schema = base_schema();
268 let wide_schema = widen_schema(&raw_schema, cli.width_factor);
269 let cap_rows = cli.rows_per_file.saturating_mul(cli.num_files);
270
271 println!(
272 "Synthesizing: {} base cols × {} factor = {} cols × {} files of {} rows each (total {} rows, ZSTD(1), 1 row group/file).",
273 raw_schema.fields().len(),
274 cli.width_factor,
275 wide_schema.fields().len(),
276 cli.num_files,
277 cli.rows_per_file,
278 cap_rows,
279 );
280
281 std::fs::create_dir_all(&cli.dst_dir)
282 .map_err(|e| exec_datafusion_err!("creating {}: {e}", cli.dst_dir.display()))?;
283
284 let mut file_idx: usize = 0;
285 let mut writer: Option<ArrowWriter<File>> = None;
286 let mut rows_in_current: usize = 0;
287 let mut total_written: usize = 0;
288 let mut row_cursor: usize = 0;
289
290 'outer: while total_written < cap_rows {
291 let batch_n = cli.batch_size.min(cap_rows - total_written);
292 let base_batch = synthesize_batch(row_cursor, batch_n, &raw_schema)?;
293 let wide_batch = widen_batch(&base_batch, &wide_schema, cli.width_factor)?;
294 row_cursor += batch_n;
295
296 let mut remaining = wide_batch;
297 while remaining.num_rows() > 0 {
298 if writer.is_none() {
299 if file_idx >= cli.num_files {
300 break 'outer;
301 }
302 file_idx += 1;
303 let path = if cli.num_files == 1 {
304 cli.dst_dir.join("events.parquet")
305 } else {
306 cli.dst_dir.join(format!("events_{file_idx:04}.parquet"))
307 };
308 writer = Some(open_writer(
309 &path,

Callers

nothing calls this directly

Calls 13

base_schemaFunction · 0.85
widen_schemaFunction · 0.85
synthesize_batchFunction · 0.85
widen_batchFunction · 0.85
open_writerFunction · 0.85
is_noneMethod · 0.80
sliceMethod · 0.80
closeMethod · 0.80
minMethod · 0.45
joinMethod · 0.45
maxMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…