6 #ifndef TURI_SERIALIZATION_DIR_ARCHIVE_HPP 7 #define TURI_SERIALIZATION_DIR_ARCHIVE_HPP 13 #include <core/storage/fileio/fs_utils.hpp> 14 #include <core/storage/fileio/general_fstream.hpp> 30 namespace dir_archive_impl {
56 size_t version = (size_t)(-1);
57 std::vector<std::string> prefixes;
58 std::map<std::string, std::string> metadata;
119 void open_directory_for_write(std::string directory,
120 bool fail_on_existing =
false);
129 void open_directory_for_read(std::string directory);
136 std::string get_directory()
const;
142 std::string get_next_write_prefix();
150 std::string get_next_read_prefix();
171 void set_metadata(std::string key, std::string val);
177 bool get_metadata(std::string key, std::string& val)
const;
189 static void delete_archive(std::string directory);
197 static std::string get_directory_metadata(
198 std::string directory,
199 const std::string& key);
204 static bool directory_has_existing_archive(
205 const std::vector<std::pair<std::string, fileio::file_status> >& dircontents);
209 void set_close_callback(std::function<
void()>&);
211 void init_for_read(
const std::string& directory);
213 void init_for_write(
const std::string& directory);
215 void make_s3_read_cache(
const std::string& directory);
222 std::string m_directory;
227 std::unique_ptr<general_ofstream> m_objects_out;
232 std::unique_ptr<general_ifstream> m_objects_in;
235 size_t m_read_prefix_index = 0;
238 size_t m_write_prefix_index = 0;
241 std::unique_ptr<dir_archive> m_cache_archive;
244 std::function<void()> m_close_callback;
const char * DIR_ARCHIVE_INI_FILE
const char * DIR_ARCHIVE_OBJECTS_BIN