ModErn Text Analysis
META Enumerates Textual Applications
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
meta::index::string_list_writer Class Reference

A class for writing large lists of strings to disk with an associated index file for fast random access. More...

#include <string_list_writer.h>

Public Member Functions

 string_list_writer (const std::string &path, uint64_t size)
 Constructs the writer, writing the string file to the given path. More...
 
 string_list_writer (string_list_writer &&)
 May be move constructed.
 
string_list_writeroperator= (string_list_writer &&)
 May be move assigned.
 
void insert (uint64_t idx, const std::string &elem)
 Sets the string at idx to be elem. More...
 

Private Types

using ofstream = std::unique_ptr< std::ofstream >
 workaround for lack of move operators for gcc 4.8
 

Private Member Functions

std::ofstream & file ()
 
ofstream make_file (const std::string &path)
 

Private Attributes

std::mutex mutex_
 Writes are internally synchronized.
 
ofstream string_file_
 The file containing the strings.
 
uint64_t write_pos_
 Keeps track of the write position.
 
util::disk_vector< uint64_t > index_
 Index vector—stores byte positions.
 

Detailed Description

A class for writing large lists of strings to disk with an associated index file for fast random access.

This class is used for writing the output format read by the string_list class.

Constructor & Destructor Documentation

meta::index::string_list_writer::string_list_writer ( const std::string &  path,
uint64_t  size 
)

Constructs the writer, writing the string file to the given path.

The index file will go alongside that path.

Parameters
pathThe path to write the string file to.
sizeThe number of strings in the list (must be known)

Member Function Documentation

void meta::index::string_list_writer::insert ( uint64_t  idx,
const std::string &  elem 
)

Sets the string at idx to be elem.

Parameters
idx
elem
std::ofstream& meta::index::string_list_writer::file ( )
inlineprivate
Returns
a reference to the file stream
ofstream meta::index::string_list_writer::make_file ( const std::string &  path)
inlineprivate
Parameters
pathThe path to the file
Returns
a std::ofstream created from the file

The documentation for this class was generated from the following files: