Tony-X commented on code in PR #12909: URL: https://github.com/apache/lucene/pull/12909#discussion_r1423089503
########## 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: maybe add a random flag here. For the RA API you don't strictly need to init, as long as you know the state and the index of the transition. -- 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