00001
00002
00003
00004 #ifndef AITOOLS_INVERTEDINDEX_POSTLIST_WRITER_HPP
00005 #define AITOOLS_INVERTEDINDEX_POSTLIST_WRITER_HPP
00006
00007 #include "Iterator.hpp"
00008 #include "NonCopyable.hpp"
00009 #include <boost/shared_ptr.hpp>
00010 #include <boost/filesystem.hpp>
00011 #include <cstdio>
00012
00013 namespace aitools {
00014 namespace invertedindex {
00015
00025 class PostlistWriter : public NonCopyable {
00026
00027 public:
00028
00029 typedef boost::shared_ptr<PostlistWriter> SharedPointer;
00030
00031 public:
00032
00036 PostlistWriter();
00037
00041 PostlistWriter(const bfs::path& path) throw (std::invalid_argument);
00042
00046 ~PostlistWriter();
00047
00048 public:
00049
00050 void close();
00051
00052 bool is_open() const;
00053
00054 void open(const bfs::path& path)
00055 throw (std::runtime_error, std::invalid_argument);
00056
00057 void write(Iterator::SharedPointer iterator);
00058
00059 const bfs::path& path() const;
00060
00061 bool ready() const;
00062
00063 uint64_t tell();
00064
00065 private:
00066
00067 FILE* file_;
00068 bfs::path path_;
00069
00070 };
00071
00072 }
00073 }
00074
00075 #endif // AITOOLS_INVERTEDINDEX_POSTLIST_WRITER_HPP