Implementing Git for Data on DuckDB (Part 3): Branches, diff, pick, merge — The Version Primitives of Data

The first two posts made history readable. This one covers what makes a data version system actually useful: branches and changes. 1. The branch model A branch isn’t “a copy of the data”; it’s a combination of three things: branch = pin (which commit) + name + lineage (parent / base_line) + optional storage (materialized copy) or delta (changes relative to a base) materialize: really copy the table; reads go straight to the copy; delta: store only “which keys were removed from the base, which rows were added”; reads compose; update in a delta is a removal plus an addition of the same key (replacement pairing). This design brings the cost of “create a branch” from “copy a table” down to “register one metadata row.” ...

October 20, 2026 · 4 min · daviszhen

Rewriting Lucene in C++ (Part 4): The Writer and the Long Tail — From 59% to 100% Coverage

The first three posts covered reading, scoring and searching. The last one covers writing: the index writer, and a more prosaic question — how much do you actually support? 1. Writer architecture In one sentence: documents come in, get grouped by term → token, accumulate in a RAM buffer, and flush into a segment when full. Design point Approach Why Grouping Reusable (termId, tokenIndex) integer sort Each term’s postings are written contiguously Encoding One varint stream per term: [docDelta, freq, posDelta*freq] Matches the Lucene104 format Segment names Base 36 Java’s rule; otherwise multi-segment naming collides Deleted bitmap .liv = header + bits2words(maxDoc) little-endian longs 1 = live; padding bits past maxDoc must be cleared Merge Pairwise merge tree (not whole-index reread) Bounded memory, output still equivalent to a single pass Append Pre-register source FieldInfos Preserves field numbers; otherwise they all shift 2. Acceptance: byte identity Merge and append correctness has a one-line criterion: ...

October 20, 2026 · 4 min · daviszhen