Skip to content

Commit 0810c99

Browse files
committed
fix(hll): preserve set coupon order when serializing
Compact HLL Set serialization used to sort retained coupons before writing bytes. Java and C++ write compact Set coupons in hash table iteration order. Write the existing iterator output directly. This keeps the compact format and removes the extra allocation.
1 parent 9a80c60 commit 0810c99

1 file changed

Lines changed: 1 addition & 11 deletions

File tree

datasketches/src/hll/hash_set.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -179,17 +179,7 @@ impl HashSet {
179179

180180
// Write coupons
181181
if compact {
182-
// Compact mode: collect non-empty coupons and sort for deterministic output
183-
let mut coupons_vec: Vec<Coupon> = self
184-
.container
185-
.coupons
186-
.iter()
187-
.filter(|&&c| !c.is_empty())
188-
.copied()
189-
.collect();
190-
coupons_vec.sort_unstable();
191-
192-
for coupon in coupons_vec.iter().copied() {
182+
for coupon in self.container.iter() {
193183
bytes.write_u32_le(coupon.raw());
194184
}
195185
} else {

0 commit comments

Comments
 (0)