This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Zebo is a Rust library for efficient filesystem-based document storage. It groups documents into fixed-size pages with configurable constraints on both document count per page and page size. The library is designed for high-performance data storage and retrieval with minimal memory overhead.
- Zebo: Main struct with generic const parameters
MAX_DOC_PER_PAGE,PAGE_SIZE, and document ID type - ZeboPage: Represents a single page file containing multiple documents with binary layout
- ZeboIndex: Manages page mapping and document location tracking
- DocumentId trait: Abstraction for document identifiers (u32, u64)
- Each page is a binary file (
page_N.zebo) with structured header and document data - Index directory contains
index.indexfile mapping document IDs to pages - Page headers contain document count, limits, offsets, and document index entries
- Documents are stored contiguously after the page header
- Pages automatically created when current page exceeds document count or size limits
- Page size limit can be exceeded for single large documents
- Document deletion marks entries with sentinel values (u64::MAX, u32::MAX)
- Batch insertion API for improved performance with multiple documents
# Check code compilation
cargo check
# Run all tests
cargo test
# Format code (must pass in CI)
cargo fmt
# Run linter (must pass in CI)
cargo clippy
# Build release
cargo build --release# Simple usage example
cargo run --example simple
# Performance testing example
cargo run --example perf
# Reload functionality example
cargo run --example reload- Comprehensive unit tests in
src/lib.rscovering single and batch operations - Tests for page management, document retrieval, deletion, and persistence
- Page-level internal tests in
src/page.rsfor binary format validation - Tests use temporary directories with unique names to avoid conflicts
src/lib.rs: Main API, Zebo struct, iterators, and core functionalitysrc/page.rs: Binary page format, document storage, and page operationssrc/index.rs: Page indexing and document-to-page mappingsrc/error.rs: Error types and Result type aliasexamples/: Usage examples demonstrating different features
The main Zebo struct uses const generics:
MAX_DOC_PER_PAGE: Maximum documents per page (typically 10-1M)PAGE_SIZE: Target page size in bytes (can be exceeded for large documents)DocId: Document identifier type implementing DocumentId trait
add_documents(): Sequential document insertionadd_documents_batch(): Optimized batch insertion with fewer disk writesget_documents(): Retrieve documents by ID (returns iterator)remove_documents(): Mark documents as deleted with optional data cleaning
- Zebo instances can be recreated pointing to existing directories
- Index and pages are automatically loaded from filesystem
- Current page state is preserved across instance recreation