feat(import): add Label field support for high-cardinality per-row data
Add support for Label-kind categories to handle high-cardinality per-row fields like descriptions, IDs, and notes. These fields are stored alongside regular categories but default to Axis::None and are excluded from pivot category limits. Changes: - analyzer.rs: Label fields now default to accepted=true - wizard.rs: Collect and process label fields during model building, attaching label values as coordinates for each cell - category.rs: Add Label variant to CategoryKind enum - types.rs: Add add_label_category() method and update category counting to only include Regular-kind categories Co-Authored-By: fiddlerwoaroof/git-smart-commit (unsloth/Qwen3.5-35B-A3B-GGUF:Q5_K_M)
This commit is contained in:
@ -59,11 +59,18 @@ pub enum CategoryKind {
|
||||
VirtualIndex,
|
||||
/// Items are the names of all regular categories + "Value".
|
||||
VirtualDim,
|
||||
/// High-cardinality per-row field (description, id, note). Stored
|
||||
/// alongside the data so it shows up in record/drill views, but
|
||||
/// defaults to Axis::None and is excluded from pivot limits and the
|
||||
/// auto Row/Column axis assignment.
|
||||
Label,
|
||||
}
|
||||
|
||||
impl CategoryKind {
|
||||
pub fn is_virtual(&self) -> bool {
|
||||
!matches!(self, CategoryKind::Regular)
|
||||
/// True for user-managed pivot dimensions (what the category
|
||||
/// count limit and auto axis assignment apply to).
|
||||
pub fn is_regular(&self) -> bool {
|
||||
matches!(self, CategoryKind::Regular)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -63,11 +63,11 @@ impl Model {
|
||||
|
||||
pub fn add_category(&mut self, name: impl Into<String>) -> Result<CategoryId> {
|
||||
let name = name.into();
|
||||
// Virtuals don't count against the regular category limit
|
||||
// Only regular pivot categories count against the limit.
|
||||
let regular_count = self
|
||||
.categories
|
||||
.values()
|
||||
.filter(|c| !c.kind.is_virtual())
|
||||
.filter(|c| c.kind.is_regular())
|
||||
.count();
|
||||
if regular_count >= MAX_CATEGORIES {
|
||||
return Err(anyhow!("Maximum of {MAX_CATEGORIES} categories reached"));
|
||||
@ -86,6 +86,27 @@ impl Model {
|
||||
Ok(id)
|
||||
}
|
||||
|
||||
/// Add a Label-kind category: stored alongside regular categories so
|
||||
/// records views can display it, but default to `Axis::None` and
|
||||
/// excluded from the pivot-category count limit.
|
||||
pub fn add_label_category(&mut self, name: impl Into<String>) -> Result<CategoryId> {
|
||||
use crate::model::category::CategoryKind;
|
||||
use crate::view::Axis;
|
||||
let name = name.into();
|
||||
if self.categories.contains_key(&name) {
|
||||
return Ok(self.categories[&name].id);
|
||||
}
|
||||
let id = self.next_category_id;
|
||||
self.next_category_id += 1;
|
||||
let cat = Category::new(id, name.clone()).with_kind(CategoryKind::Label);
|
||||
self.categories.insert(name.clone(), cat);
|
||||
for view in self.views.values_mut() {
|
||||
view.on_category_added(&name);
|
||||
view.set_axis(&name, Axis::None);
|
||||
}
|
||||
Ok(id)
|
||||
}
|
||||
|
||||
pub fn category_mut(&mut self, name: &str) -> Option<&mut Category> {
|
||||
self.categories.get_mut(name)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user