Add Java implementation of the h2 histogram#1
Merged
Conversation
A pure-Java port of the iopsystems h2 histogram, producing byte-for-byte identical bucketing to the Rust histogram crate. Mirrors the code organization of the Go and Python implementations: - Config: bucketing parameters and value<->index conversions - Histogram: dense histogram with record/percentile/merge/subtract/downsample - SparseHistogram: columnar (index, count) form for storage - CumulativeHistogram: read-only cumulative form with O(log n) percentiles and a precomputed midpoint-estimated mean - Bucket / PercentileResult / BucketWithQuantiles value types Values and counts are u64 carried in Java longs with unsigned semantics, so the full u64 range is supported. The bucketing math is verified against the exact assertions from the Rust crate's own unit tests (src/config.rs). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016Bb8BttJZHuy6zh957NMGT
This was referenced Jul 10, 2026
Single-threaded record-path benchmark at matched relative-error levels (h2 grouping powers 3/7/14 vs HDR 1/2/4 significant digits), with value streams touching from 64 buckets up to the full counter array to stress different cache levels. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016Bb8BttJZHuy6zh957NMGT
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016Bb8BttJZHuy6zh957NMGT
thinkingfish
marked this pull request as ready for review
July 10, 2026 14:58
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.
A pure-Java implementation of the iopsystems h2 histogram, using the Rust
histogramcrate as the reference and mirroring the code organization and README structure of the Go and Python ports.What's included
Config— bucketing parameters,valueToIndex/indexToLowerBound/indexToUpperBound,totalBuckets,error, plusfromTotalBucketsfor inferring the grouping power from a bare bucket count (Rezolus parquet files).Histogram— dense histogram:increment,record,recordMany,percentile(s),merge,subtract,downsample,toSparse,toCumulative,fromBuckets.SparseHistogram— columnar(index, count)form (the Rezolus:bucket_indices/:bucket_countslayout):fromHistogram,fromParts,toDense,toCumulative.CumulativeHistogram— read-only cumulative form (the crate'sCumulativeROHistogram): binary-searchpercentile(s), precomputed midpoint-estimatedmean,bucketQuantileRange,bucketsWithQuantiles.Bucket/PercentileResult/BucketWithQuantiles— value types (Java records).Design notes
u64carried in Javalongs with unsigned semantics (Long.compareUnsigned,Long.numberOfLeadingZeros,>>>), so the fullu64range is supported, exactly like the Rust crate and the Go port.0.1.0-SNAPSHOT; the README documents the release flow.Correctness
src/config.rs), the same approach used by the Go and Python ports. 36 tests, all passing.valueToIndex/ bucket bounds against the Go implementation over 40,000 random values spanning the fullu64range (grouping powers 3 and 7): zero mismatches.🤖 Generated with Claude Code
https://claude.ai/code/session_016Bb8BttJZHuy6zh957NMGT
Generated by Claude Code