fix: make the order of sort key deterministic
parent
9ffaf863fa
commit
b4d86dcb7d
|
@ -147,7 +147,7 @@ impl<'a> SortKey<'a> {
|
|||
self.columns.is_empty()
|
||||
}
|
||||
|
||||
/// Returns sort keys of the given columns
|
||||
/// Returns a subset of the sort key that includes only the given columns
|
||||
pub fn selected_sort_key(&self, select_keys: Vec<&str>) -> SortKey<'a> {
|
||||
let keys: IndexMap<&'a str, SortOptions> = self
|
||||
.columns
|
||||
|
|
|
@ -211,13 +211,10 @@ pub fn compute_sort_key<'a>(summaries: impl Iterator<Item = &'a TableSummary>) -
|
|||
}
|
||||
|
||||
trace!(cardinalities=?cardinalities, "cardinalities of of columns to compute sort key");
|
||||
print!(
|
||||
"cardinalities of of columns to compute sort key: {:#?}",
|
||||
cardinalities
|
||||
);
|
||||
|
||||
let mut cardinalities: Vec<_> = cardinalities.into_iter().collect();
|
||||
cardinalities.sort_by_key(|x| x.1);
|
||||
// Sort by (cardinality, column_name) to have deterministic order if same cardinality
|
||||
cardinalities.sort_by_key(|x| (x.1, x.0));
|
||||
|
||||
let mut key = SortKey::with_capacity(cardinalities.len() + 1);
|
||||
for (col, _) in cardinalities {
|
||||
|
@ -226,7 +223,6 @@ pub fn compute_sort_key<'a>(summaries: impl Iterator<Item = &'a TableSummary>) -
|
|||
key.push(TIME_COLUMN_NAME, Default::default());
|
||||
|
||||
trace!(computed_sort_key=?key, "Value of sort key from compute_sort_key");
|
||||
println!("Value of sort key from compute_sort_key: {:#?}", key);
|
||||
|
||||
key
|
||||
}
|
||||
|
|
|
@ -1123,7 +1123,7 @@ mod tests {
|
|||
async fn test_query_json() {
|
||||
let (client, server_url) = setup_test_data().await;
|
||||
|
||||
// send a second line of data to demontrate how that works
|
||||
// send a second line of data to demonstrate how that works
|
||||
let lp_data =
|
||||
"h2o_temperature,location=Boston,state=MA surface_degrees=50.2 1617286224000000000";
|
||||
|
||||
|
|
Loading…
Reference in New Issue