Don't tableize runautomatons.

tableizing means evaluation is strictly linear time O(inputLength),
but costs #states * alphabet in ram. alphabet here is unicode (64k) so it blows up huge.

With tableize=false, it just means evaluation is O(inputLength * log(numIntervals)).
This is plenty fast for our purposes.

For these same reasons lucene only tableizes ByteRunAutomaton (alphabet size=256)
by default, for CharRunAutomaton it defaults to false.

Ban the trappy RunAutomaton ctor that tableizes. Fix tests using it.

Closes elastic/elasticsearch#739.

Original commit: elastic/x-pack-elasticsearch@28ab66b0ee
This commit is contained in:
Robert Muir 2015-02-25 12:31:54 -05:00
parent 82beae9c0c
commit c8a169e3be
3 changed files with 7 additions and 3 deletions

View File

@ -1,3 +1,7 @@
@defaultMessage Convert to URI @defaultMessage Convert to URI
java.net.URL#getPath() java.net.URL#getPath()
java.net.URL#getFile() java.net.URL#getFile()
@defaultMessage explicitly pass tableization parameter (use false if you do not know)
dk.brics.automaton.RunAutomaton#<init>(dk.brics.automaton.Automaton)

View File

@ -17,7 +17,7 @@ public class AutomatonPredicate implements Predicate<String> {
private final RunAutomaton automaton; private final RunAutomaton automaton;
public AutomatonPredicate(Automaton automaton) { public AutomatonPredicate(Automaton automaton) {
this(new RunAutomaton(automaton)); this(new RunAutomaton(automaton, false));
} }
public AutomatonPredicate(RunAutomaton automaton) { public AutomatonPredicate(RunAutomaton automaton) {

View File

@ -60,12 +60,12 @@ public class AutomatonsTests extends ElasticsearchTestCase {
} }
private void assertMatch(Automaton automaton, String text) { private void assertMatch(Automaton automaton, String text) {
RunAutomaton runAutomaton = new RunAutomaton(automaton); RunAutomaton runAutomaton = new RunAutomaton(automaton, false);
assertThat(runAutomaton.run(text), is(true)); assertThat(runAutomaton.run(text), is(true));
} }
private void assertMismatch(Automaton automaton, String text) { private void assertMismatch(Automaton automaton, String text) {
RunAutomaton runAutomaton = new RunAutomaton(automaton); RunAutomaton runAutomaton = new RunAutomaton(automaton, false);
assertThat(runAutomaton.run(text), is(false)); assertThat(runAutomaton.run(text), is(false));
} }