-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: factor out
metadata_builder
from scanner
- Loading branch information
Showing
10 changed files
with
576 additions
and
267 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
/* vim:set ts=2 sw=2 sts=2 et: */ | ||
/** | ||
* \author Marcus Holland-Moritz ([email protected]) | ||
* \copyright Copyright (c) Marcus Holland-Moritz | ||
* | ||
* This file is part of dwarfs. | ||
* | ||
* dwarfs is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* dwarfs is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with dwarfs. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <cstdint> | ||
#include <memory> | ||
#include <span> | ||
#include <utility> | ||
#include <vector> | ||
|
||
namespace dwarfs { | ||
|
||
class logger; | ||
|
||
namespace writer { | ||
struct metadata_options; | ||
} | ||
|
||
namespace thrift::metadata { | ||
class metadata; | ||
} // namespace thrift::metadata | ||
|
||
namespace writer::internal { | ||
|
||
class inode_manager; | ||
class block_manager; | ||
class dir; | ||
|
||
class metadata_builder { | ||
public: | ||
metadata_builder(logger& lgr, metadata_options const& options); | ||
~metadata_builder(); | ||
|
||
void set_devices(std::vector<uint64_t> devices) { | ||
impl_->set_devices(std::move(devices)); | ||
} | ||
|
||
void set_symlink_table_size(size_t size) { | ||
impl_->set_symlink_table_size(size); | ||
} | ||
|
||
void set_block_size(uint32_t block_size) { | ||
impl_->set_block_size(block_size); | ||
} | ||
|
||
void set_total_fs_size(uint64_t total_fs_size) { | ||
impl_->set_total_fs_size(total_fs_size); | ||
} | ||
|
||
void set_total_hardlink_size(uint64_t total_hardlink_size) { | ||
impl_->set_total_hardlink_size(total_hardlink_size); | ||
} | ||
|
||
void set_shared_files_table(std::vector<uint32_t> shared_files) { | ||
impl_->set_shared_files_table(std::move(shared_files)); | ||
} | ||
|
||
void set_category_names(std::vector<std::string> category_names) { | ||
impl_->set_category_names(std::move(category_names)); | ||
} | ||
|
||
void set_block_categories(std::vector<uint32_t> block_categories) { | ||
impl_->set_block_categories(std::move(block_categories)); | ||
} | ||
|
||
void add_symlink_table_entry(size_t index, uint32_t entry) { | ||
impl_->add_symlink_table_entry(index, entry); | ||
} | ||
|
||
void gather_chunks(inode_manager const& im, block_manager const& bm, | ||
size_t chunk_count) { | ||
impl_->gather_chunks(im, bm, chunk_count); | ||
} | ||
|
||
void gather_entries(std::span<dir*> dirs, global_entry_data& ge_data, | ||
uint32_t num_inodes) { | ||
impl_->gather_entries(dirs, ge_data, num_inodes); | ||
} | ||
|
||
thrift::metadata::metadata const& build(global_entry_data& ge_data) { | ||
return impl_->build(ge_data); | ||
} | ||
|
||
class impl { | ||
public: | ||
virtual ~impl() = default; | ||
|
||
virtual void set_devices(std::vector<uint64_t> devices) = 0; | ||
virtual void set_symlink_table_size(size_t size) = 0; | ||
virtual void set_block_size(uint32_t block_size) = 0; | ||
virtual void set_total_fs_size(uint64_t total_fs_size) = 0; | ||
virtual void set_total_hardlink_size(uint64_t total_hardlink_size) = 0; | ||
virtual void set_shared_files_table(std::vector<uint32_t> shared_files) = 0; | ||
virtual void | ||
set_category_names(std::vector<std::string> category_names) = 0; | ||
virtual void | ||
set_block_categories(std::vector<uint32_t> block_categories) = 0; | ||
virtual void add_symlink_table_entry(size_t index, uint32_t entry) = 0; | ||
virtual void gather_chunks(inode_manager const& im, block_manager const& bm, | ||
size_t chunk_count) = 0; | ||
virtual void | ||
gather_entries(std::span<dir*> dirs, global_entry_data& ge_data, | ||
uint32_t num_inodes) = 0; | ||
|
||
virtual thrift::metadata::metadata const& | ||
build(global_entry_data& ge_data) = 0; | ||
}; | ||
|
||
private: | ||
std::unique_ptr<impl> impl_; | ||
}; | ||
|
||
} // namespace writer::internal | ||
|
||
} // namespace dwarfs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* vim:set ts=2 sw=2 sts=2 et: */ | ||
/** | ||
* \author Marcus Holland-Moritz ([email protected]) | ||
* \copyright Copyright (c) Marcus Holland-Moritz | ||
* | ||
* This file is part of dwarfs. | ||
* | ||
* dwarfs is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* dwarfs is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with dwarfs. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <cstddef> | ||
#include <cstdint> | ||
#include <functional> | ||
#include <optional> | ||
#include <string> | ||
#include <vector> | ||
|
||
#include <dwarfs/file_stat.h> | ||
#include <dwarfs/history_config.h> | ||
#include <dwarfs/writer/inode_options.h> | ||
|
||
namespace dwarfs::writer { | ||
|
||
class entry_interface; | ||
|
||
struct metadata_options { | ||
std::optional<file_stat::uid_type> uid; | ||
std::optional<file_stat::gid_type> gid; | ||
std::optional<uint64_t> timestamp; | ||
bool keep_all_times{false}; | ||
uint32_t time_resolution_sec{1}; | ||
bool pack_chunk_table{false}; | ||
bool pack_directories{false}; | ||
bool pack_shared_files_table{false}; | ||
bool plain_names_table{false}; | ||
bool pack_names{false}; | ||
bool pack_names_index{false}; | ||
bool plain_symlinks_table{false}; | ||
bool pack_symlinks{false}; | ||
bool pack_symlinks_index{false}; | ||
bool force_pack_string_tables{false}; | ||
bool no_create_timestamp{false}; | ||
size_t inode_size_cache_min_chunk_count{128}; | ||
}; | ||
|
||
} // namespace dwarfs::writer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.