Architecture: The Indexed LakehouseΒΆ
BenoStreamDB implements an indexed, compute-disaggregated lakehouse storage architecture that pairs authoritative open table storage with advisory, persistent secondary indexes and a unified retrieval layer.
Iceberg Table
β
βββββββββββββββ΄βββββββββββββββ
β β
Authoritative Storage Advisory Index Overlay
β β
Parquet Files Bitmap / Bloom / BM25 / HNSW / TQ
Core PhilosophyΒΆ
βYour Data is Standard. Your Index is Custom.β
BenoStreamDB attaches persistent, reconstructible sidecar index files alongside standard Parquet files:
100% Format Compatibility: Standard data engines (Spark, Trino, DuckDB, Pandas) read the underlying Parquet and Iceberg tables directly at native speed.
O(log N) Accelerated Retrieval: BenoStreamDB-aware query engines and REST search gateways leverage inverted bitmap and vector indexes for low-latency queries directly on object storage.
The Overlay Invariant: Indexes are derived state. If an index file is absent, corrupted, or stale, queries safely degrade to Parquet scanning without failing or returning incorrect results. See ADR-001: Tightened Overlay Index Artifact Contract & Compound Puffin Bundles.
Storage Layout: Hybrid SegmentsΒΆ
Data is stored in immutable Segments pairing open columnar storage with advisory index sidecars:
Authoritative Raw Data:
data/segment_id.parquet: Standard Apache Iceberg columnar data files written with ZSTD compression and dictionary encoding. 100% readable by external engines (DuckDB, Spark, Trino, Polars).
Advisory Secondary Indexes (Apache Iceberg Puffin Compound Bundles):
metadata/segment_id.puffin: As specified in ADR-001, production deployments consolidate secondary index artifacts into standard Apache Iceberg Puffin (.puffin) compound bundles. A single.puffinfile encapsulates Roaring Bitmap inverted indexes, BM25 term frequencies, and Voronoi-clustered HNSW/TurboQuant vector graphs queried via HTTP byte-range offsets, preventing cloud object count explosion.(Uncompacted / Local Debug Mode): Prior to Voronoi cluster compaction (
rebuild_cluster_index), transient per-column sidecars (.inv.parquet,.bm25.parquet,.centroids.parquet,.hnsw.graph) may be emitted beforecompact()orvacuum()merges them into compound Puffin bundles.
Iceberg Table Metadata:
_manifest/v{N}.avro: Standard Iceberg V2/V3 snapshot manifests and manifest lists._metadata/v{N}.metadata.json: Iceberg table schema, sort orders, partition specs, and snapshot lineage.
Ingestion Pipeline: Non-Blocking Indexing & Async WALΒΆ
BenoStreamDB achieves high ingestion throughput while maintaining real-time queryability:
Memtable & Async WAL: Incoming records write to an in-memory batch buffer with adaptive or immediate WAL fsync durability.
Parquet Flushes: Records flush to compressed Parquet files for immediate durability.
Background Indexing: High-dimensional vector graphs (HNSW-IVF) and full-text indexes build asynchronously across a Rayon thread pool without blocking writes.
Atomic Manifest Snapshot: Once background index construction completes, the manifest is atomically swapped via Optimistic Concurrency Control (OCC) or distributed CAS locks (
FileBasedLock).
The Read Path & Hot Row CacheΒΆ
BenoStreamDB combines scalar pre-filtering, vector search, and in-memory caching for ultra-low latencies:
Scalar Pruning: Query planner evaluates inverted index sidecars, producing a candidate row bitmap.
Vector / Keyword Scoring:
Vector Search: Traverses HNSW graph sidecars, evaluating candidates with dynamic SIMD metrics.
Full-Text Search: Scores terms using BM25 Okapi sidecars.
Hybrid RRF: Combines ranks from vector and keyword search using Reciprocal Rank Fusion ($1 / (k + \text{rank} + 1)$).
Hot Row Cache (
BLOCK_CACHE):Decoded Parquet
RecordBatchchunks are held in an in-memory LRU block cache.Scattered kNN candidate row fetches resolve directly from memory in sub-millisecond time, completely bypassing disk I/O and eliminating tail latency spikes.
Table-Level Cluster Indexing & Sequential 512 MiB Puffin ShardingΒΆ
For multi-million and 100M+ vector tables, per-segment vector sidecars create query fan-out overhead across hundreds of small HNSW graphs. BenoStreamDB provides Table-Level Cluster Indexing (ClusterIndex) via table.rebuild_cluster_index():
Table-Level Cluster Index (v42)
β
ββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββ
β β β
Shard 0000 (β€512 MiB) Shard 0001 (β€512 MiB) Shard 0002 (β€512 MiB)
Clusters [0 .. K0] Clusters [K0+1 .. K1] Clusters [K1+1 .. K2]
- HNSW Graphs (IPC) - HNSW Graphs (IPC) - HNSW Graphs (IPC)
- (seg_id, row_id) Parquet - (seg_id, row_id) Parquet - (seg_id, row_id) Parquet
Architectural Guarantees:ΒΆ
Decoupled Overlay Invariant: Cluster nodes carry
(segment_idx, row_id)tuples stored in Arrow Parquet metadata tables. The underlying Parquet data files are read once and never rewritten or compacted, completely eliminating fragile ETL pipeline failures and maintaining standard Apache Iceberg read compatibility.Sequential 512 MiB Rolling Shards: Shards (
cluster_{col}_{version}_shard_{i}.puffin) roll strictly at the advisory target size ($\le 512\text{ MiB}$), complying with cloud object store single-PUT requirements (avoiding AWS S3 5 GB multi-part upload penalties and latency).Monotonic Cluster Ordering & Disjoint Ranges: Clusters are assigned in strictly monotonic order ($0, 1, 2, \dots, K-1$) and packed into non-overlapping cluster ranges (
min_cluster..=max_cluster), ensuring $O(1)$ shard lookup and high spatial locality during top-$N$ Voronoi centroid routing.Zero-Copy Out-of-Core Memory Mapping (
memmap2): Sealed Puffin shards are wrapped in zero-copy memory maps viaBytes::from_owner(MmapOwner(Arc::new(mmap))). Builds stream directly to disk viaBufWriter<File>, maintaining flat memory consumption ($\sim 2.2 - 3.5\text{ GiB}$) inside strict $16\text{ GiB}$ zero-swap container cgroups without OOM events.Multi-Threaded Rayon Compaction: Centroid assignment (Pass 2) and intra-bucket cluster graph construction (Pass 3) execute across all available CPU cores using Rayon work-stealing parallel iterators, achieving $300% - 600%$ CPU saturation and a $3.5\times$ compaction speedup.
Multi-Protocol Search Gateway (bsdb-search)ΒΆ
BenoStreamDB exposes its columnar storage and index overlays via standard REST protocols:
OpenSearch / Elasticsearch 7.10 API (Port 9200): Drop-in compatibility for
_search,_bulk,_mapping, and_cat/indices.Qdrant Vector API (Port 6333): Qdrant v1.x REST emulation β collections, point upsert/retrieve, payload & vector edits, vector search, aliases, and the universal query API. See QDRANT_COMPATIBILITY.md.
Arrow Flight SQL (Port 50051): Low-latency zero-copy gRPC queries for analytical tools.