pub struct Indexer { /* private fields */ }Expand description
Owning handle over a SQLite connection to a logdive index.
Implementations§
Source§impl Indexer
impl Indexer
Sourcepub fn open(path: &Path) -> Result<Self>
pub fn open(path: &Path) -> Result<Self>
Open (or create) a logdive index at path.
Creates the parent directory if it does not already exist, opens the SQLite database, and runs idempotent schema migrations.
Sourcepub fn open_in_memory() -> Result<Self>
pub fn open_in_memory() -> Result<Self>
Open an in-memory index. Used by tests; also usable for one-shot scenarios that don’t need persistence.
Sourcepub fn open_read_only(path: &Path) -> Result<Self>
pub fn open_read_only(path: &Path) -> Result<Self>
Open an existing logdive index at path in read-only mode.
Unlike Indexer::open, this method:
- Does not create the database file if it is missing (the
SQLITE_OPEN_READ_ONLYflag fails rather than creates), - Does not create the parent directory,
- Does not run schema migrations — the caller is promising
that
pathalready points at a valid logdive index.
Enforcement of read-only semantics is at the SQLite level: any attempted write through the returned connection raises a runtime error. This is defense-in-depth for the HTTP API (milestone 8), whose surface is exclusively read.
Sourcepub fn connection(&self) -> &Connection
pub fn connection(&self) -> &Connection
Borrow the underlying connection.
Exposed so the query executor can run reads without an extra
abstraction layer. Read-only borrow keeps ingestion and querying
from contending over &mut.
Sourcepub fn insert_batch(&mut self, entries: &[LogEntry]) -> Result<InsertStats>
pub fn insert_batch(&mut self, entries: &[LogEntry]) -> Result<InsertStats>
Insert a slice of entries into the index, chunking internally into
transactions of BATCH_SIZE rows each.
Returns aggregate stats across all chunks. Entry ordering within the index is not guaranteed.
Sourcepub fn stats(&self) -> Result<Stats>
pub fn stats(&self) -> Result<Stats>
Read aggregate metadata about the index.
Runs three read-only queries:
COUNT(*)for the row count,MIN(timestamp), MAX(timestamp)for the time range,SELECT DISTINCT tag ... ORDER BY tagfor the tag list.
On an empty database, returns entries = 0, both timestamp bounds
as None, and an empty tags vector — not an error.