-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Adding filters for TimeBoundary on backend #3168
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
Merged
fjy
merged 10 commits into
apache:master
from
rajk-tetration:add-time-boundary-filter-discuss
Aug 15, 2016
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
1c6fb63
Adding filters for TimeBoundary on backend
c2c3292
updating TimeBoundaryQuery constructor in QueryHostFinderTest
3fc2ea0
add filter helpers
7ea155f
update filterSegments + test
8d014e5
Conditional filterSegment depending on whether a filter exists
2889bb5
Style changes
ae0a7b8
Trigger rebuild
2591097
Adding documentation for timeboundaryquery filtering
aca3e2c
added filter serialization to timeboundaryquery cache
6e42b41
code style changes
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
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 |
|---|---|---|
|
|
@@ -31,6 +31,7 @@ | |
| import io.druid.query.Result; | ||
| import io.druid.query.spec.MultipleIntervalSegmentSpec; | ||
| import io.druid.query.spec.QuerySegmentSpec; | ||
| import io.druid.query.filter.DimFilter; | ||
| import org.joda.time.DateTime; | ||
| import org.joda.time.Interval; | ||
|
|
||
|
|
@@ -52,13 +53,15 @@ public class TimeBoundaryQuery extends BaseQuery<Result<TimeBoundaryResultValue> | |
|
|
||
| private static final byte CACHE_TYPE_ID = 0x0; | ||
|
|
||
| private final DimFilter dimFilter; | ||
| private final String bound; | ||
|
|
||
| @JsonCreator | ||
| public TimeBoundaryQuery( | ||
| @JsonProperty("dataSource") DataSource dataSource, | ||
| @JsonProperty("intervals") QuerySegmentSpec querySegmentSpec, | ||
| @JsonProperty("bound") String bound, | ||
| @JsonProperty("filter") DimFilter dimFilter, | ||
|
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. This requires updating the timeboundary query documentation in docs/content/querying |
||
| @JsonProperty("context") Map<String, Object> context | ||
| ) | ||
| { | ||
|
|
@@ -70,13 +73,13 @@ public TimeBoundaryQuery( | |
| context | ||
| ); | ||
|
|
||
| this.dimFilter = dimFilter; | ||
| this.bound = bound == null ? "" : bound; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean hasFilters() | ||
| { | ||
| return false; | ||
| public boolean hasFilters() { | ||
| return dimFilter != null; | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -85,6 +88,12 @@ public String getType() | |
| return Query.TIME_BOUNDARY; | ||
| } | ||
|
|
||
| @JsonProperty("filter") | ||
| public DimFilter getDimensionsFilter() | ||
| { | ||
| return dimFilter; | ||
| } | ||
|
|
||
| @JsonProperty | ||
| public String getBound() | ||
| { | ||
|
|
@@ -98,6 +107,7 @@ public TimeBoundaryQuery withOverriddenContext(Map<String, Object> contextOverri | |
| getDataSource(), | ||
| getQuerySegmentSpec(), | ||
| bound, | ||
| dimFilter, | ||
| computeOverridenContext(contextOverrides) | ||
| ); | ||
| } | ||
|
|
@@ -109,6 +119,7 @@ public TimeBoundaryQuery withQuerySegmentSpec(QuerySegmentSpec spec) | |
| getDataSource(), | ||
| spec, | ||
| bound, | ||
| dimFilter, | ||
| getContext() | ||
| ); | ||
| } | ||
|
|
@@ -120,16 +131,21 @@ public Query<Result<TimeBoundaryResultValue>> withDataSource(DataSource dataSour | |
| dataSource, | ||
| getQuerySegmentSpec(), | ||
| bound, | ||
| dimFilter, | ||
| getContext() | ||
| ); | ||
| } | ||
|
|
||
| public byte[] getCacheKey() | ||
| { | ||
| final byte[] filterBytes = dimFilter == null ? new byte[]{} : dimFilter.getCacheKey(); | ||
| final byte[] boundBytes = StringUtils.toUtf8(bound); | ||
| return ByteBuffer.allocate(1 + boundBytes.length) | ||
| final byte delimiter = (byte) 0xff; | ||
| return ByteBuffer.allocate(2 + boundBytes.length + filterBytes.length) | ||
| .put(CACHE_TYPE_ID) | ||
| .put(boundBytes) | ||
| .put(delimiter) | ||
| .put(filterBytes) | ||
| .array(); | ||
| } | ||
|
|
||
|
|
@@ -211,6 +227,7 @@ public String toString() | |
| ", querySegmentSpec=" + getQuerySegmentSpec() + | ||
| ", duration=" + getDuration() + | ||
| ", bound=" + bound + | ||
| ", dimFilter=" + dimFilter + | ||
| '}'; | ||
| } | ||
|
|
||
|
|
@@ -233,6 +250,10 @@ public boolean equals(Object o) | |
| return false; | ||
| } | ||
|
|
||
| if (dimFilter != null ? !dimFilter.equals(that.dimFilter) : that.dimFilter != null) { | ||
| return false; | ||
| } | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
|
|
@@ -241,6 +262,7 @@ public int hashCode() | |
| { | ||
| int result = super.hashCode(); | ||
| result = 31 * result + bound.hashCode(); | ||
| result = 31 * result + (dimFilter != null ? dimFilter.hashCode() : 0); | ||
| return result; | ||
| } | ||
| } | ||
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
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.
Is there a reason this is an "and" filter rather than just
<filter>?Uh oh!
There was an error while loading. Please reload this page.
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 couldn't find an example of just using
"filter": <filter>anywhere else in the docs, for example in TimeSeries an actual filter is given. I can change it, just wanted to be consistent.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.
hmm, fair enough, I guess this style predated your edit so feel free to leave it that way.