Skip to main content

pick_closed_merge

Function pick_closed_merge 

Source
pub(crate) fn pick_closed_merge(
    files: &[FileHandle],
    mapper: &PrimaryKeyRangeMapper,
    options: ClosedMergeOptions,
) -> Option<UnitPick>
Expand description

Picks an interval of units among all files of an inactive window.

Units are the closures of conflicting files: no file outside a unit intrudes on its bounding box. A closure larger than the input limit is split back into single files, so files around a late file spanning a large sorted run can still be merged. Intervals follow sort_units. An interval is eligible if its outputs add no more conflicts than its files have with other files (see adds_no_conflicts), and it

  • removes files within the rewrite budget, or
  • resolves conflicts without rewriting a dominant sorted run (unless ClosedMergeOptions::allow_unbalanced), and adds at most one tail file.

The pick maximizes resolved conflicts plus removed files per rewritten byte. A window whose split-unit conflict graph is too dense to materialize falls back to a bounded file reduction; see pick_dense_closed_merge.