This commit is contained in:
Marcus Holland-Moritz 2021-03-17 11:17:52 +01:00
parent daecc748db
commit aa323d2ed6
3 changed files with 15 additions and 15 deletions

View File

@ -149,15 +149,15 @@ class metadata_ final : public metadata_v2::impl {
file_index_offset_ - symlink_table_offset_)); file_index_offset_ - symlink_table_offset_));
} }
if (auto uft = meta_.unique_files_table()) { if (auto sfp = meta_.shared_files_table()) {
if (static_cast<int>(uft->size()) != if (static_cast<int>(sfp->size()) !=
(dev_index_offset_ - file_index_offset_)) { (dev_index_offset_ - file_index_offset_)) {
DWARFS_THROW( DWARFS_THROW(
runtime_error, runtime_error,
fmt::format( fmt::format(
"metadata inconsistency: number of files ({}) does not match " "metadata inconsistency: number of files ({}) does not match "
"device/chunk index delta ({} - {} = {})", "device/chunk index delta ({} - {} = {})",
uft->size(), dev_index_offset_, file_index_offset_, sfp->size(), dev_index_offset_, file_index_offset_,
dev_index_offset_ - file_index_offset_)); dev_index_offset_ - file_index_offset_));
} }
} else { } else {
@ -360,12 +360,12 @@ class metadata_ final : public metadata_v2::impl {
inode -= file_index_offset_; inode -= file_index_offset_;
if (auto uf = meta_.unique_files_table()) { if (auto sfp = meta_.shared_files_table()) {
if (inode < 0 or inode >= static_cast<int>(uf->size())) { if (inode < 0 or inode >= static_cast<int>(sfp->size())) {
return rv; return rv;
} }
inode = (*uf)[inode]; inode = (*sfp)[inode];
} }
if (inode >= 0 && if (inode >= 0 &&
@ -569,11 +569,11 @@ void metadata_<LoggerPolicy>::dump(
if (auto de = meta_.dir_entries()) { if (auto de = meta_.dir_entries()) {
os << "dir_entries: " << de->size() << std::endl; os << "dir_entries: " << de->size() << std::endl;
} }
if (auto uf = meta_.unique_files_table()) { if (auto sfp = meta_.shared_files_table()) {
os << "unique_files_table: " << uf->size() << std::endl; os << "shared_files_table: " << sfp->size() << std::endl;
std::vector<uint32_t> uni; std::vector<uint32_t> uni;
uni.resize(meta_.chunk_table().size()); uni.resize(meta_.chunk_table().size());
for (auto f : *uf) { for (auto f : *sfp) {
++uni.at(f); ++uni.at(f);
} }
os << "unique files: " << std::count(uni.begin(), uni.end(), 1) os << "unique files: " << std::count(uni.begin(), uni.end(), 1)
@ -740,7 +740,7 @@ void metadata_<LoggerPolicy>::walk_data_order_impl(
if (auto dep = meta_.dir_entries()) { if (auto dep = meta_.dir_entries()) {
// TODO: this is *even more complicated* now :-) // TODO: this is *even more complicated* now :-)
auto ufp = meta_.unique_files_table(); auto sfp = meta_.shared_files_table();
auto mid = auto mid =
std::stable_partition(entries.begin(), entries.end(), std::stable_partition(entries.begin(), entries.end(),
[de = *dep, beg = file_index_offset_, [de = *dep, beg = file_index_offset_,
@ -749,11 +749,11 @@ void metadata_<LoggerPolicy>::walk_data_order_impl(
return ino < beg or ino >= end; return ino < beg or ino >= end;
}); });
std::stable_sort(mid, entries.end(), std::stable_sort(mid, entries.end(),
[de = *dep, uf = *ufp, off = file_index_offset_]( [de = *dep, sf = *sfp, off = file_index_offset_](
auto const& a, auto const& b) { auto const& a, auto const& b) {
auto ia = de[a.first].inode_num() - off; auto ia = de[a.first].inode_num() - off;
auto ib = de[b.first].inode_num() - off; auto ib = de[b.first].inode_num() - off;
return uf[ia] < uf[ib]; return sf[ia] < sf[ib];
}); });
} else { } else {
std::sort(entries.begin(), entries.end(), std::sort(entries.begin(), entries.end(),

View File

@ -660,10 +660,10 @@ void scanner_<LoggerPolicy>::scan(filesystem_writer& fsw,
root->accept(sdv); root->accept(sdv);
sdv.pack(mv2, ge_data); sdv.pack(mv2, ge_data);
LOG_INFO << "saving unique files table..."; LOG_INFO << "saving shared files table...";
save_unique_files_visitor sufv(first_file_inode, first_device_inode); save_unique_files_visitor sufv(first_file_inode, first_device_inode);
root->accept(sufv); root->accept(sufv);
mv2.unique_files_table_ref() = std::move(sufv.get_unique_files()); mv2.shared_files_table_ref() = std::move(sufv.get_unique_files());
thrift::metadata::fs_options fsopts; thrift::metadata::fs_options fsopts;
fsopts.mtime_only = !options_.keep_all_times; fsopts.mtime_only = !options_.keep_all_times;

View File

@ -230,7 +230,7 @@ struct metadata {
/** /**
* Maps from file inode to chunk_table index * Maps from file inode to chunk_table index
*/ */
20: optional list<UInt32> unique_files_table, 20: optional list<UInt32> shared_files_table,
// TODO: add timestamp // TODO: add timestamp
// 21: optional UInt64 timestamp, // 21: optional UInt64 timestamp,