[improve][misc] Migrate Yahoo DataSketches to Apache DataSketches#25965
Merged
Conversation
11 tasks
dao-jun
approved these changes
Jun 8, 2026
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.
Motivation
Pulsar still depends on
com.yahoo.datasketches:sketches-core:0.8.3. The DataSketches project moved to the Apache Software Foundation and was renamed toorg.apache.datasketches:datasketches-java; the old Yahoo coordinates have been unmaintained for years.This mirrors the motivation of apache/bookkeeper#4774. Pulsar
masteris still on BookKeeper 4.17.3 but will soon migrate to 4.18.0, which uses Apache DataSketches — and there is an intent to drop Yahoo DataSketches on the Pulsar side as well. Migrating now removes the unmaintained dependency and aligns Pulsar with BookKeeper.The Apache DataSketches maintainers recommend the KLL sketch over the classic quantiles sketch for new code (datasketches-java#398): it is faster and more memory efficient with comparable accuracy. This change therefore ports to
KllDoublesSketchrather than a 1:1 replacement with the classicDoublesSketch.Modifications
gradle/libs.versions.toml): removedcom.yahoo.datasketches:sketches-core:0.8.3; addedorg.apache.datasketches:datasketches-java:7.0.1anddatasketches-memory:4.1.0. Build files now referencelibs.datasketches.java.org.apache.datasketches.kll.KllDoublesSketchinDataSketchesOpStatsLogger(broker + bookkeeper-prometheus-metrics-provider),DataSketchesSummaryLogger,ThreadLocalAccessor, and the clientProducerStatsRecorderImpl:newHeapInstance()), matching prior behavior.DoublesUnion; aggregation usesmerge()into a freshly allocated heap sketch.reset(); per-thread sketches are reassigned to a freshnewHeapInstance()under the existingStampedLockwrite lock.KllDoublesSketch.getQuantile()/getQuantiles()throw on an empty sketch (the classic sketch returnedNaN), so callers now guard withisEmpty()to preserve the previousNaNreturn.pulsar.client-shade-conventions.gradle.ktsandpulsar-functions/localrun-shadedfromcom.yahoo*toorg.apache.datasketches.distribution/server,distribution/shell): updated the bundled jar entries to the Apache coordinates/versions.ThreadLocalAccessorTestported toKllDoublesSketch.Note: metric names and formats are unchanged; only the internal sketch algorithm changes, so approximate quantile values may differ slightly.
Verifying this change
This change is already covered by existing tests (e.g.
ThreadLocalAccessorTestand the broker stats/metrics tests). Checkstyle and spotless pass locally.Does this pull request potentially affect one of the following parts: