(self)
| 311 | } |
| 312 | impl RunOpt { |
| 313 | pub async fn run(self) -> Result<()> { |
| 314 | println!( |
| 315 | "Running dictionary encoding benchmarks with the following options: {self:#?}\n" |
| 316 | ); |
| 317 | |
| 318 | let query_range = match self.query { |
| 319 | Some(query_id) => { |
| 320 | if query_id >= 1 && query_id <= DICTIONARY_QUERIES.len() { |
| 321 | query_id..=query_id |
| 322 | } else { |
| 323 | return exec_err!( |
| 324 | "Query {query_id} not found. Available queries: 1 to {}", |
| 325 | DICTIONARY_QUERIES.len() |
| 326 | ); |
| 327 | } |
| 328 | } |
| 329 | None => 1..=DICTIONARY_QUERIES.len(), |
| 330 | }; |
| 331 | |
| 332 | let config = self.common.config()?; |
| 333 | let rt = self.common.build_runtime()?; |
| 334 | let ctx = SessionContext::new_with_config_rt(config, rt); |
| 335 | let mut benchmark_run = BenchmarkRun::new(); |
| 336 | |
| 337 | for query_id in query_range { |
| 338 | let query = &DICTIONARY_QUERIES[query_id - 1]; |
| 339 | benchmark_run.start_new_case(query.name); |
| 340 | |
| 341 | let query_run = self.benchmark_query(query, &ctx).await; |
| 342 | match query_run { |
| 343 | Ok(query_results) => { |
| 344 | for iter in query_results { |
| 345 | benchmark_run.write_iter(iter.elapsed, iter.row_count); |
| 346 | } |
| 347 | } |
| 348 | Err(e) => { |
| 349 | return Err(DataFusionError::Context( |
| 350 | format!("Dictionary benchmark '{}' failed:", query.name), |
| 351 | Box::new(e), |
| 352 | )); |
| 353 | } |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | benchmark_run.maybe_write_json(self.output_path.as_ref())?; |
| 358 | Ok(()) |
| 359 | } |
| 360 | |
| 361 | async fn benchmark_query( |
| 362 | &self, |
nothing calls this directly
no test coverage detected