ModErn Text Analysis
META Enumerates Textual Applications
string_list_writer.h
Go to the documentation of this file.
1 
10 #ifndef META_STRING_LIST_WRITER_H_
11 #define META_STRING_LIST_WRITER_H_
12 
13 #include <fstream>
14 #include <mutex>
15 #include <string>
16 
17 #include "meta/config.h"
19 #include "meta/util/disk_vector.h"
20 
21 namespace meta
22 {
23 namespace index
24 {
25 
32 {
33  public:
41  string_list_writer(const std::string& path, uint64_t size);
42 
47 
52 
58  void insert(uint64_t idx, const std::string& elem);
59 
60  private:
62  std::mutex mutex_;
63 
66 
68  uint64_t write_pos_;
69 
72 };
73 }
74 }
75 
76 #endif
std::mutex mutex_
Writes are internally synchronized.
Definition: string_list_writer.h:62
string_list_writer & operator=(string_list_writer &&)
May be move assigned.
Definition: string_list_writer.cpp:30
A class for writing large lists of strings to disk with an associated index file for fast random acce...
Definition: string_list_writer.h:31
uint64_t write_pos_
Keeps track of the write position.
Definition: string_list_writer.h:68
A stupid wrapper around a std::fstream to work around GCC&#39;s libstdc++ lacking move constructors for s...
Definition: moveable_stream.h:93
The ModErn Text Analysis toolkit is a suite of natural language processing, classification, information retrieval, data mining, and other applications of text processing.
Definition: analyzer.h:25
string_list_writer(const std::string &path, uint64_t size)
Constructs the writer, writing the string file to the given path.
Definition: string_list_writer.cpp:14
void insert(uint64_t idx, const std::string &elem)
Sets the string at idx to be elem.
Definition: string_list_writer.cpp:41
io::mofstream string_file_
The file containing the strings.
Definition: string_list_writer.h:65
util::disk_vector< uint64_t > index_
Index vector—stores byte positions.
Definition: string_list_writer.h:71