Skip to main content

pick_count_first

Function pick_count_first 

Source
fn pick_count_first(
    sorted_runs: Vec<SortedRun<FileHandle>>,
    max_output_file_size: Option<u64>,
) -> Vec<FileHandle>
Expand description

Picks a contiguous (in global time order) interval of files to compact.

The picker reorders all files from all sorted runs by (start asc, end desc) and enumerates every interval of at most MAX_INPUT_FILES files as a Candidate. An interval is eligible when it

  • holds at least 2 files,
  • is balanced: no single file dominates it (largest <= sum of the others),
  • when mixing levels with known row counts, has at most twice as many L1 rows as L0 rows,
  • makes progress on at least one axis: it reduces the physical file count given the output split threshold max_output_file_size, or it resolves at least one overlap between sorted runs.

The best interval wins by CandidateScore; ties keep the earliest interval.