Skip to main content

Tests: internal/compaction

internal/compaction · 5 tests

Each test is named for the property it holds, and runs against a real deployment: there is no mock of the database and no arm that skips when it is absent. The sentence is the test's name read back; the name is what go test -run takes.

compaction_test.go

  • The roll up climbs one level per full runTestTheRollUpClimbsOneLevelPerFullRun. Nothing is written while the history fits in the verbatim tail; the first run behind the tail becomes a level-1 segment; a full run of level-1 segments becomes a level-2 one over their union.
  • Ten thousand turns cost linearly many summariesTestTenThousandTurnsCostLinearlyManySummaries. Ten thousand turns cost a number of summaries linear in the turns, not quadratic: each turn is summarised once per level it climbs, and the levels are logarithmic.
  • A gap ends a run and only the covering segments are written againTestAGapEndsARunAndOnlyTheCoveringSegmentsAreWrittenAgain. A gap in the history, which is what an erasure leaves, ends a run: no segment spans it, and the segments that covered erased turns are the only ones the pass has to write again.
  • The assembly is newest verbatim then highest segments and cuts from the oldest endTestTheAssemblyIsNewestVerbatimThenHighestSegmentsAndCutsFromTheOldestEnd. The assembly is the newest turns verbatim and the highest segment over everything older, oldest first; it is cut from the oldest end to fit the budget and says so.
  • A higher level gap closes early and overlapping segments are never joinedTestAHigherLevelGapClosesEarlyAndOverlappingSegmentsAreNeverJoined. A run of level-1 segments shorter than a branch closes when it ends at a level-2 segment that already exists, the way a level-1 run does at level 1: that is the shape an erasure leaves.