-
Notifications
You must be signed in to change notification settings - Fork 3.8k
make bitmap index usage optional for bloom filters #6633
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
Closed
Closed
Changes from all commits
Commits
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 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
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 |
|---|---|---|
|
|
@@ -26,28 +26,30 @@ | |
| import com.google.common.collect.RangeSet; | ||
| import com.google.common.collect.Sets; | ||
| import com.google.common.hash.HashCode; | ||
| import org.apache.druid.java.util.common.StringUtils; | ||
| import org.apache.druid.query.cache.CacheKeyBuilder; | ||
| import org.apache.druid.query.extraction.ExtractionFn; | ||
| import org.apache.druid.segment.filter.DimensionPredicateFilter; | ||
|
|
||
| import javax.annotation.Nullable; | ||
| import java.util.HashSet; | ||
| import java.util.Objects; | ||
|
|
||
| /** | ||
| */ | ||
| public class BloomDimFilter implements DimFilter | ||
| { | ||
|
|
||
| private final String dimension; | ||
| private final BloomKFilter bloomKFilter; | ||
| private final HashCode hash; | ||
| private final ExtractionFn extractionFn; | ||
| private final boolean useBitmapIndex; | ||
|
|
||
| @JsonCreator | ||
| public BloomDimFilter( | ||
| @JsonProperty("dimension") String dimension, | ||
| @JsonProperty("bloomKFilter") BloomKFilterHolder bloomKFilterHolder, | ||
| @JsonProperty("extractionFn") ExtractionFn extractionFn | ||
| @JsonProperty("extractionFn") ExtractionFn extractionFn, | ||
| @Nullable @JsonProperty("useBitmapIndex") Boolean useBitmapIndex | ||
| ) | ||
| { | ||
| Preconditions.checkArgument(dimension != null, "dimension must not be null"); | ||
|
|
@@ -56,6 +58,7 @@ public BloomDimFilter( | |
| this.bloomKFilter = bloomKFilterHolder.getFilter(); | ||
| this.hash = bloomKFilterHolder.getFilterHash(); | ||
| this.extractionFn = extractionFn; | ||
| this.useBitmapIndex = useBitmapIndex != null && useBitmapIndex; | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -153,7 +156,14 @@ public boolean applyNull() | |
| } | ||
| }, | ||
| extractionFn | ||
| ); | ||
| ) | ||
| { | ||
| @Override | ||
| public boolean supportsBitmapIndex(BitmapIndexSelector selector) | ||
| { | ||
| return useBitmapIndex; | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| @JsonProperty | ||
|
|
@@ -174,14 +184,17 @@ public ExtractionFn getExtractionFn() | |
| return extractionFn; | ||
| } | ||
|
|
||
|
|
||
| @Override | ||
| public String toString() | ||
| public RangeSet<String> getDimensionRangeSet(String dimension) | ||
| { | ||
| if (extractionFn != null) { | ||
| return StringUtils.format("%s(%s) = %s", extractionFn, dimension, hash.toString()); | ||
| } else { | ||
| return StringUtils.format("%s = %s", dimension, hash.toString()); | ||
| } | ||
| return null; | ||
|
Member
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. It would be better if you could add the |
||
| } | ||
|
|
||
| @Override | ||
| public HashSet<String> getRequiredColumns() | ||
| { | ||
| return Sets.newHashSet(dimension); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -193,36 +206,27 @@ public boolean equals(Object o) | |
| if (o == null || getClass() != o.getClass()) { | ||
| return false; | ||
| } | ||
|
|
||
| BloomDimFilter that = (BloomDimFilter) o; | ||
|
|
||
| if (!dimension.equals(that.dimension)) { | ||
| return false; | ||
| } | ||
| if (hash != null ? !hash.equals(that.hash) : that.hash != null) { | ||
| return false; | ||
| } | ||
| return extractionFn != null ? extractionFn.equals(that.extractionFn) : that.extractionFn == null; | ||
| } | ||
|
|
||
| @Override | ||
| public RangeSet<String> getDimensionRangeSet(String dimension) | ||
| { | ||
| return null; | ||
| return useBitmapIndex == that.useBitmapIndex && | ||
| Objects.equals(dimension, that.dimension) && | ||
| Objects.equals(hash, that.hash) && | ||
| Objects.equals(extractionFn, that.extractionFn); | ||
| } | ||
|
|
||
| @Override | ||
| public HashSet<String> getRequiredColumns() | ||
| public int hashCode() | ||
| { | ||
| return Sets.newHashSet(dimension); | ||
| return Objects.hash(dimension, hash, extractionFn, useBitmapIndex); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() | ||
| public String toString() | ||
| { | ||
| int result = dimension.hashCode(); | ||
| result = 31 * result + (hash != null ? hash.hashCode() : 0); | ||
| result = 31 * result + (extractionFn != null ? extractionFn.hashCode() : 0); | ||
| return result; | ||
| return "BloomDimFilter{" + | ||
| "dimension='" + dimension + '\'' + | ||
| ", hash=" + hash + | ||
| ", extractionFn=" + extractionFn + | ||
| ", useBitmapIndex=" + useBitmapIndex + | ||
| '}'; | ||
| } | ||
| } | ||
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
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.
There is no need to add this blank line.