rmuir commented on PR #16816: URL: https://github.com/apache/lucene/pull/16816#issuecomment-6136536925
@msfroh i'd prefer if we didn't add a constructor (even private) taking this CompiledAutomaton. In modern java we don't need to do it this way anymore thanks to [JEP 513](https://openjdk.org/jeps/513). Here is one example for this case: ```java public AutomatonQuery(final Term term, Automaton automaton, boolean isBinary, RewriteMethod rewriteMethod) { // compute local variable before super() call var compiled = new CompiledAutomaton(automaton, false, true, isBinary); super(term.field(), specialCaseRewriteMethod(compiled, rewriteMethod)); this.term = term; this.automaton = automaton; this.automatonIsBinary = isBinary; this.compiled = compiled; // compiled may already reference the same Automaton instance; only count its bytes once. long automatonBytes = compiled.sharesAutomaton(automaton) ? 0L : automaton.ramBytesUsed(); this.ramBytesUsed = BASE_RAM_BYTES + term.ramBytesUsed() + automatonBytes + compiled.ramBytesUsed(); } ``` I hope we can take advantage of the feature to avoid odd workarounds just like here (i know we have some elsewhere too) -- 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]
