Skip to main content

incremental_apply

Function incremental_apply 

Source
pub fn incremental_apply(
    events_dir: &Path,
    db_path: &Path,
    force_full: bool,
) -> Result<ApplyReport>
Expand description

Apply only events newer than the high-water mark to the projection.

Steps:

  1. Open (or try to open) the projection database.
  2. Read the projection cursor (byte offset + last event hash).
  3. Run safety checks — schema version, cursor validity, manifest integrity.
  4. If any check fails, fall back to a full rebuild.
  5. Otherwise, read shard content from the cursor byte offset onward.
  6. Parse and project only the new events.
  7. Update the cursor.

§Arguments

  • events_dir — Path to .bones/events/ (the shard directory)
  • db_path — Path to .bones/bones.db (the SQLite projection file)
  • force_full — If true, skip incremental and always do a full rebuild (bn admin rebuild --full).

§Errors

Returns an error if reading shards, parsing events, or projection fails.