Package org.aksw.iguana.cc.utils.files
Class IndexedQueryReader
java.lang.Object
org.aksw.iguana.cc.utils.files.IndexedQueryReader
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.
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 Summary
Modifier and TypeMethodDescriptionstatic IndexedQueryReader
Indexes every non-empty line inside the given file.static IndexedQueryReader
makeWithEmptyLines
(Path filepath) Indexes every bundle of lines inside the file, that are in between two empty lines (including the beginning and end of the file).static IndexedQueryReader
makeWithStringSeparator
(Path filepath, String separator) Indexes each content in between two of the given separators (including the beginning and end of the file).This method returns a list of strings that contains every indexed content.readQuery
(int index) Returns the indexed content with the given index.int
size()
Returns the number of indexed content.streamQuery
(int index)
-
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 fileseparator
- 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 emptyIOException
-
makeWithEmptyLines
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
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
Returns the indexed content with the given index.- Parameters:
index
- the index of the searched content- Returns:
- the searched content
- Throws:
IOException
-
streamQuery
- Throws:
IOException
-
readQueries
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
-