All my work / Storage & data systems · by Ravindra Sawant

Floe

Iceberg-style table format: immutable Parquet, manifests, snapshots, time travel, compare-and-swap commits.

Python 3.11+ · PyArrow · SQLite 639 lines of core code source on GitHub ↗ CI status

4/4 core requirements 10 tests passing 4/4 benchmark targets

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

ReqPriRequirement Proven byStatus
FR-01P0Create table with field IDs/types/partition field; reject incompatible rowsT01, T04pass
FR-02P0Append immutable Parquet + manifest with stats; commit new metadata versionT01, T03pass
FR-03P0Atomic SQLite CAS of metadata pointer; preserve snapshots; refuse stale commitsT02, T03pass
FR-04P0Snapshot scan with partition + min/max pruning, exact predicate, projection, countsT01pass
FR-05P1Rebase retries, add nullable / rename by field ID, conditional compactionT02, T04, T05pass
TestWhat it provesResult
T01Two batches: per-snapshot row sets, parent chain, pruned scan == unpruned scanpass
T02Two processes publish from the same version: exactly one CAS wins; loser rebases if askedpass
T03Writer killed after data write / before CAS / after CAS: only published files visible, orphans listedpass
T04Add nullable field + rename by ID across old/new files; reject incompatible type changepass
T05Compaction keeps row multiset and old snapshots readable; stale compaction failspass

Benchmark

Target (hypothesis from the spec)GoalActual
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>= 4x10.0xmet
pruned scans return exact row countsexactall exactmet
  • full_scan_file_opens = 200
  • partition_scan_file_opens = 10
  • range_scan_file_opens = 20
  • compaction_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   # bench

More 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

Distributed systems

  • Quorum Deterministic Raft consensus simulator with fault injection and an always-on invariant checker
  • Tandem Collaborative text editor on a sequence CRDT: offline edits, any delivery order, always converges
  • Burrow Minimal Linux container runtime in Go: namespaces, pivot_root, cgroup v2 limits

← See all my work: apps, ML/AI and systems