aitools::invertedindex::InvertedFileReader< Value > Class Template Reference

#include <InvertedFileReader.hpp>

List of all members.

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_

Detailed Description

template<typename Value>
class aitools::invertedindex::InvertedFileReader< Value >

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.

Author:
martin.trenkmann@uni-weimar.de

Created on Jun 22, 2008

Id
InvertedFileReader.hpp,v 1.7 2010/05/11 23:41:08 trenkman Exp

Definition at line 44 of file InvertedFileReader.hpp.


Constructor & Destructor Documentation

template<typename Value >
aitools::invertedindex::InvertedFileReader< Value >::InvertedFileReader (  )  [inline]

Definition at line 77 of file InvertedFileReader.hpp.

template<typename Value >
aitools::invertedindex::InvertedFileReader< Value >::InvertedFileReader ( const bfs::path &  path  )  throw (std::invalid_argument) [inline]

Definition at line 81 of file InvertedFileReader.hpp.

template<typename Value >
aitools::invertedindex::InvertedFileReader< Value >::~InvertedFileReader (  )  [inline]

Definition at line 88 of file InvertedFileReader.hpp.


Member Function Documentation

template<typename Value >
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().

Here is the caller graph for this function:

template<typename Value >
bool aitools::invertedindex::InvertedFileReader< Value >::is_open (  )  const [inline]

Definition at line 102 of file InvertedFileReader.hpp.

template<typename Value >
bool aitools::invertedindex::InvertedFileReader< Value >::next ( Record< Value > &  record  )  [inline, virtual]

Extracts the next record by resetting the content of the given record.

Parameters:
record A record to fill with new content.
Returns:
true if a new record could be extracted successfully, and false otherwise, which signals the end of the stream.

Implements aitools::invertedindex::RecordReader< Value >.

Definition at line 116 of file InvertedFileReader.hpp.

Referenced by BOOST_AUTO_TEST_CASE().

Here is the caller graph for this function:

template<typename Value >
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.

Parameters:
path The path of the file to be opened.

Implements aitools::invertedindex::RecordReader< Value >.

Definition at line 141 of file InvertedFileReader.hpp.

template<typename Value >
const bfs::path & aitools::invertedindex::InvertedFileReader< Value >::path (  )  const [inline]

Definition at line 109 of file InvertedFileReader.hpp.


Member Data Documentation

template<typename Value >
bfs::ifstream aitools::invertedindex::InvertedFileReader< Value >::ifs_ [private]

Definition at line 32 of file InvertedFileReader.hpp.

template<typename Value >
std::string aitools::invertedindex::InvertedFileReader< Value >::key_ [private]

Definition at line 33 of file InvertedFileReader.hpp.

template<typename Value >
bfs::path aitools::invertedindex::InvertedFileReader< Value >::path_ [private]

Definition at line 34 of file InvertedFileReader.hpp.


The documentation for this class was generated from the following file:
Generated on Wed May 30 15:07:37 2012 by  doxygen 1.6.3