-
Notifications
You must be signed in to change notification settings - Fork 26.6k
degist-concurrency-bugfix #12223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
degist-concurrency-bugfix #12223
Changes from 6 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
3b55ad3
degist-concurrency-bugfix
wxbty 1f68243
stytle opt
wxbty f6e84cc
fix i++
wxbty 083b45c
revert demo
wxbty 55f9f49
fix sonar
wxbty 1463007
remove apache licence
wxbty bddaa55
add licence
650d27e
Merge branch '3.2' into degist-concurrency-bugfix
songxiaosheng 4d2bf78
add testcase&& fix notice
a6b8277
Merge branch 'degist-concurrency-bugfix' of https://github.com/wxbty/…
532c141
add notice
23fe6ab
add notice
6b7f9b7
add notice
b0a0330
add notice
5f45fc8
fix ci timeout
wxbty 35b47b8
fix ci timeout
wxbty 0deeb1a
remove testcase because of timeout
wxbty 8b1a2d2
remove testcase because of timeout
wxbty 586d613
remove testcase because of timeout
wxbty 18a24c0
fix ci
fb14b63
fix sonar
8c128c0
Merge branch '3.2' into degist-concurrency-bugfix
songxiaosheng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
...bo-metrics-api/src/main/java/org/apache/dubbo/metrics/aggregate/DubboAbstractTDigest.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
|
|
||
| package org.apache.dubbo.metrics.aggregate; | ||
|
|
||
| import com.tdunning.math.stats.Centroid; | ||
| import com.tdunning.math.stats.TDigest; | ||
|
|
||
| public abstract class DubboAbstractTDigest extends TDigest { | ||
| boolean recordAllData = false; | ||
|
|
||
| /** | ||
| * Same as {@link #weightedAverageSorted(double, double, double, double)} but flips | ||
| * the order of the variables if <code>x2</code> is greater than | ||
| * <code>x1</code>. | ||
| */ | ||
| static double weightedAverage(double x1, double w1, double x2, double w2) { | ||
| if (x1 <= x2) { | ||
| return weightedAverageSorted(x1, w1, x2, w2); | ||
| } else { | ||
| return weightedAverageSorted(x2, w2, x1, w1); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Compute the weighted average between <code>x1</code> with a weight of | ||
| * <code>w1</code> and <code>x2</code> with a weight of <code>w2</code>. | ||
| * This expects <code>x1</code> to be less than or equal to <code>x2</code> | ||
| * and is guaranteed to return a number in <code>[x1, x2]</code>. An | ||
| * explicit check is required since this isn't guaranteed with floating-point | ||
| * numbers. | ||
| */ | ||
| private static double weightedAverageSorted(double x1, double w1, double x2, double w2) { | ||
| assert x1 <= x2; | ||
| final double x = (x1 * w1 + x2 * w2) / (w1 + w2); | ||
| return Math.max(x1, Math.min(x, x2)); | ||
| } | ||
|
|
||
| abstract void add(double x, int w, Centroid base); | ||
|
|
||
| /** | ||
| * Sets up so that all centroids will record all data assigned to them. For testing only, really. | ||
| */ | ||
| @Override | ||
| public TDigest recordAllData() { | ||
| recordAllData = true; | ||
| return this; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isRecording() { | ||
| return recordAllData; | ||
| } | ||
|
|
||
| /** | ||
| * Adds a sample to a histogram. | ||
| * | ||
| * @param x The value to add. | ||
| */ | ||
| @Override | ||
| public void add(double x) { | ||
| add(x, 1); | ||
| } | ||
|
|
||
| @Override | ||
| public void add(TDigest other) { | ||
| for (Centroid centroid : other.centroids()) { | ||
| add(centroid.mean(), centroid.count(), centroid); | ||
| } | ||
| } | ||
|
|
||
| } | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.