Skip to content
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

Merged
merged 1 commit into from
Mar 31, 2016
Merged

Implement native in filter #2577

merged 1 commit into from
Mar 31, 2016

Conversation

navis
Copy link
Contributor

@navis navis commented Mar 2, 2016

Currently, InDimFilter is translated to "or + selector filters". Value matcher can use hash set for faster filtering.

@Override
public boolean apply(String input)
{
return values.contains(Strings.nullToEmpty(input));
Copy link
Contributor

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 ?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

@nishantmonu51 nishantmonu51 self-assigned this Mar 14, 2016
new DefaultDimensionSpec(dimension, dimension)
);
if (dimensionSelector == null) {
return new BooleanValueMatcher(values.contains(Strings.nullToEmpty(null)));
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Member

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 ?

Copy link
Contributor Author

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.

@fjy
Copy link
Contributor

fjy commented Mar 14, 2016

👍

@nishantmonu51
Copy link
Member

👍 after travis, @navis please squash commits.

@navis
Copy link
Contributor Author

navis commented Mar 21, 2016

@nishantmonu51 squashed

@nishantmonu51
Copy link
Member

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)
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

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....

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverted that

@gianm
Copy link
Contributor

gianm commented Mar 24, 2016

would be nice to see some additional tests too, especially tests involving null handling.

@gianm gianm added this to the 0.9.1 milestone Mar 24, 2016
@gianm
Copy link
Contributor

gianm commented Mar 28, 2016

Looks good other than some minor comments and a desire for tests.

@gianm
Copy link
Contributor

gianm commented Mar 30, 2016

👍, 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.

@navis
Copy link
Contributor Author

navis commented Mar 31, 2016

rebased to master and squashed

@gianm
Copy link
Contributor

gianm commented Mar 31, 2016

👍

@gianm gianm merged commit 5f9240f into apache:master Mar 31, 2016
@navis navis deleted the native-in-filter branch March 31, 2016 09:12
sirpkt pushed a commit to sirpkt/druid that referenced this pull request Apr 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants