Skip to content

Commit

Permalink
merging main into junhao PR
Browse files Browse the repository at this point in the history
  • Loading branch information
davemarco committed Oct 31, 2024
2 parents bf5e4c9 + 9e82372 commit ad306f2
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 7 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ target_include_directories(${CLP_FFI_JS_BIN_NAME} PRIVATE src/)

set(CLP_FFI_JS_SRC_MAIN
src/clp_ffi_js/ir/decoding_methods.cpp
src/clp_ffi_js/ir/IrStreamReader.cpp
src/clp_ffi_js/ir/StreamReader.cpp
)

Expand Down
4 changes: 2 additions & 2 deletions src/clp_ffi_js/ir/IrStreamReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,11 @@ IrStreamReader::IrStreamReader(
)},
m_ts_pattern{m_stream_reader_data_context->get_deserializer().get_timestamp_pattern()} {}

auto IrStreamReader::create_deserializer_and_data_context(
auto IrStreamReader::create_data_context(
std::unique_ptr<clp::streaming_compression::zstd::Decompressor>&& zstd_decompressor,
clp::Array<char>&& data_buffer
) -> StreamReaderDataContext<four_byte_encoded_variable_t> {
rewind_reader_and_verify_encoding_type(*zstd_decompressor);
rewind_reader_and_validate_encoding_type(*zstd_decompressor);

auto result{
clp::ir::LogEventDeserializer<four_byte_encoded_variable_t>::create(*zstd_decompressor)
Expand Down
2 changes: 1 addition & 1 deletion src/clp_ffi_js/ir/StreamReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ auto StreamReader::create(DataArrayTsType const& data_array) -> std::unique_ptr<

auto const version{get_version(*zstd_decompressor)};
if (version == "v0.0.0") {
auto stream_reader_data_context{IrStreamReader::create_deserializer_and_data_context(
auto stream_reader_data_context{IrStreamReader::create_data_context(
std::move(zstd_decompressor),
std::move(data_buffer)
)};
Expand Down
4 changes: 4 additions & 0 deletions src/clp_ffi_js/ir/StreamReader.hpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#ifndef CLP_FFI_JS_IR_STREAM_READER_HPP
#define CLP_FFI_JS_IR_STREAM_READER_HPP

#include <Array.hpp>
#include <cstddef>
#include <memory>

#include <emscripten/val.h>

namespace clp_ffi_js::ir {
using clp::ir::four_byte_encoded_variable_t;

EMSCRIPTEN_DECLARE_VAL_TYPE(DataArrayTsType);
EMSCRIPTEN_DECLARE_VAL_TYPE(DecodedResultsTsType);
EMSCRIPTEN_DECLARE_VAL_TYPE(FilteredLogEventMapTsType);
Expand Down Expand Up @@ -39,6 +42,7 @@ class StreamReader {
// Delete move assignment operator since it's also disabled in `clp::ir::LogEventDeserializer`.
auto operator=(StreamReader&&) -> StreamReader& = delete;

// Methods
/**
* @return The number of events buffered.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/clp_ffi_js/ir/decoding_methods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
namespace clp_ffi_js::ir {
auto get_version(clp::ReaderInterface& reader) -> std::string {
// The encoding type bytes must be consumed before the metadata can be read.
rewind_reader_and_verify_encoding_type(reader);
rewind_reader_and_validate_encoding_type(reader);

// Deserialize metadata bytes from preamble.
clp::ffi::ir_stream::encoded_tag_t metadata_type{};
Expand Down Expand Up @@ -54,7 +54,7 @@ auto get_version(clp::ReaderInterface& reader) -> std::string {
return version;
}

auto rewind_reader_and_verify_encoding_type(clp::ReaderInterface& reader) -> void {
auto rewind_reader_and_validate_encoding_type(clp::ReaderInterface& reader) -> void {
reader.seek_from_begin(0);

bool is_four_bytes_encoding{true};
Expand Down
8 changes: 7 additions & 1 deletion src/clp_ffi_js/ir/decoding_methods.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@

namespace clp_ffi_js::ir {
auto get_version(clp::ReaderInterface& reader) -> std::string;
auto rewind_reader_and_verify_encoding_type(clp::ReaderInterface& reader) -> void;
/**
* Rewinds the reader to the beginning and validates the CLP IR data encoding type.
* @param reader
* @throws ClpFfiJsException if the encoding type couldn't be decoded or the encoding type is
* unsupported.
*/
auto rewind_reader_and_validate_encoding_type(clp::ReaderInterface& reader) -> void;
} // namespace clp_ffi_js::ir

#endif // CLP_FFI_JS_IR_DECODING_METHODS_HPP

0 comments on commit ad306f2

Please sign in to comment.