rajat315315 opened a new pull request, #16361:
URL: https://github.com/apache/lucene/pull/16361
Fixes: #16360
**Title:** Optimize transition lookup in `CompiledAutomaton.addTail`
**Description:**
### Summary
This PR optimizes the transition lookup in `CompiledAutomaton.addTail` by
replacing the linear scan with a binary search, addressing a `TODO` comment in
the codebase.
### Proposed Changes
- Replaced the $O(N)$ loop in `CompiledAutomaton.addTail` with a binary
search over the transitions using `automaton.getTransition(state, index,
transition)`.
- This reduces the lookup complexity from linear ($O(N)$) to logarithmic
($O(\log N)$) where $N$ is the number of outgoing transitions from the state.
### Testing
- Ran the unit test suite `TestCompiledAutomaton` to verify correctness:
```bash
./gradlew :lucene:core:test --tests
"org.apache.lucene.util.automaton.TestCompiledAutomaton"
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]