-
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
Implement native in filter #2577
Conversation
@Override | ||
public boolean apply(String input) | ||
{ | ||
return values.contains(Strings.nullToEmpty(input)); |
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.
can we add check for null ?
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.
values
cannot be null and Strings.nullToEmpty(input)
also cannot be null.
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.
values
may contain null, this should match ""
but with the current code it will not. Something should be translating null to empty within values
.
new DefaultDimensionSpec(dimension, dimension) | ||
); | ||
if (dimensionSelector == null) { | ||
return new BooleanValueMatcher(values.contains(Strings.nullToEmpty(null))); |
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.
you can just pass in empty string
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.
wanted to look same with line 69. I'll address that.
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 it a allowed for values to be empty set ?
should we consider empty set as equivalent to filtering against null ?
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.
could be regarded false for all values imo, but seeing it had thrown exception in OR filter in runtime in original implementation, it would be better to add precondition in InDimFilter
not to accept null or empty.
👍 |
👍 after travis, @navis please squash commits. |
@nishantmonu51 squashed |
Ah, It has merge conflicts. @navis can you rebase with the latest master ? |
@@ -462,13 +463,9 @@ public TimeseriesQueryBuilder filters(String dimensionName, String value) | |||
return this; | |||
} | |||
|
|||
public TimeseriesQueryBuilder filters(String dimensionName, String value, String... values) |
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.
IMO the old signature was better- it enforces at least one value must be passed in. an IN ()
with empty list seems strange to me and not very meaningful.
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 believe the old impl would actually have thrown an exception in this case. It would have tried to construct an empty OrFilter, which isn't allowed.
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.
ah I see you're checking this in InDimFilter's constructor. In that case why not keep value, values...
.
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.
reverted that
would be nice to see some additional tests too, especially tests involving null handling. |
Looks good other than some minor comments and a desire for tests. |
👍, looks good once the tests can compile. BaseFilterTest was adjusted in #2753 such that it could also test filtered aggregators; the tests need to call it a little differently since then. |
rebased to master and squashed |
👍 |
Currently, InDimFilter is translated to "or + selector filters". Value matcher can use hash set for faster filtering.