-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Fix rate agg with custom _doc_count
#79346
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
Changes from 5 commits
72b4c3b
3b4064d
23b9c78
4f04d77
7c3a73d
07ddb9d
206f647
8cbcf50
e95753a
47af043
a77f6af
2d0ea4e
b941998
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,14 +43,18 @@ public LeafBucketCollector getLeafCollector(LeafReaderContext ctx, final LeafBuc | |
| public void collect(int doc, long bucket) throws IOException { | ||
| sums = bigArrays().grow(sums, bucket + 1); | ||
| compensations = bigArrays().grow(compensations, bucket + 1); | ||
| // Compute the sum of double values with Kahan summation algorithm which is more | ||
| // accurate than naive summation. | ||
| double sum = sums.get(bucket); | ||
| double compensation = compensations.get(bucket); | ||
| kahanSummation.reset(sum, compensation); | ||
|
|
||
| if (values.advanceExact(doc)) { | ||
| if (computeRateOnDocs) { | ||
| final int docCount = docCountProvider.getDocCount(doc); | ||
| kahanSummation.add(docCount); | ||
| } else if (values.advanceExact(doc)) { | ||
| final int valuesCount = values.docValueCount(); | ||
| // Compute the sum of double values with Kahan summation algorithm which is more | ||
| // accurate than naive summation. | ||
| double sum = sums.get(bucket); | ||
| double compensation = compensations.get(bucket); | ||
| kahanSummation.reset(sum, compensation); | ||
|
|
||
| switch (rateMode) { | ||
| case SUM: | ||
| for (int i = 0; i < valuesCount; i++) { | ||
|
|
@@ -63,10 +67,10 @@ public void collect(int doc, long bucket) throws IOException { | |
| default: | ||
| throw new IllegalArgumentException("Unsupported rate mode " + rateMode); | ||
| } | ||
|
|
||
| compensations.set(bucket, kahanSummation.delta()); | ||
| sums.set(bucket, kahanSummation.value()); | ||
| } | ||
|
|
||
| compensations.set(bucket, kahanSummation.delta()); | ||
|
||
| sums.set(bucket, kahanSummation.value()); | ||
| } | ||
| }; | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.