tisonkun opened a new pull request, #369:
URL: https://github.com/apache/datasketches-rust/pull/369

   ## Summary
   
   Makes union serialization APIs symmetric with `to_sketch` / 
`CompactThetaSketch` across HLL and Theta unions:
   
   - **Target `HllType` in `HllUnion::serialize`**: Update unreleased 
`HllUnion::serialize(&self, hll_type: HllType) -> Vec<u8>` (`#[must_use]`) to 
accept any target `HllType` (`Hll4`, `Hll6`, or `Hll8`), matching 
`HllUnion::to_sketch(hll_type)`. Each mode (`List`, `Set`, and dense `Array8`) 
encodes directly into a single final `SketchBytes` allocation without 
constructing an intermediate `HllSketch` or cloning the underlying container.
   - **Direct `Array8` transcoding (`Hll4` / `Hll6`)**: Extract 
`serialization::write_hll_preamble` and add `Array8::serialize_as` to pack 
6-bit registers (`Hll6`) and compact 4-bit nibbles plus ascending-slot aux 
exceptions (`Hll4`) directly from `Array8` registers and estimator state. For 
`Hll4`, output matches `to_sketch(HllType::Hll4).serialize()` byte-for-byte 
when `aux_count <= 1`, and produces an equal `HllSketch` with identical 
preamble, nibbles, estimates, and bounds when `cur_min > 0` and `aux_count >= 
2` (where `AuxMap` hash order differs from ascending slot order).
   - **Compressed Theta union serialization**: Extract `CompactThetaSketch` v4 
compression helpers into 
`thetafamily::theta::serialization::serialize_compact_compressed`, add 
`#[must_use] pub fn serialize_compressed(&self) -> Vec<u8>` on `ThetaUnion`, 
and align `ThetaUnion::serialize(&self, ordered: bool)` documentation with 
`TupleUnion::serialize`.
   - **Callers, tests, benchmarks, and changelog**: Update 
`HllUnion::serialize` call sites, add integration/serde tests across HLL target 
types and compressed Theta union outputs, extend HLL union serialization 
benchmarks to cover `Hll4`, `Hll6`, and `Hll8` vs `to_sketch(ty).serialize()`, 
and update `CHANGELOG.md`.
   
   ## Benchmarks
   
   `cargo bench --package benchmarks --bench benchmarks -- hll::serde` (`lg_k = 
18`, 5 runs per variant, comparing `union.serialize(ty)` against 
`union.to_sketch(ty).serialize()`):
   
   | Target | Rows   | Rounds     | `via_sketch` median ms | `direct` median ms 
| Speedup (`direct` / `via_sketch`) |
   | ------ | ------ | ---------- | ---------------------: | -----------------: 
| --------------------------------: |
   | `hll4` | 0      | 10,000,000 |                    318 |                139 
|                             0.44x |
   | `hll4` | 4      | 8,000,000  |                    289 |                144 
|                             0.50x |
   | `hll4` | 100    | 1,500,000  |                    321 |                270 
|                             0.84x |
   | `hll4` | 80,000 | 500        |                    316 |                 97 
|                             0.31x |
   | `hll6` | 0      | 10,000,000 |                    321 |                139 
|                             0.43x |
   | `hll6` | 4      | 8,000,000  |                    285 |                145 
|                             0.51x |
   | `hll6` | 100    | 1,500,000  |                    329 |                274 
|                             0.83x |
   | `hll6` | 80,000 | 600        |                    314 |                 32 
|                             0.10x |
   | `hll8` | 0      | 10,000,000 |                    332 |                137 
|                             0.42x |
   | `hll8` | 4      | 8,000,000  |                    295 |                146 
|                             0.49x |
   | `hll8` | 100    | 1,500,000  |                    319 |                256 
|                             0.80x |
   | `hll8` | 80,000 | 50,000     |                    335 |                171 
|                             0.51x |
   
   ## Validation
   
   - `cargo x check`: passed (`--no-default-features`, each individual feature, 
and `--all-features` with `-Dwarnings`)
   - `cargo x test`: 750 passed, 0 failed, 0 ignored (`datasketches` unit 90, 
`serde_tests` 162, `hll_test` 46, `theta_test` 85, doctests 136, plus remaining 
test binaries)
   - `cargo x lint`: passed (clippy `-D warnings`, fmt `--check`, doc `--cfg 
docsrs -D warnings`, taplo, typos, hawkeye)
   - `cargo +1.86.0 check -p datasketches --all-features`: passed
   - `cargo bench --package benchmarks --bench benchmarks -- --test`: passed
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to