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

Integration Cookbook: Practical Recipes for Production

This directory contains self-contained, production-tested integration patterns and recipes for embedding learned_index_lab (PgmIndex, MultilevelPgmIndex, and EytzingerSearch) into real-world storage engines, embedded databases, and analytical pipelines.


Architectural Invariants

All learned index structures in this lab adhere to four foundational constraints:

  1. Pre-Sorted Input: Vectors passed to constructors must be sorted in non-decreasing order (data[i] <= data[i + 1]).
  2. Deterministic Error Bounds: Every key’s predicted position is strictly bounded by $\pm \varepsilon$ around the true index.
  3. Zero Pointer Indirection: Segments and data arrays are contiguous memory buffers with zero runtime heap allocations during queries.
  4. Thread-Safe Read Concurrency: All index structures implement Send and Sync, allowing multi-threaded read sharing via Arc.
flowchart TD
    subgraph Storage["Storage Engine / Compaction Pipeline"]
        Raw["Sorted Data Array (u64)"] --> PLA["Streaming PLA (Single-Pass)"]
        PLA --> Segments["Contiguous Linear Segments"]
    end

    subgraph Memory["Query Serving Engine"]
        Key["Query Key x"] --> ALU["ALU Prediction: y = a*x + b"]
        ALU --> Window["Local Search Window: 2ε + 1 Keys"]
        Window --> Match["Exact Key / Predecessor"]
    end

    Segments -.->|"Segment Parameters"| ALU
    Raw -.->|"Contiguous Memory"| Window

Recipe Directory

RecipeTarget TopicPrimary APIs & Patterns
1. Point & Range QueriesExact matches, predecessors, and range scansfind, lower_bound, range, build
2. Concurrent Read ScalingMulti-core read parallelism without lock contentionArc<PgmIndex>, std::thread, thread pools
3. LSM SSTable Double-BufferingNon-blocking compaction lifecycle in LSM enginesmerge_sorted_batch, RwLock<Arc<PgmIndex>>
4. Columnar Block Zone MapsSparse indexing for Parquet / ClickHouse blocksBlock boundaries, row-group pruning
5. Operational Tuning & MonitoringProduction sizing, epsilon tuning, and health checksCache line sizing, N/S ratio monitoring