-
Notifications
You must be signed in to change notification settings - Fork 455
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
[4189] Fix colliding filters by updating match method for MultiCharSequenceFilter to iterate through all patterns for the most complete match and not return on the first pattern found #4188
Changes from 1 commit
caeb6f6
6086f86
1b9ea72
4b36d5f
8f0402a
2222592
604df47
dceb8da
64fe147
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,18 @@ import ( | |
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestPrefixCompositeR2Filter(t *testing.T) { | ||
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. Seems like a better place to add these test cases is in 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. Agreed, I also think the naming also isn't great. Is R2 naming only relevant internally to Uber? 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. Nah, there's R2 references aplenty in OSS world. |
||
id0 := "arachne_failures" | ||
id1 := "arachne_failures_by_rack" | ||
f, err := newMultiCharSequenceFilter([]byte("arachne_failures,arachne_failures_by_rack"), false) | ||
require.NoError(t, err) | ||
_, matches1 := f.matches([]byte(id0)) | ||
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. Maybe I'm understanding the requirement wrong: Should "arachne_failures" match "arachne_failures" or "arachne_failures_by_rack" ? If your expectation was to match with "arachne_failures" with "arachne_failures" then wouldn't "len(pattern) > len(bestPattern)" make it match "arachne_failures_by_rack" ? Follow-ups:
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. I think you're looking at an older commit possibly. "arachne_failures" should match with "arachne-failures" and "arachne_failures_by_rack" should match with "arachne_failures_by_rack" even if it also matches with other patterns in the filter since this pattern is the best match. In the latest commit I have tests for the length of the value in the returned byte array and with backwards set to true. 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. Gotcha! Yeah was looking at the older commit. Thanks for the update! |
||
require.True(t, matches1) | ||
_, matches2 := f.matches([]byte(id1)) | ||
require.True(t, matches2) | ||
|
||
} | ||
|
||
func TestNewFilterFromFilterValueInvalidPattern(t *testing.T) { | ||
inputs := []string{"ab]c[sdf", "abc[z-a]", "*con[tT]ains*"} | ||
for _, input := range inputs { | ||
|
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.
Nit: seems like the
bestPattern == nil
isn't neededThere 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.
Good catch, updated.