Class IndexedQueryReader

java.lang.Object
org.aksw.iguana.cc.utils.files.IndexedQueryReader

public class IndexedQueryReader extends Object
This class creates objects, that index the start positions characters in between two given separators. A separator can be, for example "\n", which is the equivalent of indexing every line.
The beginning and the end of the file count as separators too.
Empty content in between two separators won't be indexed.
The start positions and the length of each indexed content will be stored in an internal array for later accessing.
  • Method Details

    • makeWithStringSeparator

      public static IndexedQueryReader makeWithStringSeparator(Path filepath, String separator) throws IOException
      Indexes each content in between two of the given separators (including the beginning and end of the file). The given separator isn't allowed to be empty.
      Parameters:
      filepath - path to the file
      separator - the separator line that is used in the file (isn't allowed to be empty)
      Returns:
      reader to access the indexed content
      Throws:
      IllegalArgumentException - the given separator was empty
      IOException
    • makeWithEmptyLines

      public static IndexedQueryReader makeWithEmptyLines(Path filepath) throws IOException
      Indexes every bundle of lines inside the file, that are in between two empty lines (including the beginning and end of the file).
      It uses the doubled line ending of the file as a separator, for example "\n\n".
      Parameters:
      filepath - path to the file
      Returns:
      reader to access the indexed content
      Throws:
      IOException
    • make

      public static IndexedQueryReader make(Path filepath) throws IOException
      Indexes every non-empty line inside the given file. It uses the line ending of the file as a separator.
      Parameters:
      filepath - path to the file
      Returns:
      reader to access the indexed lines
      Throws:
      IOException
    • readQuery

      public String readQuery(int index) throws IOException
      Returns the indexed content with the given index.
      Parameters:
      index - the index of the searched content
      Returns:
      the searched content
      Throws:
      IOException
    • streamQuery

      public InputStream streamQuery(int index) throws IOException
      Throws:
      IOException
    • readQueries

      public List<String> readQueries() throws IOException
      This method returns a list of strings that contains every indexed content.
      Returns:
      list of lines
      Throws:
      IOException
    • size

      public int size()
      Returns the number of indexed content.
      Returns:
      number of indexed objects