store: remove nodes and uuid_to_key HashMaps
All node access now goes through index → capnp: - scoring.rs: consolidation_priority, replay_queue, consolidation_plan - admin.rs: cmd_init, cmd_fsck, cmd_dedup - engine.rs: run_generator, eval_filter, run_transform - parser.rs: resolve_field, execute_query Added Store::remove_from_index() for dedup cleanup. The relations Vec remains for now (used for graph building). Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
af3e41f1d9
commit
5877fd857a
5 changed files with 65 additions and 47 deletions
|
|
@ -32,7 +32,6 @@ pub use ops::current_provenance;
|
|||
|
||||
use crate::graph::{self, Graph};
|
||||
|
||||
use std::collections::HashMap;
|
||||
use anyhow::{bail, Result};
|
||||
|
||||
/// Strip .md suffix from a key, handling both bare keys and section keys.
|
||||
|
|
@ -48,8 +47,6 @@ pub fn strip_md_suffix(key: &str) -> String {
|
|||
|
||||
// The full in-memory store
|
||||
pub struct Store {
|
||||
pub nodes: HashMap<String, Node>, // key → latest node
|
||||
pub uuid_to_key: HashMap<[u8; 16], String>, // uuid → key (rebuilt from nodes)
|
||||
pub relations: Vec<Relation>, // all active relations
|
||||
/// Log sizes at load time — used for staleness detection.
|
||||
pub(crate) loaded_nodes_size: u64,
|
||||
|
|
@ -61,8 +58,6 @@ pub struct Store {
|
|||
impl Default for Store {
|
||||
fn default() -> Self {
|
||||
Store {
|
||||
nodes: HashMap::new(),
|
||||
uuid_to_key: HashMap::new(),
|
||||
relations: Vec::new(),
|
||||
loaded_nodes_size: 0,
|
||||
loaded_rels_size: 0,
|
||||
|
|
@ -101,6 +96,14 @@ impl Store {
|
|||
index::all_keys(db)
|
||||
}
|
||||
|
||||
/// Remove a node from the index (used after appending a tombstone).
|
||||
pub fn remove_from_index(&self, key: &str, uuid: &[u8; 16]) -> Result<()> {
|
||||
if let Some(db) = self.db.as_ref() {
|
||||
index::remove_node(db, key, uuid)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn resolve_key(&self, target: &str) -> Result<String> {
|
||||
// Strip .md suffix if present — keys no longer use it
|
||||
let bare = strip_md_suffix(target);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue