Repository navigation
fix(dedup): support zero document priority - #513
Merged
davanstrien merged 2 commits intoNov 4, 2026
Merged
Conversation
Contributor
|
I just checked this PR applied to current main. For a 100-document fixture with priorities 1, 2, 42 and 65535, the signature files were byte-identical before and after applying this PR, at both 32 and 64-bit hash precision and with 1/3 finder workers. I also mixed a shard written by the old implementation with a shard written by this PR containing zero priorities. Both the old and new finder and filter implementations retained the expected highest-priority documents. The PR's ten exact-dedup tests also passed. This supports compatibility for existing positive-priority signatures in those cases. These checks used xxhash 3.6.0 on Python 3.12 in my environment. |
Contributor
Author
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.
Summary
[0, 65535].priority_max - priorityso that zero remains lower priority than positive values.ValueErrorfor out-of-range priorities and add regression coverage for zero priorities, ties, and invalid boundaries.Motivation
document_prioritycan legitimately return zero. For example, the URL deduplication example useslen(doc.text) // 4, which returns zero for documents shorter than four characters.The current assertion rejects these documents. Simply removing it would also be incorrect because negating an unsigned zero leaves it at zero, causing it to sort before positive priorities.
Fixes #337
Testing
python -m pytest -q tests/pipeline/dedup23 passed, 3 skipped, 2 subtests passedmake qualityNote
Medium Risk
Changes which duplicate document is kept when priority is 0 or near range limits, but behavior is localized to exact-dedup signature ordering and is covered by new regression tests.
Overview
Exact dedup now accepts
document_priorityvalues in[0, 65535]instead of rejecting zero. Stage-1 signature sorting no longer negates unsigned priorities (which broke ordering when priority was 0); it usespriority_max - prioritybefore and after sort so higher user priorities still win among duplicate hashes.Validation in
save_hashesraisesValueErrorfor out-of-range priorities instead of an assert. Tests cover zero-priority URL dedup (keeps higher priority / one doc per URL cluster), tied zero priorities, and boundaries-1/65536.Reviewed by Cursor Bugbot for commit e4f39b7. Bugbot is set up for automated code reviews on this repo. Configure here.