-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Better groupBy error messages and docs around resource limits. #4162
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 all commits
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 |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| /* | ||
| * Licensed to Metamarkets Group Inc. (Metamarkets) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. Metamarkets licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| package io.druid.query.groupby.epinephelinae; | ||
|
|
||
| import java.util.Objects; | ||
|
|
||
| public class AggregateResult | ||
| { | ||
| private static final AggregateResult OK = new AggregateResult(true, null); | ||
|
|
||
| private final boolean ok; | ||
| private final String reason; | ||
|
|
||
| public static AggregateResult ok() | ||
| { | ||
| return OK; | ||
| } | ||
|
|
||
| public static AggregateResult failure(final String reason) | ||
| { | ||
| return new AggregateResult(false, reason); | ||
| } | ||
|
|
||
| private AggregateResult(final boolean ok, final String reason) | ||
| { | ||
| this.ok = ok; | ||
| this.reason = reason; | ||
| } | ||
|
|
||
| public boolean isOk() | ||
| { | ||
| return ok; | ||
| } | ||
|
|
||
| public String getReason() | ||
| { | ||
| return reason; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(final Object o) | ||
| { | ||
| if (this == o) { | ||
| return true; | ||
| } | ||
| if (o == null || getClass() != o.getClass()) { | ||
| return false; | ||
| } | ||
| final AggregateResult that = (AggregateResult) o; | ||
| return ok == that.ok && | ||
| Objects.equals(reason, that.reason); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() | ||
| { | ||
| return Objects.hash(ok, reason); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() | ||
| { | ||
| return "AggregateResult{" + | ||
| "ok=" + ok + | ||
| ", reason='" + reason + '\'' + | ||
| '}'; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,6 +59,16 @@ | |
| public class BufferGrouper<KeyType> implements Grouper<KeyType> | ||
| { | ||
| private static final Logger log = new Logger(BufferGrouper.class); | ||
| private static final AggregateResult DICTIONARY_FULL = AggregateResult.failure( | ||
| "Not enough dictionary space to execute this query. Try increasing " | ||
| + "druid.query.groupBy.maxMergingDictionarySize or enable disk spilling by setting " | ||
| + "druid.query.groupBy.maxOnDiskStorage to a positive number." | ||
|
Contributor
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. s/positive/larger , user might already have a positive number in there
Contributor
Author
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. This error will only be seen by the user if maxOnDiskStorage is 0, so "positive" does make sense. If it's > 0 they'll see a different error, about disk space being full. |
||
| ); | ||
| private static final AggregateResult HASHTABLE_FULL = AggregateResult.failure( | ||
| "Not enough aggregation table space to execute this query. Try increasing " | ||
| + "druid.processing.buffer.sizeBytes or enable disk spilling by setting " | ||
| + "druid.query.groupBy.maxOnDiskStorage to a positive number." | ||
|
Contributor
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. larger
Contributor
Author
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. Same as above |
||
| ); | ||
|
|
||
| private static final int MIN_INITIAL_BUCKETS = 4; | ||
| private static final int DEFAULT_INITIAL_BUCKETS = 1024; | ||
|
|
@@ -146,11 +156,13 @@ public boolean isInitialized() | |
| } | ||
|
|
||
| @Override | ||
| public boolean aggregate(KeyType key, int keyHash) | ||
| public AggregateResult aggregate(KeyType key, int keyHash) | ||
| { | ||
| final ByteBuffer keyBuffer = keySerde.toByteBuffer(key); | ||
| if (keyBuffer == null) { | ||
| return false; | ||
| // This may just trigger a spill and get ignored, which is ok. If it bubbles up to the user, the message will | ||
| // be correct. | ||
| return DICTIONARY_FULL; | ||
| } | ||
|
|
||
| if (keyBuffer.remaining() != keySize) { | ||
|
|
@@ -178,7 +190,9 @@ public boolean aggregate(KeyType key, int keyHash) | |
| } | ||
|
|
||
| if (bucket < 0) { | ||
| return false; | ||
| // This may just trigger a spill and get ignored, which is ok. If it bubbles up to the user, the message will | ||
| // be correct. | ||
| return HASHTABLE_FULL; | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -203,11 +217,11 @@ public boolean aggregate(KeyType key, int keyHash) | |
| aggregators[i].aggregate(tableBuffer, offset + aggregatorOffsets[i]); | ||
| } | ||
|
|
||
| return true; | ||
| return AggregateResult.ok(); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean aggregate(final KeyType key) | ||
| public AggregateResult aggregate(final KeyType key) | ||
| { | ||
| return aggregate(key, Groupers.hash(key)); | ||
| } | ||
|
|
||
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.
nit: maybe turn this into a link to that section