You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2021/05/19 11:56:35 UTC
[GitHub] [lucene] glawson0 opened a new pull request #146: LUCENE-9963 Add tests for alternate path failures in FlattenGraphFilter
glawson0 opened a new pull request #146:
URL: https://github.com/apache/lucene/pull/146
<!--
_(If you are a project committer then you may remove some/all of the following template.)_
Before creating a pull request, please file an issue in the ASF Jira system for Lucene:
* https://issues.apache.org/jira/projects/LUCENE-9963
You will need to create an account in Jira in order to create an issue.
The title of the PR should reference the Jira issue number in the form:
* LUCENE-####: <short description of problem or changes>
LUCENE must be fully capitalized. A short description helps people scanning pull requests for items they can work on.
Properly referencing the issue in the title ensures that Jira is correctly updated with code review comments and commits. -->
# Description
Add tests for alternate path failures in FlattenGraphFilter.
Currently failing tests marked AwaitingFix so they will be ignored. Adding these tests before fix to allow others to also develop towards a fix.
# Solution
None
# Tests
Tests cover 3 problems that can arise for holes in alternate paths.
1) hole at start of path causes long path to not flatten correctly
2) hole at end of path causes long path to not move it's output point correctly
3) token stream ends before last shows up to end alternate path.
# Checklist
Please review the following and check all that apply:
- [x] I have reviewed the guidelines for [How to Contribute](https://wiki.apache.org/lucene/HowToContribute) and my code conforms to the standards described there to the best of my ability.
- [x] I have created a Jira issue and added the issue ID to my pull request title.
- [x] I have given Lucene maintainers [access](https://help.github.com/en/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork) to contribute to my PR branch. (optional but recommended)
- [x] I have developed this patch against the `main` branch.
- [x] I have run `./gradlew check`.
- [x] I have added tests for my changes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] mikemccand merged pull request #146: LUCENE-9963 Add tests for alternate path failures in FlattenGraphFilter
Posted by GitBox <gi...@apache.org>.
mikemccand merged pull request #146:
URL: https://github.com/apache/lucene/pull/146
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] mikemccand commented on pull request #146: LUCENE-9963 Add tests for alternate path failures in FlattenGraphFilter
Posted by GitBox <gi...@apache.org>.
mikemccand commented on pull request #146:
URL: https://github.com/apache/lucene/pull/146#issuecomment-869757664
> The branch this PR is built in has multiple commits. For clarity about the contents of the commit message should I squash these down before it gets merged or should I leave squashing commits to the person doing the merging?
No need for you to pre-squash -- we can do that when merging. GitHub gives us this convenient "Squash and Merge" (by default) button for just that.
I'll merge these added test cases soon. Thanks @gautamworah96!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] mikemccand commented on pull request #146: LUCENE-9963 Add tests for alternate path failures in FlattenGraphFilter
Posted by GitBox <gi...@apache.org>.
mikemccand commented on pull request #146:
URL: https://github.com/apache/lucene/pull/146#issuecomment-869757664
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] msokolov commented on a change in pull request #146: LUCENE-9963 Add tests for alternate path failures in FlattenGraphFilter
Posted by GitBox <gi...@apache.org>.
msokolov commented on a change in pull request #146:
URL: https://github.com/apache/lucene/pull/146#discussion_r635290159
##########
File path: lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestFlattenGraphFilter.java
##########
@@ -314,5 +314,116 @@ public void testTwoLongParallelPaths() throws Exception {
11);
}
+ // The end node the long path is supposed to flatten over doesn't exist
+ @AwaitsFix(bugUrl = "https://issues.apache.org/jira/browse/LUCENE-9963")
+ public void testAltPathFirstStepHole() throws Exception {
+ TokenStream in =
+ new CannedTokenStream(
+ 0,
+ 3,
+ new Token[] {token("abc", 1, 3, 0, 3), token("b", 1, 1, 1, 2), token("c", 1, 1, 2, 3)});
+
+ TokenStream out = new FlattenGraphFilter(in);
+
+ assertTokenStreamContents(
Review comment:
I'm curious to know what happens currently - how does the test fail? Could you maybe add a comment saying what the bad results are in each of these cases? Hmm I see you did in some cases below.
This stuff is crazy? TBH I am not all that familiar with how FlattenGraphFilter works, but I wonder if we could express some invariants cleanly and write a randomized test? There seem to be a lot of different edge cases.
##########
File path: lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestFlattenGraphFilter.java
##########
@@ -314,5 +314,116 @@ public void testTwoLongParallelPaths() throws Exception {
11);
}
+ // The end node the long path is supposed to flatten over doesn't exist
+ @AwaitsFix(bugUrl = "https://issues.apache.org/jira/browse/LUCENE-9963")
+ public void testAltPathFirstStepHole() throws Exception {
+ TokenStream in =
+ new CannedTokenStream(
+ 0,
+ 3,
+ new Token[] {token("abc", 1, 3, 0, 3), token("b", 1, 1, 1, 2), token("c", 1, 1, 2, 3)});
+
+ TokenStream out = new FlattenGraphFilter(in);
+
+ assertTokenStreamContents(
+ out,
+ new String[] {"abc", "b", "c"},
+ new int[] {0, 1, 2},
+ new int[] {3, 2, 3},
+ new int[] {1, 1, 1},
+ new int[] {3, 1, 1},
+ 3);
+ }
+ // Last node in an alt path releases the long path. but it doesn't exist in this graph
Review comment:
nit: add a blank line
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] mikemccand commented on a change in pull request #146: LUCENE-9963 Add tests for alternate path failures in FlattenGraphFilter
Posted by GitBox <gi...@apache.org>.
mikemccand commented on a change in pull request #146:
URL: https://github.com/apache/lucene/pull/146#discussion_r659244839
##########
File path: lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestFlattenGraphFilter.java
##########
@@ -314,5 +323,221 @@ public void testTwoLongParallelPaths() throws Exception {
11);
}
+ // The end node the long path is supposed to flatten over doesn't exist
+ // assert disabled = pos length of abc = 4
+ // assert enabled = AssertionError: outputEndNode=3 vs inputTo=2
+ @AwaitsFix(bugUrl = "https://issues.apache.org/jira/browse/LUCENE-9963")
+ public void testAltPathFirstStepHole() throws Exception {
+ TokenStream in =
+ new CannedTokenStream(
+ 0,
+ 3,
+ new Token[] {token("abc", 1, 3, 0, 3), token("b", 1, 1, 1, 2), token("c", 1, 1, 2, 3)});
+
+ TokenStream out = new FlattenGraphFilter(in);
+
+ assertTokenStreamContents(
+ out,
+ new String[] {"abc", "b", "c"},
+ new int[] {0, 1, 2},
+ new int[] {3, 2, 3},
+ new int[] {1, 1, 1},
+ new int[] {3, 1, 1},
+ 3);
+ }
+
+ // Last node in an alt path releases the long path. but it doesn't exist in this graph
+ // pos length of abc = 1
+ @AwaitsFix(bugUrl = "https://issues.apache.org/jira/browse/LUCENE-9963")
+ public void testAltPathLastStepHole() throws Exception {
+ TokenStream in =
+ new CannedTokenStream(
+ 0,
+ 4,
+ new Token[] {
+ token("abc", 1, 3, 0, 3),
+ token("a", 0, 1, 0, 1),
+ token("b", 1, 1, 1, 2),
+ token("d", 2, 1, 3, 4)
+ });
+
+ TokenStream out = new FlattenGraphFilter(in);
+
+ assertTokenStreamContents(
+ out,
+ new String[] {"abc", "a", "b", "d"},
+ new int[] {0, 0, 1, 3},
+ new int[] {1, 1, 2, 4},
+ new int[] {1, 0, 1, 2},
+ new int[] {3, 1, 1, 1},
+ 4);
+ }
+
+ // Posinc >2 gets squashed to 2
+ public void testLongHole() throws Exception {
+ TokenStream in =
+ new CannedTokenStream(
+ 0,
+ 28,
+ new Token[] {
+ token("hello", 1, 1, 0, 5), token("hole", 5, 1, 20, 24), token("fun", 1, 1, 25, 28),
+ });
+
+ TokenStream out = new FlattenGraphFilter(in);
+
+ assertTokenStreamContents(
+ out,
+ new String[] {"hello", "hole", "fun"},
+ new int[] {0, 20, 25},
+ new int[] {5, 24, 28},
+ new int[] {1, 2, 1},
+ new int[] {1, 1, 1},
+ 28);
+ }
+
+ // multiple nodes missing in the alt path. Last edge shows up after long edge and short edge,
+ // which looks good but the output graph isn't flat.
+ // assert disabled = nothing
+ // assert enabled = AssertionError
+ @AwaitsFix(bugUrl = "https://issues.apache.org/jira/browse/LUCENE-9963")
+ public void testAltPathLastStepLongHole() throws Exception {
+ TokenStream in =
+ new CannedTokenStream(
+ 0,
+ 4,
+ new Token[] {token("abc", 1, 3, 0, 3), token("a", 0, 1, 0, 1), token("d", 3, 1, 3, 4)});
+
+ TokenStream out = new FlattenGraphFilter(in);
+
+ assertTokenStreamContents(
+ out,
+ new String[] {"abc", "a", "d"},
+ new int[] {0, 0, 3},
+ new int[] {1, 1, 4},
+ new int[] {1, 0, 1},
+ new int[] {1, 1, 1},
+ 4);
+ }
+
+ // LUCENE-8723
+ // Token stream ends without last node showing up
+ // assert disabled = dropped token
+ // assert enabled = AssertionError: 2
+ @AwaitsFix(bugUrl = "https://issues.apache.org/jira/browse/LUCENE-9963")
+ public void testAltPathLastStepHoleWithoutEndToken() throws Exception {
+ TokenStream in =
+ new CannedTokenStream(
+ 0,
+ 2,
+ new Token[] {token("abc", 1, 3, 0, 3), token("a", 0, 1, 0, 1), token("b", 1, 1, 1, 2)});
+
+ TokenStream out = new FlattenGraphFilter(in);
+
+ assertTokenStreamContents(
+ out,
+ new String[] {"abc", "a", "b"},
+ new int[] {0, 0, 1},
+ new int[] {1, 1, 2},
+ new int[] {1, 0, 1},
+ new int[] {1, 1, 1},
+ 2);
+ }
+
+ private CharsRef buildMultiTokenCarRef(
Review comment:
Hmm the method name is mis-spelled -- `CharsRef` suffix instead of `CarRef`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] glawson0 commented on a change in pull request #146: LUCENE-9963 Add tests for alternate path failures in FlattenGraphFilter
Posted by GitBox <gi...@apache.org>.
glawson0 commented on a change in pull request #146:
URL: https://github.com/apache/lucene/pull/146#discussion_r636782125
##########
File path: lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestFlattenGraphFilter.java
##########
@@ -314,5 +314,116 @@ public void testTwoLongParallelPaths() throws Exception {
11);
}
+ // The end node the long path is supposed to flatten over doesn't exist
+ @AwaitsFix(bugUrl = "https://issues.apache.org/jira/browse/LUCENE-9963")
+ public void testAltPathFirstStepHole() throws Exception {
+ TokenStream in =
+ new CannedTokenStream(
+ 0,
+ 3,
+ new Token[] {token("abc", 1, 3, 0, 3), token("b", 1, 1, 1, 2), token("c", 1, 1, 2, 3)});
+
+ TokenStream out = new FlattenGraphFilter(in);
+
+ assertTokenStreamContents(
Review comment:
I've added a test that builds a graph then deletes some tokens. It already found another failure case in my fix.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] glawson0 commented on pull request #146: LUCENE-9963 Add tests for alternate path failures in FlattenGraphFilter
Posted by GitBox <gi...@apache.org>.
glawson0 commented on pull request #146:
URL: https://github.com/apache/lucene/pull/146#issuecomment-869533691
Thanks for the comments @mikemccand. The branch this PR is built in has multiple commits. For clarity about the contents of the commit message should I squash these down before it gets merged or should I leave squashing commits to the person doing the merging?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] mikemccand commented on pull request #146: LUCENE-9963 Add tests for alternate path failures in FlattenGraphFilter
Posted by GitBox <gi...@apache.org>.
mikemccand commented on pull request #146:
URL: https://github.com/apache/lucene/pull/146#issuecomment-869822018
OK I merged and backported to 8.x! Thanks @glawson0! Now let's try to also finish #157.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] mikemccand merged pull request #146: LUCENE-9963 Add tests for alternate path failures in FlattenGraphFilter
Posted by GitBox <gi...@apache.org>.
mikemccand merged pull request #146:
URL: https://github.com/apache/lucene/pull/146
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] mikemccand commented on a change in pull request #146: LUCENE-9963 Add tests for alternate path failures in FlattenGraphFilter
Posted by GitBox <gi...@apache.org>.
mikemccand commented on a change in pull request #146:
URL: https://github.com/apache/lucene/pull/146#discussion_r659244744
##########
File path: lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestFlattenGraphFilter.java
##########
@@ -314,5 +314,116 @@ public void testTwoLongParallelPaths() throws Exception {
11);
}
+ // The end node the long path is supposed to flatten over doesn't exist
+ @AwaitsFix(bugUrl = "https://issues.apache.org/jira/browse/LUCENE-9963")
+ public void testAltPathFirstStepHole() throws Exception {
+ TokenStream in =
+ new CannedTokenStream(
+ 0,
+ 3,
+ new Token[] {token("abc", 1, 3, 0, 3), token("b", 1, 1, 1, 2), token("c", 1, 1, 2, 3)});
+
+ TokenStream out = new FlattenGraphFilter(in);
+
+ assertTokenStreamContents(
Review comment:
Oh sorry I missed this -- yeah I was thinking we could manually invoke graphviz/dot, and perhaps it supports ascii art output, and then copy/paste manually that ascii art as a comment in our java sources. Seems like a long shot though!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] mikemccand commented on a change in pull request #146: LUCENE-9963 Add tests for alternate path failures in FlattenGraphFilter
Posted by GitBox <gi...@apache.org>.
mikemccand commented on a change in pull request #146:
URL: https://github.com/apache/lucene/pull/146#discussion_r638860944
##########
File path: lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestFlattenGraphFilter.java
##########
@@ -314,5 +314,116 @@ public void testTwoLongParallelPaths() throws Exception {
11);
}
+ // The end node the long path is supposed to flatten over doesn't exist
+ @AwaitsFix(bugUrl = "https://issues.apache.org/jira/browse/LUCENE-9963")
+ public void testAltPathFirstStepHole() throws Exception {
+ TokenStream in =
+ new CannedTokenStream(
+ 0,
+ 3,
+ new Token[] {token("abc", 1, 3, 0, 3), token("b", 1, 1, 1, 2), token("c", 1, 1, 2, 3)});
+
+ TokenStream out = new FlattenGraphFilter(in);
+
+ assertTokenStreamContents(
Review comment:
Phew, thanks @glawson0! This is super tricky. I wish we could inline little `.png` pictures of the graphs in each case. Maybe `graphviz`/`dot` supports ascii art output format?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] glawson0 commented on a change in pull request #146: LUCENE-9963 Add tests for alternate path failures in FlattenGraphFilter
Posted by GitBox <gi...@apache.org>.
glawson0 commented on a change in pull request #146:
URL: https://github.com/apache/lucene/pull/146#discussion_r639529557
##########
File path: lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestFlattenGraphFilter.java
##########
@@ -314,5 +314,116 @@ public void testTwoLongParallelPaths() throws Exception {
11);
}
+ // The end node the long path is supposed to flatten over doesn't exist
+ @AwaitsFix(bugUrl = "https://issues.apache.org/jira/browse/LUCENE-9963")
+ public void testAltPathFirstStepHole() throws Exception {
+ TokenStream in =
+ new CannedTokenStream(
+ 0,
+ 3,
+ new Token[] {token("abc", 1, 3, 0, 3), token("b", 1, 1, 1, 2), token("c", 1, 1, 2, 3)});
+
+ TokenStream out = new FlattenGraphFilter(in);
+
+ assertTokenStreamContents(
Review comment:
I couldn't find any tools within Lucene for visualizing `dot` graphs. There are a few tests that print out `dot` graphs when `tests.verbose=true`. I assume the idea is for the user to invoke graphviz themselves. We could continue with this pattern with the random and specific case tests. Is that what you're thinking about?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] glawson0 commented on a change in pull request #146: LUCENE-9963 Add tests for alternate path failures in FlattenGraphFilter
Posted by GitBox <gi...@apache.org>.
glawson0 commented on a change in pull request #146:
URL: https://github.com/apache/lucene/pull/146#discussion_r635828761
##########
File path: lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestFlattenGraphFilter.java
##########
@@ -314,5 +314,116 @@ public void testTwoLongParallelPaths() throws Exception {
11);
}
+ // The end node the long path is supposed to flatten over doesn't exist
+ @AwaitsFix(bugUrl = "https://issues.apache.org/jira/browse/LUCENE-9963")
+ public void testAltPathFirstStepHole() throws Exception {
+ TokenStream in =
+ new CannedTokenStream(
+ 0,
+ 3,
+ new Token[] {token("abc", 1, 3, 0, 3), token("b", 1, 1, 1, 2), token("c", 1, 1, 2, 3)});
+
+ TokenStream out = new FlattenGraphFilter(in);
+
+ assertTokenStreamContents(
Review comment:
A randomized test should be possible. We could build a random valid graph and try to flatten it. Checking offsets/length/increment would be difficult because the FlattenGraphFilter does change those as the graph gets "sausage-ized". You would have to know what tokens end up as edges between the same nodes in the final graph and what order they'ed be in.
An easy way to do this might be to start with a closed set of tokens, create a synonym dictionary dictionary with some random relations, pick some of the tokens to be stop words, add FlattenGraphFilter at the end, then generate some strings from your tokens and send them through.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org