use crate::db::{index::IndexKey, key_taxonomy::PrimaryKeyValue};
#[derive(Debug)]
pub(in crate::db) struct IndexMutationPlan {
pub(in crate::db) groups: Vec<IndexDeltaGroup>,
}
impl IndexMutationPlan {
pub(in crate::db) const fn new(groups: Vec<IndexDeltaGroup>) -> Self {
Self { groups }
}
}
#[derive(Debug)]
pub(in crate::db) struct IndexDeltaGroup {
pub(in crate::db) index_store: String,
pub(in crate::db) deltas: Vec<IndexDelta>,
}
impl IndexDeltaGroup {
#[must_use]
pub(in crate::db) fn new(index_store: &str, deltas: Vec<IndexDelta>) -> Self {
Self {
index_store: index_store.to_string(),
deltas,
}
}
}
#[derive(Debug)]
pub(in crate::db) enum IndexDelta {
Remove(IndexMembershipDelta),
Insert(IndexMembershipDelta),
}
impl IndexDelta {
#[must_use]
pub(in crate::db) const fn remove(key: IndexKey, primary_key: &PrimaryKeyValue) -> Self {
Self::Remove(IndexMembershipDelta {
key,
primary_key: *primary_key,
})
}
#[must_use]
pub(in crate::db) const fn insert(key: IndexKey, primary_key: &PrimaryKeyValue) -> Self {
Self::Insert(IndexMembershipDelta {
key,
primary_key: *primary_key,
})
}
}
#[derive(Debug)]
pub(in crate::db) struct IndexMembershipDelta {
pub(in crate::db) key: IndexKey,
pub(in crate::db) primary_key: PrimaryKeyValue,
}