zeppelin-embed 0.8.0

In-process vector, lexical, and hybrid search for macOS and Apple silicon
Documentation
//! Bounded public graph maintenance and its write-path policy.
use super::GraphStoreError;
use crate::lifecycle::QueryControl;
use crate::property_graph::GraphGeneration;

/// Automatic inventory-fold policy for this open writer (not persisted).
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct GraphMaintenancePolicy {
    /// Fold a bounded inventory prefix before a write once the byte threshold
    /// or internal 32-publication cadence is reached. Full reclamation runs
    /// through explicit maintenance or once on a reclaim-debt refusal.
    pub automatic: bool,
    /// Committed artifact bytes between triggers; at least 1 MiB.
    pub reclaim_after_bytes: u64,
}
impl Default for GraphMaintenancePolicy {
    fn default() -> Self {
        Self {
            automatic: true,
            reclaim_after_bytes: 64 * 1024 * 1024,
        }
    }
}

/// Work performed by one maintenance step, or accumulated over one cycle.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct GraphMaintenanceReport {
    /// Last published generation.
    pub generation: GraphGeneration,
    /// Physical references replaced.
    pub replaced_physical_refs: u64,
    /// Artifact bytes written.
    pub new_pack_bytes: u64,
    /// Live bytes copied from selected packs.
    pub relocated_bytes: u64,
    /// Packs selected for draining.
    pub drained_packs: u32,
    /// Bytes covered by reclamation.
    pub reclaimed_bytes: u64,
    /// Bytes actually removed.
    pub removed_bytes: u64,
    /// This cycle finished; no reclaim intent, completion or checkpoint retry remains.
    pub cycle_complete: bool,
}

impl crate::lifecycle::Store {
    /// Sets this writer's policy.
    /// # Errors
    /// Refuses read-only stores and thresholds below 1 MiB.
    pub fn set_graph_maintenance_policy(
        &self,
        policy: GraphMaintenancePolicy,
    ) -> Result<(), GraphStoreError> {
        self.set_native_graph_maintenance_policy(policy)
            .map_err(Into::into)
    }
    /// Performs one bounded maintenance step.
    /// # Errors
    /// Returns the classified admission, preparation or storage failure.
    pub fn graph_maintain_step(
        &self,
        control: &QueryControl,
    ) -> Result<GraphMaintenanceReport, GraphStoreError> {
        self.maintain_native_graph_step(control).map_err(Into::into)
    }
    /// Runs at most four steps, stopping when the cycle completes.
    /// If `cycle_complete` is false, progress and reclaim debt are retained;
    /// call again to continue the cycle.
    /// # Errors
    /// Returns the classified admission, preparation or storage failure.
    pub fn graph_maintain_cycle(
        &self,
        control: &QueryControl,
    ) -> Result<GraphMaintenanceReport, GraphStoreError> {
        self.maintain_native_graph_cycle(control)
            .map_err(Into::into)
    }
}