Skip to content

Commit f1a6fac

Browse files
committed
perf(cubesql): Avoid allocations in sql_generator_by_alias_to_cube
1 parent ff96a50 commit f1a6fac

File tree

1 file changed

+7
-9
lines changed
  • rust/cubesql/cubesql/src/transport

1 file changed

+7
-9
lines changed

rust/cubesql/cubesql/src/transport/ctx.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,15 @@ impl MetaContext {
7979
&self,
8080
alias_to_cube: &Vec<(String, String)>,
8181
) -> Option<Arc<dyn SqlGenerator + Send + Sync>> {
82-
let data_sources = alias_to_cube
82+
let data_source = alias_to_cube
8383
.iter()
8484
.map(|(_, c)| self.cube_to_data_source.get(c))
85-
.unique()
86-
.collect::<Option<Vec<_>>>()?;
87-
if data_sources.len() != 1 {
88-
return None;
89-
}
90-
self.data_source_to_sql_generator
91-
.get(data_sources[0].as_str())
92-
.cloned()
85+
.all_equal_value();
86+
87+
// Don't care for non-equal data sources, nor for missing cube_to_data_source keys
88+
let data_source = data_source.ok()??;
89+
90+
self.data_source_to_sql_generator.get(data_source).cloned()
9391
}
9492

9593
pub fn find_cube_with_name(&self, name: &str) -> Option<&CubeMeta> {

0 commit comments

Comments
 (0)