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

Support for anything-but/ignore-case #71

Merged
merged 14 commits into from
Feb 16, 2023
Merged

Support for anything-but/ignore-case #71

merged 14 commits into from
Feb 16, 2023

Conversation

schenksj
Copy link
Contributor

@schenksj schenksj commented Feb 4, 2023

Issue #, if available:

#70

Description of changes:

Add a case-insensitive anything-but construct:

{
  "detail": {
    "command_path": [ { "anything-but": {"equals-ignore-case": [ "c:\windows", "c:\Program Files" ] } } ]
  }
}

Benchmark / Performance (for source code changes):

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running software.amazon.event.ruler.Benchmarks
Reading citylots2
Read 213068 events
EXACT events/sec: 421083.0
WILDCARD events/sec: 298833.1
PREFIX events/sec: 415337.2
SUFFIX events/sec: 418601.2
EQUALS_IGNORE_CASE events/sec: 342553.1
NUMERIC events/sec: 250079.8
ANYTHING-BUT events/sec: 234398.2
ANYTHING-BUT-IGNORE-CASE events/sec: 235955.7
ANYTHING-BUT-PREFIX events/sec: 243506.3
ANYTHING-BUT-SUFFIX events/sec: 237269.5
COMPLEX_ARRAYS events/sec: 6953.7
PARTIAL_COMBO events/sec: 103230.6
COMBO events/sec: 4215.7
Reading citylots2
Read 213068 events
Finding Rules...
Lots: 10000
Lots: 20000
Lots: 30000
Lots: 40000
Lots: 50000
Lots: 60000
Lots: 70000
Lots: 80000
Lots: 90000
Lots: 100000
Lots: 110000
Lots: 120000
Lots: 130000
Lots: 140000
Lots: 150000
Lots: 160000
Lots: 170000
Lots: 180000
Lots: 190000
Lots: 200000
Lots: 210000
Lines: 213068, Msec: 6262
Events/sec: 34025.6
 Rules/sec: 238178.9
Before: 180.3
After: 861.4
Per rule: -1702
Turning JSON into field-lists...
Finding Rules...
Lines: 213068, Msec: 1350
Events/sec: 157828.1
Before: 196.0
After: 633.1
Per rule: -1092
Reading lines...
Finding Rules...
Lots: 10000
Lots: 20000
Lots: 30000
Lots: 40000
Lots: 50000
Lots: 60000
Lots: 70000
Lots: 80000
Lots: 90000
Lots: 100000
Lots: 110000
Lots: 120000
Lots: 130000
Lots: 140000
Lots: 150000
Lots: 160000
Lots: 170000
Lots: 180000
Lots: 190000
Lots: 200000
Lots: 210000
Lines: 213068, Msec: 686
Events/sec: 310594.8
 Rules/sec: 1131186087.5
Reading citylots2
Read 213068 events
Lots: 10000
Lots: 20000
Lots: 30000
Lots: 40000
Lots: 50000
Lots: 60000
Lots: 70000
Lots: 80000
Lots: 90000
Lots: 100000
Lots: 110000
Lots: 120000
Lots: 130000
Lots: 140000
Lots: 150000
Lots: 160000
Lots: 170000
Lots: 180000
Lots: 190000
Lots: 200000
Lots: 210000
Matched: 52527
Lines: 213068, Msec: 9141
Events/sec: 23309.0
Reading lines...
Finding Rules...
Lots: 10000
Lots: 20000
Lots: 30000
Lots: 40000
Lots: 50000
Lots: 60000
Lots: 70000
Lots: 80000
Lots: 90000
Lots: 100000
Lots: 110000
Lots: 120000
Lots: 130000
Lots: 140000
Lots: 150000
Lots: 160000
Lots: 170000
Lots: 180000
Lots: 190000
Lots: 200000
Lots: 210000
Lines: 213068, Msec: 5512
Events/sec: 38655.3
 Rules/sec: 270587.1
DEEP EXACT events/sec: 14285.7
Tests run: 10, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 130.768 sec


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@schenksj schenksj marked this pull request as draft February 4, 2023 00:32
@schenksj
Copy link
Contributor Author

schenksj commented Feb 4, 2023

Putting in draft until the issue and proposed syntax is reviewed

@baldawar
Copy link
Collaborator

baldawar commented Feb 6, 2023

Heads down on something this week. I'll be slow in replying. I'm unsure if anything-but-ignore-case is the right solution, but we can wrap up the discussion in #70

@schenksj schenksj marked this pull request as ready for review February 6, 2023 23:23
@schenksj
Copy link
Contributor Author

schenksj commented Feb 6, 2023

@baldawar -- the machine I'm on won't let me update the description, so I'll update the comments when I get on another machine. If you have a sec for feedback, I'd appreciate it!

@schenksj
Copy link
Contributor Author

schenksj commented Feb 7, 2023

updated benchmarks and usage comments

@schenksj schenksj changed the title Support for anything-but-ignore-case Support for anything-but/ignore-case Feb 7, 2023
@baldawar
Copy link
Collaborator

baldawar commented Feb 7, 2023

Thanks. I'll review this on Thursday (02/09). It wasn't obvious from the tests but if the implementation was a generic ignore-case or specific to anything-but: { "ignore-case" : [...]}. If it's the former, we need more tests for remaining matchers. If its the latter, then we need to document and have open issue on supporting ignore-case for all remaining matchers.

@schenksj
Copy link
Contributor Author

schenksj commented Feb 7, 2023

Thanks. I'll review this on Thursday (02/09). It wasn't obvious from the tests but if the implementation was a generic ignore-case or specific to anything-but: { "ignore-case" : [...]}. If it's the former, we need more tests for remaining matchers. If its the latter, then we need to document and have open issue on supporting ignore-case for all remaining matchers.

The PR's implementation is very much specific to anything-but (and not even anything-but/suffix, anything-but/prefix). I'm happy to open an issue unless you'd prefer a core team member to do the analysis?

README.md Outdated
```javascript
{
"detail": {
"state": [ { "anything-but": {"ignore-case": [ "Stopped", "OverLoaded" ] } } ]
Copy link
Collaborator

Choose a reason for hiding this comment

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

I didn't spot this earlier but this is different than the existing equals-ignore-case. While I'm on the fence, I think I still prefer using it over creating a new matcher. It's just weird that we'll have this one matcher that works with single value but then with arrays when use in conjunction with anything-but.

@timbray @jonessha any opinions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agreed, the one-off equals-ignore-case was the original motivation for the creating anything-but-ignore-case... Definitely flexible with this as it has impact for your forward looking vision.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Until Tim & Shawn object by Monday (Shawn is away this week), I'd favor going equals-ignore-case over ignore-case. Definitely will check back by monday EOD.

@baldawar
Copy link
Collaborator

baldawar commented Feb 9, 2023

On a high-level, this looks disconnected with rest of ruler's features. I think it'd be great if it creates some similarities with equals-ignore-case and support single value fields (instead of just arrays).

I'm also uncomfortable with the level of complexity AnythingBut is adding within the classes. Its ripe for refactoring, but I'd like that to be initiated only after we're aligned on functionality.

@schenksj
Copy link
Contributor Author

schenksj commented Feb 9, 2023

On a high-level, this looks disconnected with rest of ruler's features. I think it'd be great if it creates some similarities with equals-ignore-case and support single value fields (instead of just arrays).

Single-values are allowed (is reuses the parser for anything-but):
https://github.com/schenksj/event-ruler/blob/7ee1c70c9309e0063ddfe9eec962dd29fb80cfb3/src/main/software/amazon/event/ruler/JsonRuleCompiler.java#L445-L458

https://github.com/schenksj/event-ruler/blob/7ee1c70c9309e0063ddfe9eec962dd29fb80cfb3/src/test/software/amazon/event/ruler/JsonRuleCompilerTest.java#L120-L121

@schenksj
Copy link
Contributor Author

schenksj commented Feb 9, 2023

I'm also uncomfortable with the level of complexity AnythingBut is adding within the classes. Its ripe for refactoring, but I'd like that to be initiated only after we're aligned on functionality.

Fair! If anything-but itself needs to be re-written, I'll happily close this PR. Just let me know. It is helpful for my product, but not 100% mandatory yet.

@baldawar
Copy link
Collaborator

baldawar commented Feb 9, 2023

I'm also uncomfortable with the level of complexity AnythingBut is adding within the classes. Its ripe for refactoring, but I'd like that to be initiated only after we're aligned on functionality.
Fair! If anything-but itself needs to be re-written, I'll happily close this PR. Just let me know. It is helpful for my product, but not 100% mandatory yet.

If you see it as significant re-write, then definitely don't do it. I'd rather merge the PR as is. Even without considering the unintended time-investment it'll trigger, the coupling of the big rewrites w small feature isn't worth it.

Also, still want to make sure there's no objections on ignore-case vs equals-ignore-case before asking you make any more changes. Looking at the code and test itself, I didn't spot anything that sounded alarming.

Hoping waiting till Monday isn't an issue. Let me know if that's an incorrect assumption.

@schenksj
Copy link
Contributor Author

schenksj commented Feb 9, 2023

I'm also uncomfortable with the level of complexity AnythingBut is adding within the classes. Its ripe for refactoring, but I'd like that to be initiated only after we're aligned on functionality.
Fair! If anything-but itself needs to be re-written, I'll happily close this PR. Just let me know. It is helpful for my product, but not 100% mandatory yet.

If you see it as significant re-write, then definitely don't do it. I'd rather merge the PR as is. Even without considering the unintended time-investment it'll trigger, the coupling of the big rewrites w small feature isn't worth it.

Also, still want to make sure there's no objections on ignore-case vs equals-ignore-case before asking you make any more changes. Looking at the code and test itself, I didn't spot anything that sounded alarming.

Hoping waiting till Monday isn't an issue. Let me know if that's an incorrect assumption.

Sounds great! This whole thing has been pretty quick and painless so I'm up for a few more small changes. I can't really commit to help a lot on refactoring the state-machines (which I think would be necessary to really make anything-but less complicated) given all the oddness in existing behavior around applying multiple to a single field. (the ones I mentioned on #69 )

@schenksj
Copy link
Contributor Author

This is a 5 minute search and replace so I'll go ahead and change the syntax to equals-ignore-case and will change it back if you get dissenters.

@schenksj
Copy link
Contributor Author

Hi @baldawar! Anything further on this PR?

@baldawar
Copy link
Collaborator

Sorry for not getting to this sooner. Just having a busy week. Should be able to merge by tomorrow morning & in maven by afternoon.

@baldawar
Copy link
Collaborator

In the meantime, as a sanity check, could you update the benchmark results. I'm not expecting anything egregious but just want to make sure it works.

@schenksj
Copy link
Contributor Author

In the meantime, as a sanity check, could you update the benchmark results. I'm not expecting anything egregious but just want to make sure it works.

no problem and done! I thought I had it up to date, but if not it is now :)

@baldawar baldawar merged commit 3b6202d into aws:main Feb 16, 2023
@baldawar
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants