Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for compressing CLP IR streams. #152

Merged
merged 128 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
02d2b48
Backup
haiqi96 May 4, 2023
21581c0
simple working version backup
haiqi96 May 5, 2023
5ff962e
backup
haiqi96 May 6, 2023
791cfee
Allow seeking beyond end of file
haiqi96 May 8, 2023
d542e47
Use BufferReader for Decoder
haiqi96 May 8, 2023
3cb8f7c
small clean up
haiqi96 May 8, 2023
21a37a0
Fixes but yet to verify
haiqi96 May 8, 2023
827c762
small clean up
haiqi96 May 8, 2023
1971ae4
Some refactoring and decompression looks ok
haiqi96 May 8, 2023
1764cfb
ok for compression
haiqi96 May 8, 2023
5319067
bug fix for proper compression
haiqi96 May 9, 2023
f616add
make error code interface matches with what's expected
haiqi96 May 9, 2023
8d2fce0
Support checkpoint in new file reader
haiqi96 May 10, 2023
d2fc530
Make existing clp code use checkpoint feature
haiqi96 May 10, 2023
921517a
updated some comments on potential improvements and add a temporary u…
haiqi96 May 11, 2023
38b0da7
remove eof flag
haiqi96 May 11, 2023
e663312
remove checkpoint related functions from readerbuffer
haiqi96 May 12, 2023
fd02a5f
refactor try_read logic
haiqi96 May 13, 2023
237bb3f
clean up
haiqi96 May 13, 2023
6cd7516
Allow more flexible reset and delay buffer loading for seek
haiqi96 May 14, 2023
eacad4a
refactor
haiqi96 May 14, 2023
dc0d91e
rename new file reader to something else
haiqi96 May 14, 2023
ccad421
More refactoring
haiqi96 May 15, 2023
2324a21
remove fstat dependency from libarchive reader
haiqi96 May 16, 2023
9e48e12
Remove code specific for BFR
haiqi96 May 16, 2023
57dd310
Remove BFR dependency on BR
haiqi96 May 16, 2023
d84276c
remove m_cursor and replace with buffer begin_pos
haiqi96 May 17, 2023
5845805
Add UTF8 utility to the FBR.
haiqi96 May 17, 2023
b90e0d6
replace UTF8 validation logic
haiqi96 May 18, 2023
e9230d0
Some personal preference
haiqi96 May 18, 2023
27af203
remove m_cursor and replace with buffer begin_pos
haiqi96 May 18, 2023
e82fbb4
int8_t -> char refactoring
haiqi96 May 19, 2023
1afc47c
further clean up
haiqi96 May 19, 2023
7868252
remove function that is unnecessary
haiqi96 May 19, 2023
10c1bad
checkpoint for profiling stuff
haiqi96 May 21, 2023
9119493
adding more comments and small refactoring
haiqi96 May 21, 2023
487bc49
Temporary Fix to disable string_view optimization
haiqi96 May 31, 2023
be7951a
Fix for code review
haiqi96 May 31, 2023
edc2acd
Missing fixes
haiqi96 May 31, 2023
e32d95e
Remove redundant constructor
haiqi96 May 31, 2023
fa0bb30
Address code review concern
haiqi96 Jun 1, 2023
6e5b013
BufferReader: Remove possibility for invalid internal buffer; Some cl…
kirkrodrigues Jul 17, 2023
ff52053
Initial change that utilizes BufferReader in the code.
haiqi96 Jul 25, 2023
47f9573
Small fix for read_to_delimiter
haiqi96 Jul 25, 2023
16637d1
simplification
haiqi96 Jul 25, 2023
3f8156f
Try to add some comments
haiqi96 Jul 26, 2023
e587427
Allow size=0 for BufferReader and simply part of the code
haiqi96 Jul 26, 2023
8bf1772
simplification by not requiring buffer to start from an aligned pos
haiqi96 Jul 30, 2023
d802310
My way of simplification
haiqi96 Jul 30, 2023
eae3cae
some other small refactoring
haiqi96 Jul 31, 2023
8f63dc2
Simplify away set buffer_size.
haiqi96 Jul 31, 2023
0776782
Simplify seek_from_begin
haiqi96 Jul 31, 2023
41b9bce
Maybe unnecessary simplification
haiqi96 Jul 31, 2023
0e6e00c
simplify BufferReader
haiqi96 Jul 31, 2023
ff0d016
optimize for buffer alignment
haiqi96 Jul 31, 2023
ca8c05a
Handle buffer combining case
haiqi96 Aug 1, 2023
84316d7
Small fixes
haiqi96 Aug 1, 2023
12ee687
First round of fixes
haiqi96 Aug 8, 2023
7877350
temporary test
haiqi96 Aug 8, 2023
ca7f48b
Fix and refactor for read_to_delim
haiqi96 Aug 8, 2023
f47613e
small touch
haiqi96 Aug 8, 2023
85f2fdc
Further refactoring
haiqi96 Aug 8, 2023
33689d3
Merge branch 'newFileReader' of https://github.com/haiqi96/clp_fork i…
haiqi96 Aug 8, 2023
749e652
small update to the temporary test
haiqi96 Aug 8, 2023
25e8dd0
small clean up
haiqi96 Aug 8, 2023
5aa4595
Refactored try_seek_from_begin function and made it consistent with d…
haiqi96 Aug 9, 2023
d74c631
Refill_buffer_reader refactor
haiqi96 Aug 9, 2023
0906e4d
Fix comments for test
haiqi96 Aug 9, 2023
504a030
fixes
haiqi96 Aug 9, 2023
66aa405
Apply clang-format to merge-conflict files
haiqi96 Aug 9, 2023
39d5af4
Merge branch 'main' into newFileReader
haiqi96 Aug 9, 2023
26b13f7
Apply clang-format to new classes
haiqi96 Aug 9, 2023
426dea3
Small cleanup
haiqi96 Aug 9, 2023
afff981
Some refactor for clang-tidy
haiqi96 Aug 10, 2023
4ca5bd8
Run clang-format on unit-test
haiqi96 Aug 10, 2023
f4a5cef
Replace unique ptr with vector
haiqi96 Aug 10, 2023
1e55966
Add error code to close function and some small refactoring
haiqi96 Aug 10, 2023
d8a50d4
fix
haiqi96 Aug 10, 2023
f3f9ca5
Manually cherrypick the changes
haiqi96 Aug 10, 2023
beb5640
Fix some clang-tidy issues
haiqi96 Aug 10, 2023
f49d7c1
more clean up
haiqi96 Aug 11, 2023
a3fbf31
Write missing docstrings and minor refactoring.
kirkrodrigues Aug 11, 2023
3e9f564
Return num_bytes_read correctly
haiqi96 Aug 12, 2023
8d7cc2c
merge
haiqi96 Aug 12, 2023
1c53b57
Clean-up BufferReader::try_read_to_delimiter
kirkrodrigues Aug 12, 2023
2fe5c77
BufferReader: Reorder methods according to guidelines.
kirkrodrigues Aug 12, 2023
36508b7
Libarchive*: Some clean-up.
kirkrodrigues Aug 13, 2023
47a5218
Undo unnecessary changes to ffi/ir_stream/encoding_methods.hpp
kirkrodrigues Aug 13, 2023
03991d7
Undo unnecessary changes and clean-up ffi/ir_stream/decoding_methods.*
kirkrodrigues Aug 13, 2023
a2ccc4d
Merge remote-tracking branch 'origin/newFileReader' into ir-decompres…
haiqi96 Aug 14, 2023
7bc93c9
Fixes
haiqi96 Aug 14, 2023
c1efd29
BufferedFileReader: Combine OperationFailed and OperationFailedWithMsg.
kirkrodrigues Aug 14, 2023
cf3c6e3
BufferedFileReader: Replace quantize_to_buffer_size with general method.
kirkrodrigues Aug 14, 2023
e5bc643
Remove include-grouping comments since clang-format handles it.
kirkrodrigues Aug 14, 2023
c8a9981
BufferedFileReader: Reset buffer reader even on EOF.
kirkrodrigues Aug 14, 2023
f28dea9
BufferedFileReader: Reduce indentation by rewriting branches.
kirkrodrigues Aug 14, 2023
8051ed2
BufferedFileReader: Return appropriate error code when trying to seek…
kirkrodrigues Aug 14, 2023
3aaf117
BufferedFileReader: Refactor refill_reader_buffer
kirkrodrigues Aug 14, 2023
9f97835
BufferedFileReader: Refactor resize_buffer_from_pos
kirkrodrigues Aug 14, 2023
53c5580
BufferedFileReader: Remaining refactoring
kirkrodrigues Aug 14, 2023
64d3a5d
BufferedFileReader: Fix docstrings
kirkrodrigues Aug 14, 2023
455b3cd
Replace off64_t with generic type.
kirkrodrigues Aug 14, 2023
08581d7
BufferedFileReader: Reorder methods according to guidelines.
kirkrodrigues Aug 14, 2023
c270b79
Make peek functions const
kirkrodrigues Aug 14, 2023
07fba97
Undo my mistake for close
kirkrodrigues Aug 14, 2023
1b5e51a
FileCompressor: Clean-up
kirkrodrigues Aug 14, 2023
9cdfe57
LibarchiveFileReader: Move new methods into the right section.
kirkrodrigues Aug 14, 2023
fd74ed9
LibarchiveReader: Space fix.
kirkrodrigues Aug 14, 2023
84028bb
BufferedFileReader: Basic refactor of unit tests.
kirkrodrigues Aug 14, 2023
ebf9d4b
East-const fixes.
kirkrodrigues Aug 14, 2023
492bd96
Fix macOS build issue.
kirkrodrigues Aug 14, 2023
e1787de
Add missing include.
kirkrodrigues Aug 14, 2023
b6c1c8a
Merge remote-tracking branch 'origin/newFileReader' into ir-decompres…
haiqi96 Aug 15, 2023
5e8cb40
clangformat
haiqi96 Aug 15, 2023
f76caf9
Merge remote-tracking branch 'origin/main' into ir-decompression-new
haiqi96 Aug 15, 2023
7c3dc03
remove unused functions
haiqi96 Aug 15, 2023
d45fd38
Undo formatting changes which should be they're own PR.
kirkrodrigues Aug 16, 2023
dd91a64
Fix includes
kirkrodrigues Aug 16, 2023
1e45fa6
another small clean up
haiqi96 Aug 16, 2023
6473e6e
Merge branch 'ir-decompression-new' of https://github.com/haiqi96/clp…
haiqi96 Aug 16, 2023
788bf36
small fixes
haiqi96 Aug 16, 2023
0629ea0
Refactoring/restructuring:
kirkrodrigues Aug 28, 2023
f8f587a
Address todos: Rename generic_parse_tokens -> deserialize_ir_message …
kirkrodrigues Aug 28, 2023
48d7b01
Add boost-outcome as submodule; LogEventDeserializer: Explicitly spec…
kirkrodrigues Aug 28, 2023
1170333
Clean-up LogEventDeserializer; Move template methods into cpp with ex…
kirkrodrigues Aug 29, 2023
7ae1e86
FileCompressor: Move template implementation into cpp with explicit s…
kirkrodrigues Aug 29, 2023
9e3e6b4
Archive: Move template implementation into cpp with explicit speciali…
kirkrodrigues Aug 29, 2023
8cbefa4
Remove unnecessary cAlwaysFalse const.
kirkrodrigues Aug 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@
[submodule "components/core/submodules/yaml-cpp"]
path = components/core/submodules/yaml-cpp
url = https://github.com/jbeder/yaml-cpp.git
[submodule "components/core/submodules/boost-outcome"]
path = components/core/submodules/boost-outcome
url = git@github.com:boostorg/outcome.git
34 changes: 34 additions & 0 deletions components/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,15 @@ set(SOURCE_FILES_clp
src/EncodedVariableInterpreter.cpp
src/EncodedVariableInterpreter.hpp
src/ErrorCode.hpp
src/ffi/encoding_methods.cpp
src/ffi/encoding_methods.hpp
src/ffi/encoding_methods.tpp
src/ffi/ir_stream/byteswap.hpp
src/ffi/ir_stream/decoding_methods.cpp
src/ffi/ir_stream/decoding_methods.hpp
src/ffi/ir_stream/decoding_methods.tpp
src/ffi/ir_stream/encoding_methods.cpp
src/ffi/ir_stream/encoding_methods.hpp
src/FileReader.cpp
src/FileReader.hpp
src/FileWriter.cpp
Expand All @@ -239,6 +248,11 @@ set(SOURCE_FILES_clp
src/GlobalMySQLMetadataDB.hpp
src/GlobalSQLiteMetadataDB.cpp
src/GlobalSQLiteMetadataDB.hpp
src/ir/LogEvent.hpp
src/ir/LogEventDeserializer.cpp
src/ir/LogEventDeserializer.hpp
src/ir/utils.cpp
src/ir/utils.hpp
src/LibarchiveFileReader.cpp
src/LibarchiveFileReader.hpp
src/LibarchiveReader.cpp
Expand Down Expand Up @@ -397,6 +411,12 @@ set(SOURCE_FILES_clg
src/EncodedVariableInterpreter.cpp
src/EncodedVariableInterpreter.hpp
src/ErrorCode.hpp
src/ffi/encoding_methods.cpp
src/ffi/encoding_methods.hpp
src/ffi/encoding_methods.tpp
src/ffi/ir_stream/decoding_methods.cpp
src/ffi/ir_stream/decoding_methods.hpp
src/ffi/ir_stream/decoding_methods.tpp
src/FileReader.cpp
src/FileReader.hpp
src/FileWriter.cpp
Expand All @@ -411,6 +431,7 @@ set(SOURCE_FILES_clg
src/GlobalSQLiteMetadataDB.hpp
src/Grep.cpp
src/Grep.hpp
src/ir/LogEvent.hpp
src/LogTypeDictionaryEntry.cpp
src/LogTypeDictionaryEntry.hpp
src/LogTypeDictionaryReader.cpp
Expand Down Expand Up @@ -554,12 +575,19 @@ set(SOURCE_FILES_clo
src/EncodedVariableInterpreter.cpp
src/EncodedVariableInterpreter.hpp
src/ErrorCode.hpp
src/ffi/encoding_methods.cpp
src/ffi/encoding_methods.hpp
src/ffi/encoding_methods.tpp
src/ffi/ir_stream/decoding_methods.cpp
src/ffi/ir_stream/decoding_methods.hpp
src/ffi/ir_stream/decoding_methods.tpp
src/FileReader.cpp
src/FileReader.hpp
src/FileWriter.cpp
src/FileWriter.hpp
src/Grep.cpp
src/Grep.hpp
src/ir/LogEvent.hpp
src/LogTypeDictionaryEntry.cpp
src/LogTypeDictionaryEntry.hpp
src/LogTypeDictionaryReader.cpp
Expand Down Expand Up @@ -726,6 +754,7 @@ set(SOURCE_FILES_unitTest
src/ffi/ir_stream/byteswap.hpp
src/ffi/ir_stream/decoding_methods.cpp
src/ffi/ir_stream/decoding_methods.hpp
src/ffi/ir_stream/decoding_methods.tpp
src/ffi/ir_stream/encoding_methods.cpp
src/ffi/ir_stream/encoding_methods.hpp
src/ffi/ir_stream/protocol_constants.hpp
Expand Down Expand Up @@ -757,6 +786,11 @@ set(SOURCE_FILES_unitTest
src/GlobalSQLiteMetadataDB.hpp
src/Grep.cpp
src/Grep.hpp
src/ir/LogEvent.hpp
src/ir/LogEventDeserializer.cpp
src/ir/LogEventDeserializer.hpp
src/ir/utils.cpp
src/ir/utils.hpp
src/LibarchiveFileReader.cpp
src/LibarchiveFileReader.hpp
src/LibarchiveReader.cpp
Expand Down
141 changes: 126 additions & 15 deletions components/core/src/EncodedVariableInterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
// Project headers
#include "Defs.h"
#include "ffi/encoding_methods.hpp"
#include "ffi/ir_stream/decoding_methods.hpp"
#include "spdlog_with_specializations.hpp"
#include "string_utils.hpp"
#include "type_utils.hpp"
Expand Down Expand Up @@ -207,24 +208,79 @@ void EncodedVariableInterpreter::encode_and_add_to_dictionary (const string& mes
// To avoid reallocating the logtype as we append to it, reserve enough space to hold the entire message
logtype_dict_entry.reserve_constant_length(message.length());
while (logtype_dict_entry.parse_next_var(message, var_begin_pos, var_end_pos, var_str)) {
// Encode variable
encoded_variable_t encoded_var;
if (convert_string_to_representable_integer_var(var_str, encoded_var)) {
logtype_dict_entry.add_int_var();
} else if (convert_string_to_representable_float_var(var_str, encoded_var)) {
logtype_dict_entry.add_float_var();
} else {
// Variable string looks like a dictionary variable, so encode it as so
variable_dictionary_id_t id;
var_dict.add_entry(var_str, id);
encoded_var = encode_var_dict_id(id);
var_ids.push_back(id);
auto encoded_var = encode_var(var_str, logtype_dict_entry, var_dict, var_ids);
encoded_vars.push_back(encoded_var);
}
}

logtype_dict_entry.add_dictionary_var();
}
template<typename encoded_variable_t>
void EncodedVariableInterpreter::encode_and_add_to_dictionary(
ir::LogEvent<encoded_variable_t> const& log_event,
LogTypeDictionaryEntry& logtype_dict_entry,
VariableDictionaryWriter& var_dict,
std::vector<ffi::eight_byte_encoded_variable_t>& encoded_vars,
std::vector<variable_dictionary_id_t>& var_ids,
size_t& raw_num_bytes
) {
logtype_dict_entry.clear();
logtype_dict_entry.reserve_constant_length(log_event.get_logtype().length());

raw_num_bytes = 0;

auto constant_handler = [&](std::string const& value, size_t begin_pos, size_t length) {
raw_num_bytes += length;
logtype_dict_entry.add_constant(value, begin_pos, length);
};

auto encoded_int_handler = [&](encoded_variable_t encoded_var) {
raw_num_bytes += ffi::decode_integer_var(encoded_var).length();
logtype_dict_entry.add_int_var();

ffi::eight_byte_encoded_variable_t eight_byte_encoded_var{};
if constexpr (std::is_same_v<encoded_variable_t, ffi::eight_byte_encoded_variable_t>) {
eight_byte_encoded_var = encoded_var;
} else { // std::is_same_v<encoded_variable_t, ffi::four_byte_encoded_variable_t>
eight_byte_encoded_var = ffi::encode_four_byte_integer_as_eight_byte(encoded_var);
}
encoded_vars.push_back(eight_byte_encoded_var);
};

auto encoded_float_handler = [&](ffi::four_byte_encoded_variable_t encoded_var) {
raw_num_bytes += ffi::decode_float_var(encoded_var).length();
logtype_dict_entry.add_float_var();

ffi::eight_byte_encoded_variable_t eight_byte_encoded_var{};
if constexpr (std::is_same_v<encoded_variable_t, ffi::eight_byte_encoded_variable_t>) {
eight_byte_encoded_var = encoded_var;
} else { // std::is_same_v<encoded_variable_t, ffi::four_byte_encoded_variable_t>
eight_byte_encoded_var = ffi::encode_four_byte_float_as_eight_byte(encoded_var);
}
encoded_vars.push_back(eight_byte_encoded_var);
};

auto dict_var_handler = [&](string const& dict_var) {
raw_num_bytes += dict_var.length();

ffi::eight_byte_encoded_variable_t encoded_var{};
if constexpr (std::is_same_v<encoded_variable_t, ffi::eight_byte_encoded_variable_t>) {
encoded_var = encode_var_dict_id(
add_dict_var(dict_var, logtype_dict_entry, var_dict, var_ids)
);
} else { // std::is_same_v<encoded_variable_t, ffi::four_byte_encoded_variable_t>
encoded_var = encode_var(dict_var, logtype_dict_entry, var_dict, var_ids);
}
encoded_vars.push_back(encoded_var);
}
};

ffi::ir_stream::generic_decode_message(
log_event.get_logtype(),
log_event.get_encoded_vars(),
log_event.get_dict_vars(),
constant_handler,
encoded_int_handler,
encoded_float_handler,
dict_var_handler
);
}

bool EncodedVariableInterpreter::decode_variables_into_message (const LogTypeDictionaryEntry& logtype_dict_entry, const VariableDictionaryReader& var_dict,
Expand Down Expand Up @@ -337,3 +393,58 @@ bool EncodedVariableInterpreter::wildcard_search_dictionary_and_get_encoded_matc
encoded_variable_t EncodedVariableInterpreter::encode_var_dict_id (variable_dictionary_id_t id) {
return bit_cast<encoded_variable_t>(id);
}

encoded_variable_t EncodedVariableInterpreter::encode_var(
string const& var,
LogTypeDictionaryEntry& logtype_dict_entry,
VariableDictionaryWriter& var_dict,
vector<variable_dictionary_id_t>& var_ids
) {
encoded_variable_t encoded_var{0};
if (convert_string_to_representable_integer_var(var, encoded_var)) {
logtype_dict_entry.add_int_var();
} else if (convert_string_to_representable_float_var(var, encoded_var)) {
logtype_dict_entry.add_float_var();
} else {
// Variable string looks like a dictionary variable, so encode it as so
encoded_var = encode_var_dict_id(add_dict_var(var, logtype_dict_entry, var_dict, var_ids));
}
return encoded_var;
}

variable_dictionary_id_t EncodedVariableInterpreter::add_dict_var(
string const& var,
LogTypeDictionaryEntry& logtype_dict_entry,
VariableDictionaryWriter& var_dict,
vector<variable_dictionary_id_t>& var_ids
) {
variable_dictionary_id_t id{cVariableDictionaryIdMax};
var_dict.add_entry(var, id);
var_ids.push_back(id);

logtype_dict_entry.add_dictionary_var();

return id;
}

// Explicitly declare template specializations so that we can define the
// template methods in this file
template
void EncodedVariableInterpreter::encode_and_add_to_dictionary<ffi::eight_byte_encoded_variable_t>(
ir::LogEvent<ffi::eight_byte_encoded_variable_t> const& log_event,
LogTypeDictionaryEntry& logtype_dict_entry,
VariableDictionaryWriter& var_dict,
std::vector<ffi::eight_byte_encoded_variable_t>& encoded_vars,
std::vector<variable_dictionary_id_t>& var_ids,
size_t& raw_num_bytes
);

template
void EncodedVariableInterpreter::encode_and_add_to_dictionary<ffi::four_byte_encoded_variable_t >(
ir::LogEvent<ffi::four_byte_encoded_variable_t> const& log_event,
LogTypeDictionaryEntry& logtype_dict_entry,
VariableDictionaryWriter& var_dict,
std::vector<ffi::eight_byte_encoded_variable_t>& encoded_vars,
std::vector<variable_dictionary_id_t>& var_ids,
size_t& raw_num_bytes
);
61 changes: 61 additions & 0 deletions components/core/src/EncodedVariableInterpreter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <vector>

// Project headers
#include "ir/LogEvent.hpp"
#include "Query.hpp"
#include "TraceableException.hpp"
#include "VariableDictionaryReader.hpp"
Expand Down Expand Up @@ -73,6 +74,32 @@ class EncodedVariableInterpreter {
*/
static void encode_and_add_to_dictionary (const std::string& message, LogTypeDictionaryEntry& logtype_dict_entry, VariableDictionaryWriter& var_dict,
std::vector<encoded_variable_t>& encoded_vars, std::vector<variable_dictionary_id_t>& var_ids);

/**
* Encodes the given IR log event, constructing a logtype dictionary entry,
* and adding any dictionary variables to the dictionary. NOTE: Four-byte
* encoded variables will be converted to eight-byte encoded variables.
* @tparam encoded_variable_t The type of the encoded variables in the log
* event
* @param log_event
* @param logtype_dict_entry
* @param var_dict
* @param encoded_vars A container to store the encoded variables in
* @param var_ids A container to store the dictionary IDs for dictionary
* variables
* @param raw_num_bytes Returns an estimate of the number of bytes that
* this log event would occupy if it was not encoded in CLP's IR
*/
template<typename encoded_variable_t>
static void encode_and_add_to_dictionary(
ir::LogEvent<encoded_variable_t> const& log_event,
LogTypeDictionaryEntry& logtype_dict_entry,
VariableDictionaryWriter& var_dict,
std::vector<ffi::eight_byte_encoded_variable_t>& encoded_vars,
std::vector<variable_dictionary_id_t>& var_ids,
size_t& raw_num_bytes
);

/**
* Decodes all variables and decompresses them into a message
* @param logtype_dict_entry
Expand Down Expand Up @@ -106,6 +133,40 @@ class EncodedVariableInterpreter {
*/
static bool wildcard_search_dictionary_and_get_encoded_matches (const std::string& var_wildcard_str, const VariableDictionaryReader& var_dict,
bool ignore_case, SubQuery& sub_query);

private:
/**
* Encodes the given string as a dictionary or non-dictionary variable and
* adds a corresponding placeholder to the logtype
* @param var
* @param logtype_dict_entry
* @param var_dict
* @param var_ids A container to add the dictionary ID to (if the string is
* a dictionary variable)
* @return The encoded variable
*/
static encoded_variable_t encode_var(
std::string const& var,
LogTypeDictionaryEntry& logtype_dict_entry,
VariableDictionaryWriter& var_dict,
std::vector<variable_dictionary_id_t>& var_ids
);

/**
* Adds the given string to the variable dictionary and adds a corresponding
* placeholder to logtype
* @param var
* @param logtype_dict_entry
* @param var_dict
* @param var_ids A container to add the dictionary ID to
* @return The dictionary ID
*/
static variable_dictionary_id_t add_dict_var(
std::string const& var,
LogTypeDictionaryEntry& logtype_dict_entry,
VariableDictionaryWriter& var_dict,
std::vector<variable_dictionary_id_t>& var_ids
);
};

#endif // ENCODEDVARIABLEINTERPRETER_HPP
Loading