Repository navigation
Conversation
flush sorted the pending buffer with f64::total_cmp, which applies its bit transform to both operands on every comparison. Store pending values as total-order u64 keys instead, transformed once in push, so the sort compares plain integers. compress_sorted now takes an iterator, letting flush decode keys as it compresses without a scratch allocation. The order is exactly total_cmp's, so flushed centroids are unchanged; a property test checks buffered ingestion against chunked merge_unsorted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
flushsorts the pending buffer withf64::total_cmp, which applies its bit transform to both operands on every comparison. This PR stores pending values as total-orderu64keys instead. The transform runs once per value inpush, and the sort compares plain integers.compress_sortednow takes anExactSizeIterator<Item = f64>, soflushdecodes keys while compressing, with no scratch allocation.merge_sortedpassesiter().copied().mean()overflow fallback decodes buffered keys the same way.total_cmp's, so flushed centroids are unchanged.Tests
test_total_order_key_matches_total_cmp: key order matchestotal_cmpacross signed zeros, subnormals and extremes, and keys round-trip bit-exactly.buffered_flush_matches_batch_merges(proptest): push + flush gives the same centroids as chunkedmerge_unsorted. I checked that this test fails if the sort is removed.The existing
buffered_flushandincremental_ingest/buffered_pushbenches cover this path. I haven't included timings from a quiet machine, so please run those benches to judge the gain.Checked locally:
cargo test(debug and release, all feature sets), clippy-D warnings, rustdoc-D warnings,no_std, and the MSRV 1.62 checks from CI.One side effect:
Debugoutput for a digest with pending values shows the internal keys rather thanf64s.🤖 Generated with Claude Code