Class AhoCorasick<T>

java.lang.Object
org.apache.nifi.util.search.ahocorasick.AhoCorasick<T>
All Implemented Interfaces:
Search<T>

public class AhoCorasick<T> extends Object implements Search<T>
  • Field Details

    • root

      private Node root
  • Constructor Details

    • AhoCorasick

      public AhoCorasick()
      Constructs a new search object.
      Throws:
      IllegalArgumentException - if given terms are null or empty
  • Method Details

    • initializeDictionary

      public void initializeDictionary(Set<SearchTerm<T>> terms)
      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 interface Search<T>
      Parameters:
      terms - the terms to create a dictionary of
    • addMatch

      private Node addMatch(SearchTerm<T> term, int offset, Node current)
    • initialize

      private void initialize()
    • search

      public SearchState search(InputStream stream, boolean findAll) throws IOException
      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 interface Search<T>
      Parameters:
      stream - the source data to scan for hits
      findAll - 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