-
Notifications
You must be signed in to change notification settings - Fork 25.1k
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
Increase search.max_buckets to 65,535 #57042
Merged
imotov
merged 13 commits into
elastic:master
from
imotov:issue-51731-increase-max-buckets
Jun 3, 2020
Merged
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
5ab18c6
Increase search.max_buckets to 65,535
imotov 1041847
Remove unnecessary checks form reduce
imotov 625c6dd
Suppress number of buckets check in some aggregations
imotov fef7b26
Merge remote-tracking branch 'elastic/master' into issue-51731-increa…
imotov 8252b03
Cleanup after merge
imotov b871bcc
Merge remote-tracking branch 'elastic/master' into issue-51731-increa…
imotov eed4060
Suppress bucket count checks in more tests
imotov 8ec8048
Fix counter in BucketsAggregator
imotov 39e034a
Make sure that we still call breaker occasionally
imotov c9e2763
Merge remote-tracking branch 'elastic/master' into issue-51731-increa…
imotov 8870925
Fix HierarchyCircuitBreakerServiceTests
imotov 7a389ec
Merge remote-tracking branch 'elastic/master' into issue-51731-increa…
imotov 6bddc55
Add comment on collectExistingBucket
imotov 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
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
|
@@ -57,12 +57,12 @@ public BucketsAggregator(String name, AggregatorFactories factories, SearchConte | |
Map<String, Object> metadata) throws IOException { | ||
super(name, factories, context, parent, metadata); | ||
bigArrays = context.bigArrays(); | ||
docCounts = bigArrays.newIntArray(1, true); | ||
if (context.aggregations() != null) { | ||
multiBucketConsumer = context.aggregations().multiBucketConsumer(); | ||
} else { | ||
multiBucketConsumer = (count) -> {}; | ||
} | ||
docCounts = bigArrays.newIntArray(1, true); | ||
} | ||
|
||
/** | ||
|
@@ -91,7 +91,9 @@ public final void collectBucket(LeafBucketCollector subCollector, int doc, long | |
* Same as {@link #collectBucket(LeafBucketCollector, int, long)}, but doesn't check if the docCounts needs to be re-sized. | ||
*/ | ||
public final void collectExistingBucket(LeafBucketCollector subCollector, int doc, long bucketOrd) throws IOException { | ||
docCounts.increment(bucketOrd, 1); | ||
if (docCounts.increment(bucketOrd, 1) == 1) { | ||
multiBucketConsumer.accept(0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's add a comment here why we're using |
||
} | ||
subCollector.collect(doc, bucketOrd); | ||
} | ||
|
||
|
@@ -137,14 +139,6 @@ public final int bucketDocCount(long bucketOrd) { | |
} | ||
} | ||
|
||
/** | ||
* Adds {@code count} buckets to the global count for the request and fails if this number is greater than | ||
* the maximum number of buckets allowed in a response | ||
*/ | ||
protected final void consumeBucketsAndMaybeBreak(int count) { | ||
multiBucketConsumer.accept(count); | ||
} | ||
|
||
/** | ||
* Hook to allow taking an action before building buckets. | ||
*/ | ||
|
@@ -186,7 +180,7 @@ public InternalAggregation get(int index) { | |
public int size() { | ||
return aggregations.length; | ||
} | ||
}); | ||
}); | ||
} | ||
return result; | ||
} | ||
|
@@ -267,7 +261,6 @@ protected final <B> void buildSubAggsForBuckets(List<B> buckets, | |
protected final <B> InternalAggregation[] buildAggregationsForFixedBucketCount(long[] owningBucketOrds, int bucketsPerOwningBucketOrd, | ||
BucketBuilderForFixedCount<B> bucketBuilder, Function<List<B>, InternalAggregation> resultBuilder) throws IOException { | ||
int totalBuckets = owningBucketOrds.length * bucketsPerOwningBucketOrd; | ||
consumeBucketsAndMaybeBreak(totalBuckets); | ||
long[] bucketOrdsToCollect = new long[totalBuckets]; | ||
int bucketOrdIdx = 0; | ||
for (long owningBucketOrd : owningBucketOrds) { | ||
|
@@ -299,7 +292,7 @@ protected interface BucketBuilderForFixedCount<B> { | |
* @param owningBucketOrds owning bucket ordinals for which to build the results | ||
* @param resultBuilder how to build a result from the sub aggregation results | ||
*/ | ||
protected final InternalAggregation[] buildAggregationsForSingleBucket(long[] owningBucketOrds, | ||
protected final InternalAggregation[] buildAggregationsForSingleBucket(long[] owningBucketOrds, | ||
SingleBucketResultBuilder resultBuilder) throws IOException { | ||
/* | ||
* It'd be entirely reasonable to call | ||
|
@@ -328,7 +321,6 @@ protected interface SingleBucketResultBuilder { | |
protected final <B> InternalAggregation[] buildAggregationsForVariableBuckets(long[] owningBucketOrds, LongHash bucketOrds, | ||
BucketBuilderForVariable<B> bucketBuilder, Function<List<B>, InternalAggregation> resultBuilder) throws IOException { | ||
assert owningBucketOrds.length == 1 && owningBucketOrds[0] == 0; | ||
consumeBucketsAndMaybeBreak((int) bucketOrds.size()); | ||
long[] bucketOrdsToCollect = new long[(int) bucketOrds.size()]; | ||
for (int bucketOrd = 0; bucketOrd < bucketOrds.size(); bucketOrd++) { | ||
bucketOrdsToCollect[bucketOrd] = bucketOrd; | ||
|
@@ -360,7 +352,6 @@ protected final <B> InternalAggregation[] buildAggregationsForVariableBuckets(lo | |
throw new AggregationExecutionException("Can't collect more than [" + Integer.MAX_VALUE | ||
+ "] buckets but attempted [" + totalOrdsToCollect + "]"); | ||
} | ||
consumeBucketsAndMaybeBreak((int) totalOrdsToCollect); | ||
long[] bucketOrdsToCollect = new long[(int) totalOrdsToCollect]; | ||
int b = 0; | ||
for (int ordIdx = 0; ordIdx < owningBucketOrds.length; ordIdx++) { | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 for fixing this behavior