mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-13 14:27:30 -04:00
chore: allow access to thawed/unpacked metadata for rewriting
This commit is contained in:
parent
115f01d78b
commit
44644ebb0f
@ -60,6 +60,10 @@ class mmif;
|
|||||||
class os_access;
|
class os_access;
|
||||||
class performance_monitor;
|
class performance_monitor;
|
||||||
|
|
||||||
|
namespace thrift::metadata {
|
||||||
|
class metadata;
|
||||||
|
}
|
||||||
|
|
||||||
namespace reader {
|
namespace reader {
|
||||||
|
|
||||||
struct cache_tidy_config;
|
struct cache_tidy_config;
|
||||||
@ -473,6 +477,9 @@ class filesystem_v2 final : public filesystem_v2_lite {
|
|||||||
|
|
||||||
history const& get_history() const;
|
history const& get_history() const;
|
||||||
|
|
||||||
|
std::unique_ptr<thrift::metadata::metadata> thawed_metadata() const;
|
||||||
|
std::unique_ptr<thrift::metadata::metadata> unpacked_metadata() const;
|
||||||
|
|
||||||
class impl : public impl_lite {
|
class impl : public impl_lite {
|
||||||
public:
|
public:
|
||||||
virtual int
|
virtual int
|
||||||
@ -484,6 +491,10 @@ class filesystem_v2 final : public filesystem_v2_lite {
|
|||||||
virtual std::string serialize_metadata_as_json(bool simple) const = 0;
|
virtual std::string serialize_metadata_as_json(bool simple) const = 0;
|
||||||
virtual std::optional<std::span<uint8_t const>> header() const = 0;
|
virtual std::optional<std::span<uint8_t const>> header() const = 0;
|
||||||
virtual history const& get_history() const = 0;
|
virtual history const& get_history() const = 0;
|
||||||
|
virtual std::unique_ptr<thrift::metadata::metadata>
|
||||||
|
thawed_metadata() const = 0;
|
||||||
|
virtual std::unique_ptr<thrift::metadata::metadata>
|
||||||
|
unpacked_metadata() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -262,6 +262,10 @@ class metadata_v2_utils {
|
|||||||
|
|
||||||
std::string serialize_as_json(bool simple) const;
|
std::string serialize_as_json(bool simple) const;
|
||||||
|
|
||||||
|
std::unique_ptr<thrift::metadata::metadata> thaw() const;
|
||||||
|
|
||||||
|
std::unique_ptr<thrift::metadata::metadata> unpack() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
metadata_v2_data const& data_;
|
metadata_v2_data const& data_;
|
||||||
};
|
};
|
||||||
|
@ -332,6 +332,14 @@ class filesystem_ final {
|
|||||||
ir_.cache_blocks(block_numbers);
|
ir_.cache_blocks(block_numbers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<thrift::metadata::metadata> thawed_metadata() const {
|
||||||
|
return metadata_v2_utils(meta_).thaw();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<thrift::metadata::metadata> unpacked_metadata() const {
|
||||||
|
return metadata_v2_utils(meta_).unpack();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
filesystem_parser make_fs_parser() const {
|
filesystem_parser make_fs_parser() const {
|
||||||
return filesystem_parser(mm_, image_offset_, options_.image_size);
|
return filesystem_parser(mm_, image_offset_, options_.image_size);
|
||||||
@ -1354,6 +1362,13 @@ class filesystem_full_
|
|||||||
return fs().header();
|
return fs().header();
|
||||||
}
|
}
|
||||||
history const& get_history() const override { return history_; }
|
history const& get_history() const override { return history_; }
|
||||||
|
std::unique_ptr<thrift::metadata::metadata> thawed_metadata() const override {
|
||||||
|
return fs().thawed_metadata();
|
||||||
|
}
|
||||||
|
std::unique_ptr<thrift::metadata::metadata>
|
||||||
|
unpacked_metadata() const override {
|
||||||
|
return fs().unpacked_metadata();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
history history_;
|
history history_;
|
||||||
@ -1471,6 +1486,16 @@ history const& filesystem_v2::get_history() const {
|
|||||||
return full_().get_history();
|
return full_().get_history();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<thrift::metadata::metadata>
|
||||||
|
filesystem_v2::thawed_metadata() const {
|
||||||
|
return full_().thawed_metadata();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<thrift::metadata::metadata>
|
||||||
|
filesystem_v2::unpacked_metadata() const {
|
||||||
|
return full_().unpacked_metadata();
|
||||||
|
}
|
||||||
|
|
||||||
auto filesystem_v2::full_() const -> impl const& { return this->as_<impl>(); }
|
auto filesystem_v2::full_() const -> impl const& { return this->as_<impl>(); }
|
||||||
|
|
||||||
} // namespace dwarfs::reader
|
} // namespace dwarfs::reader
|
||||||
|
@ -634,6 +634,14 @@ class metadata_v2_data {
|
|||||||
filesystem_info const* fsinfo,
|
filesystem_info const* fsinfo,
|
||||||
std::function<void(std::string const&, uint32_t)> const& icb) const;
|
std::function<void(std::string const&, uint32_t)> const& icb) const;
|
||||||
|
|
||||||
|
std::unique_ptr<thrift::metadata::metadata> unpack() const {
|
||||||
|
return std::make_unique<thrift::metadata::metadata>(unpack_metadata());
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<thrift::metadata::metadata> thaw() const {
|
||||||
|
return std::make_unique<thrift::metadata::metadata>(meta_.thaw());
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template <typename K>
|
template <typename K>
|
||||||
using set_type = phmap::flat_hash_set<K>;
|
using set_type = phmap::flat_hash_set<K>;
|
||||||
@ -2426,6 +2434,14 @@ std::string metadata_v2_utils::serialize_as_json(bool simple) const {
|
|||||||
return data_.serialize_as_json(simple);
|
return data_.serialize_as_json(simple);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<thrift::metadata::metadata> metadata_v2_utils::thaw() const {
|
||||||
|
return data_.thaw();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<thrift::metadata::metadata> metadata_v2_utils::unpack() const {
|
||||||
|
return data_.unpack();
|
||||||
|
}
|
||||||
|
|
||||||
metadata_v2::metadata_v2(
|
metadata_v2::metadata_v2(
|
||||||
logger& lgr, std::span<uint8_t const> schema, std::span<uint8_t const> data,
|
logger& lgr, std::span<uint8_t const> schema, std::span<uint8_t const> data,
|
||||||
metadata_options const& options, int inode_offset,
|
metadata_options const& options, int inode_offset,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user