Skip to content

Commit

Permalink
update caller
Browse files Browse the repository at this point in the history
  • Loading branch information
haiqi96 committed Jun 7, 2024
1 parent f98b37a commit c578324
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions components/core/src/clp/clp/IrDecompression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,32 @@ bool decompress_ir(CommandLineArguments& command_line_args, string const& file_o
archive_reader.open(archive_path.string());
archive_reader.refresh_dictionaries();

auto ir_output_handler = [&](
boost::filesystem::path const& src_ir_path,
string const& file_orig_id,
size_t begin_message_ix,
size_t end_message_ix
) {
auto dest_ir_file_name = file_orig_id + "_";
dest_ir_file_name += std::to_string(begin_message_ix) + "_";
dest_ir_file_name += std::to_string(end_message_ix) + "_";
dest_ir_file_name += ir::cIrFileExtension;

auto const dest_ir_path = output_dir / dest_ir_file_name;
try {
boost::filesystem::rename(src_ir_path , dest_ir_path);
} catch (boost::filesystem::filesystem_error const& e) {
SPDLOG_ERROR(
"Failed to rename from {} to {}. Error: {}",
src_ir_path.c_str(),
dest_ir_path.c_str(),
e.what()
);
return false;
}
return true;
};

// Decompress the split
auto file_metadata_ix_ptr = archive_reader.get_file_iterator_by_split_id(file_split_id);
if (false == file_metadata_ix_ptr->has_next()) {
Expand All @@ -80,9 +106,9 @@ bool decompress_ir(CommandLineArguments& command_line_args, string const& file_o
if (false
== file_decompressor.decompress_to_ir(
*file_metadata_ix_ptr,
command_line_args.get_output_dir(),
command_line_args.get_ir_temp_output_dir(),
archive_reader,
ir_output_handler,
command_line_args.get_ir_temp_output_dir(),
command_line_args.get_ir_target_size()
))
{
Expand Down

0 comments on commit c578324

Please sign in to comment.