Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

palimpsest-index

Temporal graph index: URL x time x hash x context. Two backends — in-memory (BTreeMap) and SQLite (WAL mode).

IndexEntry

#![allow(unused)]
fn main() {
pub struct IndexEntry {
    pub url: Url,
    pub captured_at: CaptureInstant,
    pub content_hash: ContentHash,
    pub crawl_context: CrawlContextId,
}

impl IndexEntry {
    pub fn new(url: Url, captured_at: CaptureInstant, content_hash: ContentHash, crawl_context: CrawlContextId) -> Self;
}
}

Implements Ord: ordered by captured_at, then URL string.

InMemoryIndex

#![allow(unused)]
fn main() {
impl InMemoryIndex {
    pub fn new() -> Self;
    pub fn insert(&mut self, entry: IndexEntry);
    pub fn query(&self, query: &IndexQuery) -> Vec<IndexEntry>;
    pub fn history(&self, url: &Url) -> Vec<IndexEntry>;
}
}

SqliteIndex

#![allow(unused)]
fn main() {
impl SqliteIndex {
    pub fn open(path: &Path) -> Result<Self, IndexError>;
    pub fn insert(&mut self, entry: IndexEntry) -> Result<(), IndexError>;
    pub fn query(&self, query: &IndexQuery) -> Result<Vec<IndexEntry>, IndexError>;
    pub fn history(&self, url: &Url) -> Result<Vec<IndexEntry>, IndexError>;
}
}

Uses WAL mode for concurrent reads. Parameterized queries. UNIQUE constraint on (url, wall_time, content_hash).

IndexQuery

Multi-dimensional filtering: by URL, time range, content hash, or crawl context. Results ordered by captured_at ascending.

Key Invariant

The index is a graph, not a lookup table. It captures the temporal dimension of the web — when content appeared, changed, and disappeared.