Example usage for org.apache.lucene.util.automaton TooComplexToDeterminizeException getMaxDeterminizedStates

List of usage examples for org.apache.lucene.util.automaton TooComplexToDeterminizeException getMaxDeterminizedStates

Introduction

In this page you can find the example usage for org.apache.lucene.util.automaton TooComplexToDeterminizeException getMaxDeterminizedStates.

Prototype

public int getMaxDeterminizedStates() 

Source Link

Document

Get the maximum number of allowed determinized states.

Usage

From source file:org.elasticsearch.xpack.core.security.support.AutomatonsTests.java

License:Open Source License

public void testSettingMaxDeterminizedStates() {
    try {//from  w  ww. j a  v a 2s . co m
        assertNotEquals(10000, Automatons.getMaxDeterminizedStates());
        // set to the min value
        Settings settings = Settings.builder().put(Automatons.MAX_DETERMINIZED_STATES_SETTING.getKey(), 10000)
                .build();
        Automatons.updateMaxDeterminizedStates(settings);
        assertEquals(10000, Automatons.getMaxDeterminizedStates());

        final List<String> names = new ArrayList<>(1024);
        for (int i = 0; i < 1024; i++) {
            names.add(randomAlphaOfLength(48));
        }
        TooComplexToDeterminizeException e = expectThrows(TooComplexToDeterminizeException.class,
                () -> Automatons.patterns(names));
        assertThat(e.getMaxDeterminizedStates(), equalTo(10000));
    } finally {
        Automatons.updateMaxDeterminizedStates(Settings.EMPTY);
        assertEquals(100000, Automatons.getMaxDeterminizedStates());
    }
}