#include <InvertedFileReader.hpp>
Public Member Functions | |
InvertedFileReader () | |
InvertedFileReader (const bfs::path &path) throw (std::invalid_argument) | |
~InvertedFileReader () | |
void | close () |
bool | is_open () const |
const bfs::path & | path () const |
bool | next (Record< Value > &record) |
void | open (const bfs::path &path) throw (std::invalid_argument) |
Private Attributes | |
bfs::ifstream | ifs_ |
std::string | key_ |
bfs::path | path_ |
This class parses the standard input file format. This file format is defined as a so called inverted file, a simple line-oriented text file. Each line, or so called postlist, begins with a key followed by a number of values. Key could be any sequence of characters whereas a value could be of different types of tuples, or so called entries aitools.invertedindex.PostlistEntry.
The delimiter between the key and the list of values is the whitespace. That means all characters from the beginning of a line to the first whitespace will be interpreted as the key (leading whitespaces omitted). Similar to this the list of values is also separated by whitespaces.
Informal Definition:
<key01>TAB<value01>TAB<value02>TAB<value03>LF <key02>TAB<value04>TAB<value05>LF <key03>TAB<value06>TAB<value07>TAB<value08>LF <key01>TAB<value09>TAB<value10>LF ...
Note that one entry may contain also whitespaces, for example a triple of (int
float
int
) primitive values. Therefore the template parameter Value
defines how to tokenize.
Furthermore the list of keys does not have to be unique whithin one or several input files. During the indexing process entries with the same key will be merged into one postlist. This procedure is very helpful for section-wise definition of postlists.
Created on Jun 22, 2008
Definition at line 44 of file InvertedFileReader.hpp.
aitools::invertedindex::InvertedFileReader< Value >::InvertedFileReader | ( | ) | [inline] |
Definition at line 77 of file InvertedFileReader.hpp.
aitools::invertedindex::InvertedFileReader< Value >::InvertedFileReader | ( | const bfs::path & | path | ) | throw (std::invalid_argument) [inline] |
Definition at line 81 of file InvertedFileReader.hpp.
aitools::invertedindex::InvertedFileReader< Value >::~InvertedFileReader | ( | ) | [inline] |
Definition at line 88 of file InvertedFileReader.hpp.
void aitools::invertedindex::InvertedFileReader< Value >::close | ( | ) | [inline, virtual] |
Closes the file currently associated with the object.
Implements aitools::invertedindex::RecordReader< Value >.
Definition at line 93 of file InvertedFileReader.hpp.
Referenced by BOOST_AUTO_TEST_CASE().
bool aitools::invertedindex::InvertedFileReader< Value >::is_open | ( | ) | const [inline] |
Definition at line 102 of file InvertedFileReader.hpp.
bool aitools::invertedindex::InvertedFileReader< Value >::next | ( | Record< Value > & | record | ) | [inline, virtual] |
Extracts the next record by resetting the content of the given record.
record | A record to fill with new content. |
Implements aitools::invertedindex::RecordReader< Value >.
Definition at line 116 of file InvertedFileReader.hpp.
Referenced by BOOST_AUTO_TEST_CASE().
void aitools::invertedindex::InvertedFileReader< Value >::open | ( | const bfs::path & | path | ) | throw (std::invalid_argument) [inline, virtual] |
Opens a file and initializes the reader to extract records. Invoking this method on an already opened file is illegal.
path | The path of the file to be opened. |
Implements aitools::invertedindex::RecordReader< Value >.
Definition at line 141 of file InvertedFileReader.hpp.
const bfs::path & aitools::invertedindex::InvertedFileReader< Value >::path | ( | ) | const [inline] |
Definition at line 109 of file InvertedFileReader.hpp.
bfs::ifstream aitools::invertedindex::InvertedFileReader< Value >::ifs_ [private] |
Definition at line 32 of file InvertedFileReader.hpp.
std::string aitools::invertedindex::InvertedFileReader< Value >::key_ [private] |
Definition at line 33 of file InvertedFileReader.hpp.
bfs::path aitools::invertedindex::InvertedFileReader< Value >::path_ [private] |
Definition at line 34 of file InvertedFileReader.hpp.