Repository navigation
Sample mostly-null arrays in integer and float Sparse selectors - #12300
lwwmanning wants to merge 6 commits into
Conversation
Signed-off-by: Will Manning <will@spiraldb.com> Co-Authored-By: Will Manning <will@spiraldb.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
roborev: Combined Review (
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cd2c774fae
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Signed-off-by: Will Manning <will@spiraldb.com> Co-Authored-By: Will Manning <will@spiraldb.com>
lwwmanning
left a comment
There was a problem hiding this comment.
Posted by Claude Opus 5.5 on Will's behalf.
I reviewed f28d6bb. The ZeroBytes fallback in null_dominated_sparse_estimate fixes the all-null sample. The new null-fill rule in Sparse::encode opens a panic, though.
Sparse::encode now takes the null-dominated branch whenever the fill is null (encodings/sparse/src/lib.rs:507). That branch still assumes the input has a null, and calls unreachable! when mask.indices() is AllOr::All (line 521). Before this commit, a null fill on an array with no nulls went to the general path instead.
NullDominatedSparseScheme::encode now passes a null fill on every call, and the sampler calls it on the sample as well as on the full array. The full array must be over 90% null, but the sample can still be all valid.
The stratified sampler takes 16 runs of 64 rows at fixed, seeded positions. A 16,384-row f64? column whose 1,024 valid rows sit at exactly those runs is about 94% null, and its sample has no nulls. Long arrays sample whole 1,024-row FastLanes chunks, so a column with clustered validity can hit the same case. The panic then fails the whole write, not just the estimate. I have not run this case.
A small fix is to require a null in the mask too, for example fill_value.as_ref().is_some_and(Scalar::is_null) && !mask.all_true(). With no nulls, the general path then stores every row as a patch under the null fill. A test that builds the array from sample_slices positions would pin it down. Sparse::encode is public, so this also keeps the old behavior for other callers.
Signed-off-by: Will Manning <will@spiraldb.com> Co-Authored-By: Will Manning <will@spiraldb.com>
|
Good catch — fixed in |
Merging this PR will not alter performanceWarning vortex-data has exceeded the Hobby plan limit of 5 active contributors. Upgrade your plan or apply to the open source program by December 8, 2026 to keep using CodSpeed. 1 warning
Comparing Footnotes
|
Signed-off-by: Will Manning <will@spiraldb.com> Co-Authored-By: Will Manning <will@spiraldb.com>
Devin Review🟢 Devin Review found nothing to fix · View findings · Follow Devin's work |
robert3005
left a comment
There was a problem hiding this comment.
I found a regression in the public Sparse::encode path for explicit null fills. This PR also conflicts with #12263 in the integer and float selectors. When those changes are combined, the shared sample should price the same compressed float patch children that the full encoder writes.
— Codex (OpenAI)
Signed-off-by: Will Manning <will@spiraldb.com> Co-Authored-By: Will Manning <will@spiraldb.com>
…fills Signed-off-by: Will Manning <will@spiraldb.com> Co-Authored-By: Will Manning <will@spiraldb.com>
|
Regarding roborev's Low note on |
lwwmanning
left a comment
There was a problem hiding this comment.
Review by Gemini 4 Carbon on behalf of @lwwmanning.
Sampling > 90% null arrays on the shared sample (CascadingCompressor::estimate_with_sampling) and honoring an explicit null fill_value in SparseData::encode is the right mechanism to compete fairly with Pco (#12266), but this PR conflicts directly with #12263 on vortex-btrblocks/src/schemes/float/sparse.rs and vortex-btrblocks/src/schemes/integer/sparse.rs and has four gaps if landed without #12263:
- Float
patch_valuesis left uncompressed (vortex-btrblocks/src/schemes/float/sparse.rs): Without#12263's child-0valuescascade,float::NullDominatedSparseSchemekeepspatch_valuesuncompressed (7,545 Bongolden__compact__float_mostly_null.snap, which is1,116 Blarger than densePcoonce#12258lands, vs~6,427 Bwhen cascading bothvaluesandindices). - Sample-vs-full fill-branch mismatch (
vortex-btrblocks/src/schemes/integer/sparse.rs:154): Whennull_dominated_sparse_estimaterunsSparseScheme::encodeonsample.data,stats.null_count() > most_frequent_countis re-checked on the sample's stats and can flip to a non-null fill when valid values cluster in a sampled slice. - Count-based ratio (
len / patch_count) in<= 90%nullinteger::SparseSchemeandZeroBytesfallback:integer/sparse.rs:131-136andschemes/mod.rs:528ignoreelem_bytes, narrowedidx_width, andpatch_validity(fixed by#12263's byte-accurate calculation). - Sample index-width under-pricing when
len > 65,536:sample.data(~1,024 rows) narrowspatch_indicestou16(2 B) even whenfull_len > 65,536requiresu32(4 B).
Remediation Plan
Please fold #12300 (encodings/sparse/src/lib.rs + vortex-compressor/src/compressor/mod.rs + sample-based null_dominated_sparse_estimate) into #12263 following the unified remediation plan posted on #12263, and close #12300.
|
Folded into #12263. |
This changes how the BtrBlocks compressor prices and encodes
Sparsefor mostly-null integer and float columns (integer::SparseSchemeandfloat::NullDominatedSparseScheme). Other schemes and the file format stay the same. Two compact golden snapshots change, and the PR adds one public method and changes the behavior of the publicSparse::encode.On develop, both schemes score an array that is more than 90% null with a fixed ratio,
len / value_count. That ratio ignores how well the patch values and indices compress, and it ignores the validity bitmap thatSparsedrops. Since #12266,Pcoscores itself on the compression sample, a few slices of the array that each candidate compresses. SoPcocan win on these columns even whenSparseis smaller. With this PR, both schemes also compress the sample, through the newCascadingCompressor::estimate_with_sampling. If the sample holds only nulls, they fall back tolen / value_count.The sample can be 90% null or less when the full array is not. So that the estimate and the full encode use the same layout, both schemes now pass a null fill to
Sparse::encode.Sparse::encodenow uses the null-fill layout for any explicit null fill if the array has at least one null. Before, it used that layout only above 90% null.integer::SparseSchemenow also picks a null fill whenever nulls outnumber its most frequent value, and its estimate matches that choice.On the compact golden data,
float_mostly_null(f64?) moves fromPcoat 7,837 B toSparseat 7,545 B.int_mostly_null(i32?) moves from 3,086 B to 1,661 B.Related to #12266. Overlaps #12263, which keeps a fixed estimate for the patch indices and still selects
Pcoonfloat_mostly_null.Assisted by AI.