diff --git a/src/clp_ffi_js/ir/StreamReaderDataContext.hpp b/src/clp_ffi_js/ir/StreamReaderDataContext.hpp index 091b0b05..c32ad35c 100644 --- a/src/clp_ffi_js/ir/StreamReaderDataContext.hpp +++ b/src/clp_ffi_js/ir/StreamReaderDataContext.hpp @@ -5,28 +5,26 @@ #include #include -#include -#include -#include +#include namespace clp_ffi_js::ir { /** * The data context for a `StreamReader`. It encapsulates a chain of the following resources: - * A `clp::ir::LogEventDeserializer` that reads from a - * `clp::streaming_compression::zstd::Decompressor`, which in turn reads from a `clp::Array`. - * @tparam encoded_variable_t Type of encoded variables encoded in the stream. + * An IR deserializer class that reads from a `clp::ReaderInterface`, which in turn reads from a + * `clp::Array`. + * @tparam Deserializer Type of deserializer. */ -template +template class StreamReaderDataContext { public: // Constructors StreamReaderDataContext( clp::Array&& data_buffer, - std::unique_ptr&& zstd_decompressor, - clp::ir::LogEventDeserializer deserializer + std::unique_ptr&& reader, + Deserializer deserializer ) : m_data_buffer{std::move(data_buffer)}, - m_zstd_decompressor{std::move(zstd_decompressor)}, + m_reader{std::move(reader)}, m_deserializer{std::move(deserializer)} {} // Disable copy constructor and assignment operator @@ -44,14 +42,12 @@ class StreamReaderDataContext { /** * @return A reference to the deserializer. */ - [[nodiscard]] auto get_deserializer() -> clp::ir::LogEventDeserializer& { - return m_deserializer; - } + [[nodiscard]] auto get_deserializer() -> Deserializer& { return m_deserializer; } private: clp::Array m_data_buffer; - std::unique_ptr m_zstd_decompressor; - clp::ir::LogEventDeserializer m_deserializer; + std::unique_ptr m_reader; + Deserializer m_deserializer; }; } // namespace clp_ffi_js::ir diff --git a/src/clp_ffi_js/ir/UnstructuredIrStreamReader.cpp b/src/clp_ffi_js/ir/UnstructuredIrStreamReader.cpp index 242d8472..9a5a8f95 100644 --- a/src/clp_ffi_js/ir/UnstructuredIrStreamReader.cpp +++ b/src/clp_ffi_js/ir/UnstructuredIrStreamReader.cpp @@ -39,9 +39,7 @@ auto UnstructuredIrStreamReader::create( std::unique_ptr&& zstd_decompressor, clp::Array data_array ) -> UnstructuredIrStreamReader { - auto result{ - clp::ir::LogEventDeserializer::create(*zstd_decompressor) - }; + auto result{UnstructuredIrDeserializer::create(*zstd_decompressor)}; if (result.has_error()) { auto const error_code{result.error()}; throw ClpFfiJsException{ @@ -55,7 +53,7 @@ auto UnstructuredIrStreamReader::create( ) }; } - auto data_context = StreamReaderDataContext( + auto data_context = StreamReaderDataContext( std::move(data_array), std::move(zstd_decompressor), std::move(result.value()) @@ -218,10 +216,10 @@ auto UnstructuredIrStreamReader::decode_range(size_t begin_idx, size_t end_idx, } UnstructuredIrStreamReader::UnstructuredIrStreamReader( - StreamReaderDataContext&& stream_reader_data_context + StreamReaderDataContext&& stream_reader_data_context ) : m_stream_reader_data_context{std::make_unique< - StreamReaderDataContext>( + StreamReaderDataContext>( std::move(stream_reader_data_context) )}, m_ts_pattern{m_stream_reader_data_context->get_deserializer().get_timestamp_pattern()} {} diff --git a/src/clp_ffi_js/ir/UnstructuredIrStreamReader.hpp b/src/clp_ffi_js/ir/UnstructuredIrStreamReader.hpp index 91b78eba..709e9a26 100644 --- a/src/clp_ffi_js/ir/UnstructuredIrStreamReader.hpp +++ b/src/clp_ffi_js/ir/UnstructuredIrStreamReader.hpp @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -17,6 +18,7 @@ namespace clp_ffi_js::ir { using clp::ir::four_byte_encoded_variable_t; +using UnstructuredIrDeserializer = clp::ir::LogEventDeserializer; /** * Mapping between an index in the filtered log events collection to an index in the unfiltered @@ -75,12 +77,12 @@ class UnstructuredIrStreamReader : public StreamReader { private: // Constructor explicit UnstructuredIrStreamReader( - StreamReaderDataContext&& stream_reader_data_context + StreamReaderDataContext&& stream_reader_data_context ); // Variables std::vector> m_encoded_log_events; - std::unique_ptr> + std::unique_ptr> m_stream_reader_data_context; FilteredLogEventsMap m_filtered_log_event_map; clp::TimestampPattern m_ts_pattern;