leerho opened a new pull request, #803: URL: https://github.com/apache/datasketches-java/pull/803
`EbppsItemsSketch.internalMerge()` computed `newWtMax = Math.max(wtMax_, other.wtMax_)` and used it for every rho step, but never stored it. This is the Java counterpart of apache/datasketches-cpp#581. ### The bug After a merge, `wtMax_` was still the target's own maximum. That had three effects: - **Proportionality:** the next `update()` computed `rho = min(1/wtMax, k/cumWt)` with the smaller, stale maximum, so rho could rise. `downsample()` ignores ratios ≥ 1, so the items already in the sample weren't rescaled and the sample stopped being proportional to weight. - **Serialization:** `toByteArray()` wrote the stale maximum, and a heapified sketch carried it forward. - **Swap path:** when the argument has the larger cumulative weight, `merge()` merges into a copy and then takes `copy.wtMax_`, which was stale too. ### The fix `internalMerge()` now ends with `wtMax_ = newWtMax;`. Nothing in the serialized format changes, and there are no EBPPS cross-language files. ### Test The new `EbppsItemsSketchTest.mergeKeepsMaxWeight` is a port of the C++ test: k = 10, 1,000 items of weight 1 and one item of weight 500. The reference is a single sketch fed all of those items followed by one more weight-1 item; its C is (1000 + 1 + 500) / 500 = 3.002. Each variant below is followed by one weight-1 update and must match the reference's n, cumulative weight and C: 1. The 1,000-item sketch merges the heavy sketch. 2. The heavy sketch merges the 1,000-item sketch (the swap path). 3. Variants 1 and 2 again, each after a serialize and heapify round trip. C depends only on the sequence of rho values, not on the random choices, so the test is deterministic. Without the fix, every variant gives C = 3.00666, the same value C++ saw. ### Also A javadoc example in the test utility `UtilityIO` used the hyphenated profile name `-Pcheck-cpp-files`. Profile names use underscores, so it now says `-Pcheck_cpp_files`. The example's missing closing quote is fixed too. The full suite passes (2,405 tests). `javac -Xlint:all -Xdoclint:all,-missing` reports nothing new in the changed files. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
