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

Method discover

benchmarks/src/benchmark_runner/suite.rs:339–390  ·  view source on GitHub ↗

Discovers all suite files below the SQL benchmark root. Each direct child directory is searched for `.suite` files. Suite names must be unique across the registry so command selectors are unambiguous.

(root: impl AsRef<Path>)

Source from the content-addressed store, hash-verified

337 /// must be unique across the registry so command selectors are
338 /// unambiguous.
339 pub fn discover(root: impl AsRef<Path>) -> Result<Self> {
340 let root = root.as_ref();
341 let mut suites = Vec::new();
342 let mut suite_names = HashSet::new();
343
344 for entry in read_dir_entries(root, "benchmark suite root")? {
345 if !entry
346 .file_type()
347 .map_err(|e| {
348 DataFusionError::External(
349 format!(
350 "failed to read benchmark suite entry type {}: {e}",
351 entry.path().display()
352 )
353 .into(),
354 )
355 })?
356 .is_dir()
357 {
358 continue;
359 }
360
361 let mut suite_files = Vec::new();
362 let suite_dir = entry.path();
363 for suite_entry in read_dir_entries(&suite_dir, "benchmark suite directory")?
364 {
365 let path = suite_entry.path();
366 if path
367 .extension()
368 .is_some_and(|extension| extension == "suite")
369 {
370 suite_files.push(path);
371 }
372 }
373 suite_files.sort();
374
375 for suite_file in suite_files {
376 let suite = SuiteConfig::from_file(suite_file)?;
377 if !suite_names.insert(suite.name.clone()) {
378 return Err(DataFusionError::Configuration(format!(
379 "duplicate suite name '{}'",
380 suite.name
381 )));
382 }
383 suites.push(suite);
384 }
385 }
386
387 suites.sort_by(|left, right| left.name.cmp(&right.name));
388
389 Ok(Self { suites })
390 }
391
392 /// Returns discovered suites sorted by selector name.
393 pub fn suites(&self) -> &[SuiteConfig] {

Callers

nothing calls this directly

Calls 13

newFunction · 0.85
read_dir_entriesFunction · 0.85
extensionMethod · 0.80
as_refMethod · 0.45
file_typeMethod · 0.45
intoMethod · 0.45
pathMethod · 0.45
pushMethod · 0.45
sortMethod · 0.45
insertMethod · 0.45
cloneMethod · 0.45
sort_byMethod · 0.45

Tested by

no test coverage detected