@@ -15,7 +15,8 @@ JsonParser::JsonParser(JsonParserOption const& option)
15
15
m_target_encoded_size (option.target_encoded_size),
16
16
m_max_document_size(option.max_document_size),
17
17
m_timestamp_key(option.timestamp_key),
18
- m_structurize_arrays(option.structurize_arrays) {
18
+ m_structurize_arrays(option.structurize_arrays),
19
+ m_record_log_order(option.record_log_order) {
19
20
if (false == FileUtils::validate_path (option.file_paths )) {
20
21
exit (1 );
21
22
}
@@ -447,6 +448,16 @@ bool JsonParser::parse() {
447
448
m_num_messages = 0 ;
448
449
size_t bytes_consumed_up_to_prev_archive = 0 ;
449
450
size_t bytes_consumed_up_to_prev_record = 0 ;
451
+
452
+ int32_t log_event_idx_node_id{};
453
+ auto add_log_event_idx_node = [&]() {
454
+ if (m_record_log_order) {
455
+ log_event_idx_node_id
456
+ = add_metadata_field (constants::cLogEventIdxName, NodeType::Integer);
457
+ }
458
+ };
459
+ add_log_event_idx_node ();
460
+
450
461
while (json_file_iterator.get_json (json_it)) {
451
462
m_current_schema.clear ();
452
463
@@ -468,12 +479,13 @@ bool JsonParser::parse() {
468
479
}
469
480
470
481
// Add log_event_idx field to metadata for record
471
- auto log_event_idx = add_metadata_field (constants::cLogEventIdxName, NodeType::Integer);
472
- m_current_parsed_message.add_value (
473
- log_event_idx,
474
- m_archive_writer->get_next_log_event_id ()
475
- );
476
- m_current_schema.insert_ordered (log_event_idx);
482
+ if (m_record_log_order) {
483
+ m_current_parsed_message.add_value (
484
+ log_event_idx_node_id,
485
+ m_archive_writer->get_next_log_event_id ()
486
+ );
487
+ m_current_schema.insert_ordered (log_event_idx_node_id);
488
+ }
477
489
478
490
// Some errors from simdjson are latent until trying to access invalid JSON fields.
479
491
// Instead of checking for an error every time we access a JSON field in parse_line we
@@ -504,6 +516,7 @@ bool JsonParser::parse() {
504
516
);
505
517
bytes_consumed_up_to_prev_archive = bytes_consumed_up_to_prev_record;
506
518
split_archive ();
519
+ add_log_event_idx_node ();
507
520
}
508
521
509
522
m_current_parsed_message.clear ();
0 commit comments