Skip to content

Commit

Permalink
Rename IRStreamReader -> IrStreamReader.
Browse files Browse the repository at this point in the history
  • Loading branch information
junhaoliao committed Oct 15, 2024
1 parent d1ed2f0 commit bf5e4c9
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ 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/IrStreamReader.cpp
src/clp_ffi_js/ir/StreamReader.cpp
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "IRStreamReader.hpp"
#include "IrStreamReader.hpp"

#include <algorithm>
#include <cstddef>
Expand Down Expand Up @@ -36,9 +36,9 @@ using namespace std::literals::string_literals;
using clp::ir::four_byte_encoded_variable_t;

namespace clp_ffi_js::ir {
auto IRStreamReader::create(DataArrayTsType const& data_array) -> IRStreamReader {
auto IrStreamReader::create(DataArrayTsType const& data_array) -> IrStreamReader {
auto const length{data_array["length"].as<size_t>()};
SPDLOG_INFO("IRStreamReader::create: got buffer of length={}", length);
SPDLOG_INFO("IrStreamReader::create: got buffer of length={}", length);

// Copy array from JavaScript to C++
clp::Array<char> data_buffer{length};
Expand All @@ -54,22 +54,22 @@ auto IRStreamReader::create(DataArrayTsType const& data_array) -> IRStreamReader
std::move(zstd_decompressor),
std::move(data_buffer)
)};
return IRStreamReader{std::move(stream_reader_data_context)};
return IrStreamReader{std::move(stream_reader_data_context)};
}

auto IRStreamReader::get_num_events_buffered() const -> size_t {
auto IrStreamReader::get_num_events_buffered() const -> size_t {
return m_encoded_log_events.size();
}

auto IRStreamReader::get_filtered_log_event_map() const -> FilteredLogEventMapTsType {
auto IrStreamReader::get_filtered_log_event_map() const -> FilteredLogEventMapTsType {
if (false == m_filtered_log_event_map.has_value()) {
return FilteredLogEventMapTsType{emscripten::val::null()};
}

return FilteredLogEventMapTsType{emscripten::val::array(m_filtered_log_event_map.value())};
}

void IRStreamReader::filter_log_events(emscripten::val const& log_level_filter) {
void IrStreamReader::filter_log_events(emscripten::val const& log_level_filter) {
if (log_level_filter.isNull()) {
m_filtered_log_event_map.reset();
return;
Expand All @@ -91,7 +91,7 @@ void IRStreamReader::filter_log_events(emscripten::val const& log_level_filter)
}
}

auto IRStreamReader::deserialize_stream() -> size_t {
auto IrStreamReader::deserialize_stream() -> size_t {
if (nullptr == m_stream_reader_data_context) {
return m_encoded_log_events.size();
}
Expand Down Expand Up @@ -151,7 +151,7 @@ auto IRStreamReader::deserialize_stream() -> size_t {
return m_encoded_log_events.size();
}

auto IRStreamReader::decode_range(size_t begin_idx, size_t end_idx, bool use_filter) const
auto IrStreamReader::decode_range(size_t begin_idx, size_t end_idx, bool use_filter) const
-> DecodedResultsTsType {
if (use_filter && false == m_filtered_log_event_map.has_value()) {
return DecodedResultsTsType{emscripten::val::null()};
Expand Down Expand Up @@ -203,7 +203,7 @@ auto IRStreamReader::decode_range(size_t begin_idx, size_t end_idx, bool use_fil
return DecodedResultsTsType(results);
}

IRStreamReader::IRStreamReader(
IrStreamReader::IrStreamReader(
StreamReaderDataContext<four_byte_encoded_variable_t>&& stream_reader_data_context
)
: m_stream_reader_data_context{std::make_unique<
Expand All @@ -212,7 +212,7 @@ 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_deserializer_and_data_context(
std::unique_ptr<clp::streaming_compression::zstd::Decompressor>&& zstd_decompressor,
clp::Array<char>&& data_buffer
) -> StreamReaderDataContext<four_byte_encoded_variable_t> {
Expand Down Expand Up @@ -241,24 +241,24 @@ auto IRStreamReader::create_deserializer_and_data_context(
} // namespace clp_ffi_js::ir

namespace {
EMSCRIPTEN_BINDINGS(ClpIRStreamReader) {
EMSCRIPTEN_BINDINGS(ClpIrStreamReader) {
emscripten::class_<
clp_ffi_js::ir::IRStreamReader,
emscripten::base<clp_ffi_js::ir::StreamReader>>("ClpIRStreamReader")
clp_ffi_js::ir::IrStreamReader,
emscripten::base<clp_ffi_js::ir::StreamReader>>("ClpIrStreamReader")
.constructor(
&clp_ffi_js::ir::IRStreamReader::create,
&clp_ffi_js::ir::IrStreamReader::create,
emscripten::return_value_policy::take_ownership()
)
.function(
"getNumEventsBuffered",
&clp_ffi_js::ir::IRStreamReader::get_num_events_buffered
&clp_ffi_js::ir::IrStreamReader::get_num_events_buffered
)
.function(
"getFilteredLogEventMap",
&clp_ffi_js::ir::IRStreamReader::get_filtered_log_event_map
&clp_ffi_js::ir::IrStreamReader::get_filtered_log_event_map
)
.function("filterLogEvents", &clp_ffi_js::ir::IRStreamReader::filter_log_events)
.function("deserializeStream", &clp_ffi_js::ir::IRStreamReader::deserialize_stream)
.function("decodeRange", &clp_ffi_js::ir::IRStreamReader::decode_range);
.function("filterLogEvents", &clp_ffi_js::ir::IrStreamReader::filter_log_events)
.function("deserializeStream", &clp_ffi_js::ir::IrStreamReader::deserialize_stream)
.function("decodeRange", &clp_ffi_js::ir::IrStreamReader::decode_range);
}
} // namespace
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace clp_ffi_js::ir {
* Class to deserialize and decode Zstandard-compressed CLP IR streams as well as format decoded
* log events.
*/
class IRStreamReader : public StreamReader {
class IrStreamReader : public StreamReader {
friend StreamReader;

public:
Expand All @@ -34,25 +34,25 @@ class IRStreamReader : public StreamReader {
using FilteredLogEventsMap = std::optional<std::vector<size_t>>;

/**
* Creates a IRStreamReader to read from the given array.
* Creates a IrStreamReader to read from the given array.
*
* @param data_array An array containing a Zstandard-compressed IR stream.
* @return The created instance.
* @throw ClpFfiJsException if any error occurs.
*/
[[nodiscard]] static auto create(DataArrayTsType const& data_array) -> IRStreamReader;
[[nodiscard]] static auto create(DataArrayTsType const& data_array) -> IrStreamReader;

// Destructor
~IRStreamReader() override = default;
~IrStreamReader() override = default;

// Disable copy constructor and assignment operator
IRStreamReader(IRStreamReader const&) = delete;
auto operator=(IRStreamReader const&) -> IRStreamReader& = delete;
IrStreamReader(IrStreamReader const&) = delete;
auto operator=(IrStreamReader const&) -> IrStreamReader& = delete;

// Define default move constructor
IRStreamReader(IRStreamReader&&) = default;
IrStreamReader(IrStreamReader&&) = default;
// Delete move assignment operator since it's also disabled in `clp::ir::LogEventDeserializer`.
auto operator=(IRStreamReader&&) -> IRStreamReader& = delete;
auto operator=(IrStreamReader&&) -> IrStreamReader& = delete;

// Methods
/**
Expand Down Expand Up @@ -100,7 +100,7 @@ class IRStreamReader : public StreamReader {

private:
// Constructor
explicit IRStreamReader(
explicit IrStreamReader(
StreamReaderDataContext<four_byte_encoded_variable_t>&& stream_reader_data_context
);

Expand Down
8 changes: 4 additions & 4 deletions src/clp_ffi_js/ir/StreamReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include <clp_ffi_js/ClpFfiJsException.hpp>
#include <clp_ffi_js/ir/decoding_methods.hpp>
#include <clp_ffi_js/ir/IRStreamReader.hpp>
#include <clp_ffi_js/ir/IrStreamReader.hpp>

namespace clp_ffi_js::ir {
auto StreamReader::create(DataArrayTsType const& data_array) -> std::unique_ptr<StreamReader> {
Expand All @@ -34,13 +34,13 @@ 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_deserializer_and_data_context(
std::move(zstd_decompressor),
std::move(data_buffer)
)};

return std::unique_ptr<IRStreamReader>(
new IRStreamReader(std::move(stream_reader_data_context))
return std::unique_ptr<IrStreamReader>(
new IrStreamReader(std::move(stream_reader_data_context))
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/clp_ffi_js/ir/StreamReaderDataContext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace clp_ffi_js::ir {
/**
* The data context for a `IRStreamReader`. It encapsulates a chain of the following resources:
* The data context for a `IrStreamReader`. 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.
Expand Down

0 comments on commit bf5e4c9

Please sign in to comment.