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

Method scan_query_dir

benchmarks/src/benchmark_runner/suite.rs:181–220  ·  view source on GitHub ↗

Recursively scans a directory and appends valid query benchmark files to the provided collection.

(&self, dir: &Path, queries: &mut Vec<SuiteQuery>)

Source from the content-addressed store, hash-verified

179 /// Recursively scans a directory and appends valid query benchmark files to
180 /// the provided collection.
181 fn scan_query_dir(&self, dir: &Path, queries: &mut Vec<SuiteQuery>) -> Result<()> {
182 let mut entries = read_dir_entries(dir, "benchmark query directory")?;
183 entries.sort_by_key(|entry| entry.file_name());
184
185 for entry in entries {
186 let path = entry.path();
187 let file_type = entry.file_type().map_err(|e| {
188 DataFusionError::External(
189 format!(
190 "failed to read benchmark query entry type {}: {e}",
191 path.display()
192 )
193 .into(),
194 )
195 })?;
196
197 if file_type.is_dir() {
198 self.scan_query_dir(&path, queries)?;
199 continue;
200 }
201
202 if path
203 .extension()
204 .is_none_or(|extension| extension != "benchmark")
205 {
206 continue;
207 }
208
209 let file_name = entry.file_name().to_string_lossy().into_owned();
210 if let Some(id) = parse_query_file_name(&file_name) {
211 queries.push(SuiteQuery {
212 id,
213 file_name,
214 path,
215 });
216 }
217 }
218
219 Ok(())
220 }
221
222 /// Validates suite metadata that cannot be enforced by TOML deserialization.
223 fn validate(&self) -> Result<()> {

Callers 1

scan_queriesMethod · 0.80

Calls 7

read_dir_entriesFunction · 0.85
parse_query_file_nameFunction · 0.85
extensionMethod · 0.80
pathMethod · 0.45
file_typeMethod · 0.45
intoMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected