Skip to content

Commit

Permalink
clp-s: Ensure ArchiveWriterOption is fully initialized when splitting…
Browse files Browse the repository at this point in the history
… archives. (#462)

Co-authored-by: kirkrodrigues <2454684+kirkrodrigues@users.noreply.github.com>
  • Loading branch information
gibber9809 and kirkrodrigues authored Jun 25, 2024
1 parent 14d9234 commit 8a2c0a8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
24 changes: 8 additions & 16 deletions components/core/src/clp_s/JsonParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@

namespace clp_s {
JsonParser::JsonParser(JsonParserOption const& option)
: m_archives_dir(option.archives_dir),
m_num_messages(0),
m_compression_level(option.compression_level),
: m_num_messages(0),
m_target_encoded_size(option.target_encoded_size),
m_max_document_size(option.max_document_size),
m_timestamp_key(option.timestamp_key),
Expand All @@ -30,14 +28,13 @@ JsonParser::JsonParser(JsonParserOption const& option)
FileUtils::find_all_files(file_path, m_file_paths);
}

ArchiveWriterOption archive_writer_option;
archive_writer_option.archives_dir = m_archives_dir;
archive_writer_option.id = m_generator();
archive_writer_option.compression_level = option.compression_level;
archive_writer_option.print_archive_stats = option.print_archive_stats;
m_archive_options.archives_dir = option.archives_dir;
m_archive_options.compression_level = option.compression_level;
m_archive_options.print_archive_stats = option.print_archive_stats;
m_archive_options.id = m_generator();

m_archive_writer = std::make_unique<ArchiveWriter>(option.metadata_db);
m_archive_writer->open(archive_writer_option);
m_archive_writer->open(m_archive_options);
}

void JsonParser::parse_obj_in_array(ondemand::object line, int32_t parent_node_id) {
Expand Down Expand Up @@ -505,13 +502,8 @@ void JsonParser::store() {

void JsonParser::split_archive() {
m_archive_writer->close();

ArchiveWriterOption archive_writer_option;
archive_writer_option.archives_dir = m_archives_dir;
archive_writer_option.id = m_generator();
archive_writer_option.compression_level = m_compression_level;

m_archive_writer->open(archive_writer_option);
m_archive_options.id = m_generator();
m_archive_writer->open(m_archive_options);
}

} // namespace clp_s
4 changes: 1 addition & 3 deletions components/core/src/clp_s/JsonParser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,7 @@ class JsonParser {
void split_archive();

int m_num_messages;
int m_compression_level;
std::vector<std::string> m_file_paths;
std::string m_archives_dir;
std::string m_schema_tree_path;

Schema m_current_schema;
ParsedMessage m_current_parsed_message;
Expand All @@ -106,6 +103,7 @@ class JsonParser {

boost::uuids::random_generator m_generator;
std::unique_ptr<ArchiveWriter> m_archive_writer;
ArchiveWriterOption m_archive_options{};
size_t m_target_encoded_size;
size_t m_max_document_size;
bool m_structurize_arrays{false};
Expand Down

0 comments on commit 8a2c0a8

Please sign in to comment.