All my work / Storage & data systems · by Ravindra Sawant
Floe
Iceberg-style table format: immutable Parquet, manifests, snapshots, time travel, compare-and-swap commits.
Verified 2026-11-28; CI re-runs the acceptance tests on every push.
The problem
File-based tables need atomic visibility across many immutable files, time travel, and safe concurrent writers. This is a small Iceberg-inspired format: Parquet data files, JSON manifests with column stats, immutable snapshot metadata, and a SQLite catalog that publishes each version with compare-and-swap.
What I found
- Two processes committing from the same base version: exactly one CAS wins; with rebase enabled the loser re-publishes its already-written files and no rows are lost.
- A writer killed after writing data but before the CAS leaves only unreachable orphans - readers never see partial commits.
- Partition + min/max pruning opened 95% fewer files on selective scans, and randomized tests prove pruning never drops a matching row.
Architecture
writer ─► validate rows (field IDs) ─► Parquet data files (tmp→fsync→rename) ─► manifest JSON (stats)
─► candidate metadata v{N+1} (snapshots[], schemas[], metadata_log) ─► SQLite CAS (version = N)
reader ─► pin catalog pointer once ─► snapshot ─► manifests ─► partition + min/max pruning ─► Parquet ─► exact filter
Warehouse layout: catalog.db, <table>/data/p=<value>/<uuid>.parquet, <table>/metadata/v<N>-<id>.metadata.json, <table>/metadata/manifest-<uuid>.json. Physical Parquet columns are f_<field id>, which makes renames free and lets old files be read through the newest schema.
Commit protocol: BEGIN IMMEDIATE; UPDATE tables SET version=version+1, metadata_path=? WHERE name=? AND version=? — success only if exactly one row changed. A loser's files remain unpublished (listed by orphans()). Append rebase reuses already-written data files and manifest; compaction is never retried silently.
Pruning safety: missing/null stats never prune; partition pruning evaluates the predicate on the partition value; the exact predicate is always re-evaluated on rows.
Durability contract: data/manifest/metadata are fsynced and atomically renamed before the CAS; SQLite runs WAL with synchronous=FULL. Local filesystem guarantees are not equivalent to object stores.
Requirements → tests
| Req | Pri | Requirement | Proven by | Status |
|---|---|---|---|---|
| FR-01 | P0 | Create table with field IDs/types/partition field; reject incompatible rows | T01, T04 | pass |
| FR-02 | P0 | Append immutable Parquet + manifest with stats; commit new metadata version | T01, T03 | pass |
| FR-03 | P0 | Atomic SQLite CAS of metadata pointer; preserve snapshots; refuse stale commits | T02, T03 | pass |
| FR-04 | P0 | Snapshot scan with partition + min/max pruning, exact predicate, projection, counts | T01 | pass |
| FR-05 | P1 | Rebase retries, add nullable / rename by field ID, conditional compaction | T02, T04, T05 | pass |
| Test | What it proves | Result |
|---|---|---|
| T01 | Two batches: per-snapshot row sets, parent chain, pruned scan == unpruned scan | pass |
| T02 | Two processes publish from the same version: exactly one CAS wins; loser rebases if asked | pass |
| T03 | Writer killed after data write / before CAS / after CAS: only published files visible, orphans listed | pass |
| T04 | Add nullable field + rename by ID across old/new files; reject incompatible type change | pass |
| T05 | Compaction keeps row multiset and old snapshots readable; stale compaction fails | pass |
Benchmark
| Target (hypothesis from the spec) | Goal | Actual | |
|---|---|---|---|
| selective partition scan opens >=80% fewer files than full scan | >= 80% | 95% | met |
| min/max range pruning opens >=80% fewer files | >= 80% | 90% | met |
| compaction reduces partition file count >= 4x | >= 4x | 10.0x | met |
| pruned scans return exact row counts | exact | all exact | met |
full_scan_file_opens= 200partition_scan_file_opens= 10range_scan_file_opens= 20compaction_reduction_x= 10.0
quick run · 2026-11-28T23:56:57+00:00 · Warm OS page cache after first trial; local disk, not object storage.
Design questions
How does a table format provide atomicity?
Writers prepare immutable files, then publish a single catalog pointer atomically; readers pin one metadata version, so uncommitted objects are never visible as rows.
How does optimistic concurrency work?
Writers validate the expected base version at publication (CAS). Compatible operations like appends can rebase; destructive rewrites must check that the files they replace still exist and fail otherwise.
Why manifests?
They group file metadata and statistics apart from data so planning and pruning do not open every data file. Large manifest lists then need their own management.
How do you safely evolve schema?
Stable field IDs separate identity from name; old files map to the current schema by ID and absent nullable fields read as null. Type changes are limited to safe promotions.
Why not delete compacted files?
Historical snapshots still reference them. Expiration/GC must consider every retained snapshot plus concurrent readers and writers.
Limitations
- Not Iceberg-compatible (JSON manifests, no Avro, no REST catalog)
- Local filesystem + one SQLite catalog; object-store atomicity not assumed
Run it
git clone https://github.com/ravirs/floe.git && cd floe
pip install -r requirements.txt
PYTHONPATH=src python -m minice demo # demo
PYTHONPATH=src python -m pytest -q # test
PYTHONPATH=src python benchmarks/bench.py --quick # benchMore systems I've built from scratch
Storage & data systems
- Strata LSM-tree key-value storage engine: WAL, SSTables with Bloom filters, atomic manifest, compaction
- Tidelog Kafka-style durable partitioned log broker: CRC'd records, offsets, generation-fenced consumer groups
- Flint Spark-style batch engine: lazy lineage, stage planning, shuffles, broadcast and salted skew joins
- Watermark Event-time stream processor: windows, watermarks, lateness, exactly-once checkpoints
- Warden Data governance catalog: explainable grants, row filters, column masks, lineage impact
- SnapshotDB MVCC transaction engine: snapshot isolation, the write-skew anomaly, a serializable mode
AI infrastructure
- Nearline HNSW-style vector search index from scratch, measured against exact search
- KVPager Paged KV cache with copy-on-write forks and prefix reuse (PagedAttention-style)
- Batchwise LLM inference scheduler simulator: static vs continuous vs chunked-prefill batching
- Steadyhand Durable AI agent runtime: allowlisted tools, approvals, budgets, crash recovery, replay
- Toolgate Model Context Protocol gateway: curated tools, signed identity, tenant policy, approvals, audit