Repository navigation
fix(index): preserve contiguous fragment coverage for compaction - #90
nyl3532016 wants to merge 2 commits into
Conversation
Required change: split the heaviest run when runs fall short of the segment countlance-spark's Pairs are So "optimal max group rows" is not sufficient evidence that the PR's compaction goal is met. The splitting step costs nothing in max group rows, and while it cannot mathematically eliminate every single-fragment segment ( Suggestion: sort by
|
|
Thanks @nyl3532016, LGTM. One follow-up: the @rchowell @universalmind303 @everySympathy, do you have time to review this one? |
|
@everySympathy @rchowell, could you take a look at this PR when you have a chance? FANNG1 has approved the updated changes, and an additional review would be appreciated. The latest update (9700367) keeps scalar and vector index coverage contiguous and splits the heaviest splittable runs to avoid singleton tails in the "large fragment + small appends" case. It also adds fragment-ID sorting and regression coverage for both BTREE and IVF_FLAT indexing followed by compaction. Validation of the updated code: the fragment distribution and compaction suites passed with 77 tests on NativeRunner and 77 tests on Ray (2 CPUs); lint, formatting, and the focused type checks also passed. Given your work on the index implementation and this repository, a review of the shared grouping policy and its compaction behavior would be especially helpful. Thanks! |
Equal-sized fragments are currently assigned to alternating index segments (
S0, S1, S0, S1, ...). Lance's compaction planner cannot merge adjacent fragments with different index coverage, so eight small fragments can produce zero compaction tasks after distributed indexing.Partition selected fragments in dataset order into deterministic contiguous groups, minimizing the largest group's row count. Preserve the existing
fragment_group_sizeAPI and its group count,ceil(fragment_count / fragment_group_size). Scalar and vector indexing share this policy. Use a uniform estimate of 1 when a row count is unavailable.Document the compaction tradeoff, partial-build gaps, and the need to rebuild existing interleaved indexes. Add exhaustive cut-placement oracle tests for grouping and end-to-end regressions for two aligned BTREE indexes and an IVF_FLAT index: eight fragments compact into two, with data and indexed query results preserved.
Related fix in lance-ray: lance-format/lance-ray#5319
Validation
Linux Docker container, Python 3.12, pylance 12.0.0, Daft 0.7.14, Ray 2.55.1; dependencies from
uv.lock:ruff check --no-cache --no-fix daft_lance tests: passed.ruff format --checkfor changed Python files: passed.mypy daft_lance/ tests/io/lance/test_fragment_distribution.py: passed (16 source files).mypy daft_lance/ tests/check reports the same 582 errors in 24 files on both unmodified main and this branch; no new typing errors.