Revert "test(engine): retain static schema names across shared factor rows"

This reverts commit ce0dc0a106f0a98230bb9c428537ec086b968273.
This commit is contained in:
boris
2026-09-13 14:16:06 +08:00
committed by boris
parent 0a6fab9038
commit be171683c9
2 changed files with 3 additions and 23 deletions
-13
View File
@@ -436,19 +436,6 @@ mod tests {
assert!(rows.iter().all(|row| matches!(row.storage, Storage::Owned(_)))); assert!(rows.iter().all(|row| matches!(row.storage, Storage::Owned(_))));
} }
#[test]
fn shared_schema_borrows_a_static_key_even_after_a_dynamic_equal_key() {
const KEY: &str = "a_shared_factor_name_longer_than_inline_storage";
let mut rows = (0..64).map(|index| NumericFactorMap::from([
(if index == 0 { Cow::Owned(KEY.to_string()) } else { Cow::Borrowed(KEY) }, index as f64),
(Cow::Borrowed("another"), 2.0),
])).collect::<Vec<_>>();
assert_eq!(NumericFactorMap::share_rows(rows.iter_mut()), rows.len());
for row in &rows {
assert_eq!(row.keys().find(|key| key.as_str() == KEY).unwrap().as_static_str(), Some(KEY));
}
}
#[test] #[test]
fn compact_keys_inline_dynamic_names_and_keep_long_static_storage() { fn compact_keys_inline_dynamic_names_and_keep_long_static_storage() {
const LONG: &str = "a_long_static_factor_identifier_that_must_remain_borrowed"; const LONG: &str = "a_long_static_factor_identifier_that_must_remain_borrowed";
@@ -1,4 +1,4 @@
use std::collections::BTreeMap; use std::collections::BTreeSet;
use std::sync::Arc; use std::sync::Arc;
use compact_str::CompactString; use compact_str::CompactString;
@@ -103,15 +103,8 @@ pub(super) fn share<'a>(rows: impl IntoIterator<Item = &'a mut NumericFactorMap>
let Storage::Owned(entries) = &row.storage else { return None }; let Storage::Owned(entries) = &row.storage else { return None };
sum.checked_add(entries.capacity().checked_mul(std::mem::size_of::<(CompactString, f64)>())?) sum.checked_add(entries.capacity().checked_mul(std::mem::size_of::<(CompactString, f64)>())?)
}) else { return 0 }; }) else { return 0 };
let mut names = BTreeMap::<&str, &CompactString>::new(); let fields = rows.iter().flat_map(|row| row.keys()).collect::<BTreeSet<_>>()
for name in rows.iter().flat_map(|row| row.keys()) { .into_iter().cloned().collect::<Vec<_>>();
names.entry(name.as_str()).and_modify(|existing| {
if existing.as_static_str().is_none() && name.as_static_str().is_some() {
*existing = name;
}
}).or_insert(name);
}
let fields = names.into_values().cloned().collect::<Vec<_>>();
let Some(cells) = rows.len().checked_mul(fields.len()) else { return 0 }; let Some(cells) = rows.len().checked_mul(fields.len()) else { return 0 };
if cells == 0 { if cells == 0 {
return 0; return 0;