Class CircuitBreakingOperations
Operations.determinize(Automaton, int).
Lucene's Operations.determinize can allocate memory proportional to the powerset of
the NFA states, which grows exponentially for certain patterns (e.g. .*a.*b.*c.*d.*).
The standard effort-based work limit (TooComplexToDeterminizeException) bounds CPU
work but does not directly bound memory. This class periodically estimates the memory consumed
by the growing DFA and intermediate data structures, checking the circuit breaker so that
construction is aborted before an OOM can occur.
The helper classes below (IntSet, FrozenIntSet, StateSet, etc.) are
copied from Lucene's package-private internals because they cannot be accessed from outside
org.apache.lucene.util.automaton.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic org.apache.lucene.util.automaton.Automatondeterminize(org.apache.lucene.util.automaton.Automaton a, int workLimit, CircuitBreaker circuitBreaker, String label) Determinizes the given automaton, periodically checking the provided circuit breaker.
-
Method Details
-
determinize
public static org.apache.lucene.util.automaton.Automaton determinize(org.apache.lucene.util.automaton.Automaton a, int workLimit, CircuitBreaker circuitBreaker, String label) Determinizes the given automaton, periodically checking the provided circuit breaker.This is functionally equivalent to
Operations.determinize(Automaton, int)but adds memory accounting. Temporary memory reserved on the breaker during construction is released before returning (or in the finally block on exception). The caller is responsible for accounting the final automaton'sramBytesUsed()separately.- Parameters:
a- the NFA to determinizeworkLimit- maximum "effort" before throwingTooComplexToDeterminizeExceptioncircuitBreaker- the circuit breaker to check (must not benull)label- descriptive label for circuit breaker error messages- Returns:
- the determinized automaton
- Throws:
org.apache.lucene.util.automaton.TooComplexToDeterminizeException- if effort exceedsworkLimitCircuitBreakingException- if the breaker trips
-