-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Configure a max limit for lgK values of HLL sketches #15516
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
fdee330
Add runtime parameter
adarshsanjeev 980fba6
Resolve builds
adarshsanjeev 0c611be
Merge remote-tracking branch 'origin/master' into hll-max-lgk
adarshsanjeev 2bd6297
Update release notes
adarshsanjeev 474b5d4
Add test
adarshsanjeev f50a9f1
Update test
adarshsanjeev 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
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
53 changes: 53 additions & 0 deletions
53
...asketches/src/main/java/org/apache/druid/query/aggregation/datasketches/SketchConfig.java
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF 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 org.apache.druid.query.aggregation.datasketches; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import javax.annotation.Nullable; | ||
import javax.validation.constraints.Max; | ||
import javax.validation.constraints.Min; | ||
|
||
/** | ||
* Contains runtime configurations specific to datasketches extension. | ||
*/ | ||
public class SketchConfig | ||
{ | ||
public static final int DEFAULT_HLL_MAX_LG_K = 20; | ||
|
||
@JsonProperty | ||
@Min(1) | ||
@Max(21) | ||
private int hllMaxLgK = DEFAULT_HLL_MAX_LG_K; | ||
|
||
public SketchConfig(@Nullable Integer maxLgK) | ||
{ | ||
this.hllMaxLgK = maxLgK == null ? DEFAULT_HLL_MAX_LG_K : maxLgK; | ||
} | ||
|
||
public SketchConfig() | ||
{ | ||
} | ||
|
||
public int getHllMaxLgK() | ||
{ | ||
return hllMaxLgK; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...asketches/src/main/java/org/apache/druid/query/aggregation/datasketches/SketchModule.java
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF 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 org.apache.druid.query.aggregation.datasketches; | ||
|
||
import com.google.inject.Binder; | ||
import org.apache.druid.guice.JsonConfigProvider; | ||
import org.apache.druid.initialization.DruidModule; | ||
|
||
public class SketchModule implements DruidModule | ||
{ | ||
@Override | ||
public void configure(Binder binder) | ||
{ | ||
JsonConfigProvider.bind(binder, "druid.sketch.config", SketchConfig.class); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -24,6 +24,7 @@ | |
import org.apache.datasketches.hll.HllSketch; | ||
import org.apache.datasketches.hll.TgtHllType; | ||
import org.apache.datasketches.hll.Union; | ||
import org.apache.druid.error.DruidException; | ||
import org.apache.druid.jackson.DefaultTrueJsonIncludeFilter; | ||
import org.apache.druid.java.util.common.StringEncoding; | ||
import org.apache.druid.java.util.common.StringEncodingDefaultUTF16LEJsonIncludeFilter; | ||
|
@@ -62,6 +63,31 @@ public abstract class HllSketchAggregatorFactory extends AggregatorFactory | |
private final boolean shouldFinalize; | ||
private final boolean round; | ||
|
||
HllSketchAggregatorFactory( | ||
final String name, | ||
final String fieldName, | ||
@Nullable final Integer lgK, | ||
@Nullable final String tgtHllType, | ||
@Nullable final StringEncoding stringEncoding, | ||
final Boolean shouldFinalize, | ||
final boolean round, | ||
final int maxLgK | ||
) | ||
{ | ||
this(name, fieldName, lgK, tgtHllType, stringEncoding, shouldFinalize, round); | ||
|
||
if (this.lgK > maxLgK) { | ||
throw DruidException.forPersona(DruidException.Persona.USER) | ||
.ofCategory(DruidException.Category.INVALID_INPUT) | ||
.build( | ||
"LgK value [%s] for HLL sketch cannot be greater than [%s]. Reduce the lgK value" | ||
adarshsanjeev marked this conversation as resolved.
Show resolved
Hide resolved
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. Please mention the name as well. |
||
+ " or increase the runtime property druid.sketch.config.hllMaxLgK", | ||
this.lgK, | ||
maxLgK | ||
); | ||
} | ||
} | ||
|
||
HllSketchAggregatorFactory( | ||
final String name, | ||
final String fieldName, | ||
|
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.
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.
This should be an ingestion time property only.
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.
The lgK can be specified during query time as well, wouldn't it need to be limited to avoid running into similar issues?
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.
I think its more of a ingestion time check only since what we want to avoid is huge rows in the generated segments which increasing the segment sizes which in turn decrease query performance.