Class AhoCorasick<T>
java.lang.Object
org.apache.nifi.util.search.ahocorasick.AhoCorasick<T>
- All Implemented Interfaces:
Search<T>
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate Node
addMatch
(SearchTerm<T> term, int offset, Node current) private void
void
initializeDictionary
(Set<SearchTerm<T>> terms) Establishes the dictionary of terms which will be searched in subsequent search calls.search
(InputStream stream, boolean findAll) Searches the given input stream for matches between the already specified dictionary and the contents scanned.private SearchState
search
(InputStream stream, boolean findAll, SearchState state)
-
Field Details
-
root
-
-
Constructor Details
-
AhoCorasick
public AhoCorasick()Constructs a new search object.- Throws:
IllegalArgumentException
- if given terms are null or empty
-
-
Method Details
-
initializeDictionary
Description copied from interface:Search
Establishes the dictionary of terms which will be searched in subsequent search calls. This can be called only once- Specified by:
initializeDictionary
in interfaceSearch<T>
- Parameters:
terms
- the terms to create a dictionary of
-
addMatch
-
initialize
private void initialize() -
search
Description copied from interface:Search
Searches the given input stream for matches between the already specified dictionary and the contents scanned.- Specified by:
search
in interfaceSearch<T>
- Parameters:
stream
- the source data to scan for hitsfindAll
- if true will find all matches if false will find only the first match- Returns:
- SearchState containing results Map might be empty which indicates no matches found but will not be null
- Throws:
IOException
- Thrown for any exceptions occurring while searching.
-
search
private SearchState search(InputStream stream, boolean findAll, SearchState state) throws IOException - Throws:
IOException
-