mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-16 07:46:27 -04:00
refactor(filesystem_writer): rename re-writing methods
This commit is contained in:
parent
e714e1f2f7
commit
a358a72a38
@ -94,7 +94,7 @@ class filesystem_writer_detail {
|
|||||||
compression_type compression, std::span<uint8_t const> data,
|
compression_type compression, std::span<uint8_t const> data,
|
||||||
std::optional<fragment_category::value_type> cat = std::nullopt,
|
std::optional<fragment_category::value_type> cat = std::nullopt,
|
||||||
block_compression_info* info = nullptr) = 0;
|
block_compression_info* info = nullptr) = 0;
|
||||||
virtual void write_section(
|
virtual void rewrite_section(
|
||||||
section_type type, compression_type compression,
|
section_type type, compression_type compression,
|
||||||
std::span<uint8_t const> data,
|
std::span<uint8_t const> data,
|
||||||
std::optional<fragment_category::value_type> cat = std::nullopt) = 0;
|
std::optional<fragment_category::value_type> cat = std::nullopt) = 0;
|
||||||
|
@ -453,7 +453,7 @@ void rewrite_filesystem(logger& lgr, dwarfs::reader::filesystem_v2 const& fs,
|
|||||||
if (recompress_block) {
|
if (recompress_block) {
|
||||||
log_recompress(s, cat);
|
log_recompress(s, cat);
|
||||||
|
|
||||||
writer.write_section(section_type::BLOCK, s->compression(),
|
writer.rewrite_section(section_type::BLOCK, s->compression(),
|
||||||
parser->section_data(*s), cat);
|
parser->section_data(*s), cat);
|
||||||
} else {
|
} else {
|
||||||
copy_compressed(s, cat);
|
copy_compressed(s, cat);
|
||||||
@ -491,7 +491,7 @@ void rewrite_filesystem(logger& lgr, dwarfs::reader::filesystem_v2 const& fs,
|
|||||||
} else {
|
} else {
|
||||||
if (opts.recompress_metadata && !from_none_to_none(s)) {
|
if (opts.recompress_metadata && !from_none_to_none(s)) {
|
||||||
log_recompress(s);
|
log_recompress(s);
|
||||||
writer.write_section(s->type(), s->compression(),
|
writer.rewrite_section(s->type(), s->compression(),
|
||||||
parser->section_data(*s));
|
parser->section_data(*s));
|
||||||
} else {
|
} else {
|
||||||
copy_compressed(s);
|
copy_compressed(s);
|
||||||
|
@ -595,7 +595,8 @@ class filesystem_writer_ final : public filesystem_writer_detail {
|
|||||||
std::span<uint8_t const> data,
|
std::span<uint8_t const> data,
|
||||||
std::optional<fragment_category::value_type> cat,
|
std::optional<fragment_category::value_type> cat,
|
||||||
block_compression_info* info) override;
|
block_compression_info* info) override;
|
||||||
void write_section(section_type type, compression_type compression,
|
void
|
||||||
|
rewrite_section(section_type type, compression_type compression,
|
||||||
std::span<uint8_t const> data,
|
std::span<uint8_t const> data,
|
||||||
std::optional<fragment_category::value_type> cat) override;
|
std::optional<fragment_category::value_type> cat) override;
|
||||||
void rewrite_block(delayed_data_fn_type data, size_t uncompressed_size,
|
void rewrite_block(delayed_data_fn_type data, size_t uncompressed_size,
|
||||||
@ -617,9 +618,8 @@ class filesystem_writer_ final : public filesystem_writer_detail {
|
|||||||
write_block_impl(fragment_category cat, shared_byte_buffer data,
|
write_block_impl(fragment_category cat, shared_byte_buffer data,
|
||||||
block_compressor const& bc, std::optional<std::string> meta,
|
block_compressor const& bc, std::optional<std::string> meta,
|
||||||
physical_block_cb_type physical_block_cb);
|
physical_block_cb_type physical_block_cb);
|
||||||
void
|
void rewrite_section_delayed_data(
|
||||||
write_section_delayed_data(section_type type, delayed_data_fn_type data,
|
section_type type, delayed_data_fn_type data, size_t uncompressed_size,
|
||||||
size_t uncompressed_size,
|
|
||||||
std::optional<fragment_category::value_type> cat);
|
std::optional<fragment_category::value_type> cat);
|
||||||
void on_block_merged(block_holder_type holder);
|
void on_block_merged(block_holder_type holder);
|
||||||
void write_section_impl(section_type type, shared_byte_buffer data);
|
void write_section_impl(section_type type, shared_byte_buffer data);
|
||||||
@ -744,6 +744,8 @@ size_t filesystem_writer_<LoggerPolicy>::mem_used() const {
|
|||||||
s += holder.value()->capacity();
|
s += holder.value()->capacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOG_VERBOSE << "mem_used: " << s;
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -921,7 +923,7 @@ void filesystem_writer_<LoggerPolicy>::check_block_compression(
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename LoggerPolicy>
|
template <typename LoggerPolicy>
|
||||||
void filesystem_writer_<LoggerPolicy>::write_section_delayed_data(
|
void filesystem_writer_<LoggerPolicy>::rewrite_section_delayed_data(
|
||||||
section_type type, delayed_data_fn_type data, size_t uncompressed_size,
|
section_type type, delayed_data_fn_type data, size_t uncompressed_size,
|
||||||
std::optional<fragment_category::value_type> cat) {
|
std::optional<fragment_category::value_type> cat) {
|
||||||
{
|
{
|
||||||
@ -931,8 +933,9 @@ void filesystem_writer_<LoggerPolicy>::write_section_delayed_data(
|
|||||||
pctx_ = prog_.create_context<compression_progress>();
|
pctx_ = prog_.create_context<compression_progress>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: do we still need this with the merger in place?
|
// TODO: this isn't currently working
|
||||||
while (mem_used() > options_.max_queue_size) {
|
while (mem_used() > options_.max_queue_size) {
|
||||||
|
LOG_VERBOSE << "waiting for queue to drain";
|
||||||
cond_.wait(lock);
|
cond_.wait(lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -951,14 +954,14 @@ void filesystem_writer_<LoggerPolicy>::write_section_delayed_data(
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename LoggerPolicy>
|
template <typename LoggerPolicy>
|
||||||
void filesystem_writer_<LoggerPolicy>::write_section(
|
void filesystem_writer_<LoggerPolicy>::rewrite_section(
|
||||||
section_type type, compression_type compression,
|
section_type type, compression_type compression,
|
||||||
std::span<uint8_t const> data,
|
std::span<uint8_t const> data,
|
||||||
std::optional<fragment_category::value_type> cat) {
|
std::optional<fragment_category::value_type> cat) {
|
||||||
auto bd = block_decompressor(compression, data);
|
auto bd = block_decompressor(compression, data);
|
||||||
auto uncompressed_size = bd.uncompressed_size();
|
auto uncompressed_size = bd.uncompressed_size();
|
||||||
|
|
||||||
write_section_delayed_data(
|
rewrite_section_delayed_data(
|
||||||
type,
|
type,
|
||||||
[bd = std::move(bd)]() mutable {
|
[bd = std::move(bd)]() mutable {
|
||||||
auto block = bd.start_decompression(malloc_byte_buffer::create());
|
auto block = bd.start_decompression(malloc_byte_buffer::create());
|
||||||
@ -972,7 +975,7 @@ template <typename LoggerPolicy>
|
|||||||
void filesystem_writer_<LoggerPolicy>::rewrite_block(
|
void filesystem_writer_<LoggerPolicy>::rewrite_block(
|
||||||
delayed_data_fn_type data, size_t uncompressed_size,
|
delayed_data_fn_type data, size_t uncompressed_size,
|
||||||
std::optional<fragment_category::value_type> cat) {
|
std::optional<fragment_category::value_type> cat) {
|
||||||
write_section_delayed_data(section_type::BLOCK, std::move(data),
|
rewrite_section_delayed_data(section_type::BLOCK, std::move(data),
|
||||||
uncompressed_size, cat);
|
uncompressed_size, cat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user