Tony-X commented on code in PR #12909:
URL: https://github.com/apache/lucene/pull/12909#discussion_r1424472195


##########
lucene/core/src/test/org/apache/lucene/util/automaton/TestNFARunAutomaton.java:
##########
@@ -73,6 +73,37 @@ public void testWithRandomRegex() {
     }
   }
 
+  public void testRandomAccessTransition() {
+    Automaton nfa = new RegExp(AutomatonTestUtil.randomRegexp(random()), 
RegExp.NONE).toAutomaton();
+    while (nfa.isDeterministic()) {
+      nfa = new RegExp(AutomatonTestUtil.randomRegexp(random()), 
RegExp.NONE).toAutomaton();
+    }
+    NFARunAutomaton runAutomaton1, runAutomaton2;
+    runAutomaton1 = new NFARunAutomaton(nfa);
+    runAutomaton2 = new NFARunAutomaton(nfa);
+    assertRandomAccessTransition(runAutomaton1, runAutomaton2, 0, new 
HashSet<>());
+  }
+
+  private void assertRandomAccessTransition(
+      NFARunAutomaton automaton1, NFARunAutomaton automaton2, int state, 
Set<Integer> visited) {
+    if (visited.contains(state)) {
+      return;
+    }
+    visited.add(state);
+
+    Transition t1 = new Transition();
+    Transition t2 = new Transition();
+    automaton1.initTransition(state, t1);
+    automaton2.initTransition(state, t2);

Review Comment:
   > but I think with the current contract we always need to initTransition
   
   Well, not necessarily.  One can do the following without calling init. 
   
   ```
   var n = automaton2.getNumTransitions(state);
   automaton2.getTransition(state, i, t2);
   ```



-- 
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-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to