Skip to content

Conversation

@JonasKunz
Copy link
Contributor

Currently exponential histograms still use the standard Object.toString implementation.
This representation is not very helpful when debugging or when e.g. equalTo() assertions fail.

Therefore this PR adds a toString implementation printing the simple class name (also for anonymous classes) plus the actual histogram contents, giving a more pleasant experience:

image

@JonasKunz JonasKunz added the :StorageEngine/Mapping The storage related side of mappings label Sep 2, 2025
@elasticsearchmachine elasticsearchmachine added external-contributor Pull request authored by a developer outside the Elasticsearch team Team:StorageEngine v9.2.0 labels Sep 2, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-storage-engine (Team:StorageEngine)

@JonasKunz JonasKunz added >non-issue external-contributor Pull request authored by a developer outside the Elasticsearch team v9.2.0 and removed external-contributor Pull request authored by a developer outside the Elasticsearch team v9.2.0 labels Sep 2, 2025
@JonasKunz JonasKunz requested a review from kkrik-es September 2, 2025 11:33
histogram.setMin(-100);
histogram.setMax(200);
histogram.setSum(1234.5);
histogram.tryAddBucket(2, 3, false); // negative bucket
Copy link
Member

@felixbarny felixbarny Sep 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to this PR but the boolean isPositive parameter makes it a bit harder to read than it needs to be. Maybe add tryAddPositiveBucket and tryAddNegativeBucket methods that internal call tryAddBucket(long index, long count, boolean isPositive) and make it private

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll open a follow-up PR doing this but also replacing most usages of FixedCapacityHistogram with the new builder instead.

@JonasKunz JonasKunz enabled auto-merge (squash) September 2, 2025 12:14
@JonasKunz JonasKunz merged commit 3c264cf into elastic:main Sep 2, 2025
33 checks passed
@JonasKunz JonasKunz deleted the histo-tostring branch September 2, 2025 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external-contributor Pull request authored by a developer outside the Elasticsearch team >non-issue :StorageEngine/Mapping The storage related side of mappings Team:StorageEngine v9.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants