-
Notifications
You must be signed in to change notification settings - Fork 9
feat: Add KQL query support for filtering structured IR log events. #104
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
Changes from all commits
dedb758
002e055
927dabd
56903d6
d2eef8d
587c25f
994a77e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -96,15 +96,31 @@ class StreamReader { | |||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||
* @return The filtered log events map. | ||||||||||||||||||||||||||||||||||
* This is a sorted list of log event indices that match the filter. | ||||||||||||||||||||||||||||||||||
* If all log events match the filter, it returns `null` or a vector of all log events. | ||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||
Comment on lines
+99
to
101
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Clarify “null vs full-vector” invariant for callers The API can return either null or a full vector when everything matches. Make the contract explicit so consumers don’t branch on both if unnecessary. /**
* @return The filtered log events map.
- * This is a sorted list of log event indices that match the filter.
- * If all log events match the filter, it returns `null` or a vector of all log events.
+ * This is a sorted list of log event indices that match the filter.
+ * If all log events match the filter, this returns `null` (preferred) to signal
+ * “no-op filtering”. Some internal paths may return a full vector; callers should
+ * treat `null` and “full coverage” equivalently.
*/ 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||
[[nodiscard]] virtual auto get_filtered_log_event_map() const -> FilteredLogEventMapTsType = 0; | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||
* Generates a filtered collection from all log events. | ||||||||||||||||||||||||||||||||||
* | ||||||||||||||||||||||||||||||||||
* @param log_level_filter Array of selected log levels | ||||||||||||||||||||||||||||||||||
* @param log_level_filter Array of selected log levels. | ||||||||||||||||||||||||||||||||||
* @param kql_filter: A KQL expression used to filter kv-pairs. | ||||||||||||||||||||||||||||||||||
* - For structured IR: the filter is applied when non-empty. | ||||||||||||||||||||||||||||||||||
* - For unstructured IR: the filter is always ignored, and a warning is logged when non-empty. | ||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||
virtual void filter_log_events(LogLevelFilterTsType const& log_level_filter) = 0; | ||||||||||||||||||||||||||||||||||
virtual void | ||||||||||||||||||||||||||||||||||
filter_log_events(LogLevelFilterTsType const& log_level_filter, std::string const& kql_filter) | ||||||||||||||||||||||||||||||||||
= 0; | ||||||||||||||||||||||||||||||||||
hoophalab marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||
* Generates a filtered collection from all log events. | ||||||||||||||||||||||||||||||||||
* | ||||||||||||||||||||||||||||||||||
* @param log_level_filter Array of selected log levels. | ||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||
void filter_log_events(LogLevelFilterTsType const& log_level_filter) { | ||||||||||||||||||||||||||||||||||
filter_log_events(log_level_filter, ""); | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
Comment on lines
+116
to
+123
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Minor: document the single-arg wrapper’s behaviour Clarify that this overload disables KQL by design. -/**
- * Generates a filtered collection from all log events.
- *
- * @param log_level_filter Array of selected log levels.
- */
+/**
+ * Convenience wrapper: filters only by `log_level_filter` (KQL disabled).
+ *
+ * @param log_level_filter Array of selected log levels.
+ */ 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||
* Deserializes all log events in the stream. | ||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,28 +1,33 @@ | ||||||||||||||||||||||||||||||||
#include "StructuredIrStreamReader.hpp" | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
#include <algorithm> | ||||||||||||||||||||||||||||||||
#include <cstddef> | ||||||||||||||||||||||||||||||||
#include <format> | ||||||||||||||||||||||||||||||||
#include <memory> | ||||||||||||||||||||||||||||||||
#include <optional> | ||||||||||||||||||||||||||||||||
#include <string> | ||||||||||||||||||||||||||||||||
#include <string_view> | ||||||||||||||||||||||||||||||||
#include <system_error> | ||||||||||||||||||||||||||||||||
#include <type_traits> | ||||||||||||||||||||||||||||||||
#include <utility> | ||||||||||||||||||||||||||||||||
#include <vector> | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
#include <clp/ErrorCode.hpp> | ||||||||||||||||||||||||||||||||
#include <clp/ffi/ir_stream/Deserializer.hpp> | ||||||||||||||||||||||||||||||||
#include <clp/ffi/SchemaTree.hpp> | ||||||||||||||||||||||||||||||||
#include <clp/ir/types.hpp> | ||||||||||||||||||||||||||||||||
#include <clp/TraceableException.hpp> | ||||||||||||||||||||||||||||||||
#include <clp/type_utils.hpp> | ||||||||||||||||||||||||||||||||
#include <emscripten/bind.h> | ||||||||||||||||||||||||||||||||
#include <emscripten/val.h> | ||||||||||||||||||||||||||||||||
#include <nlohmann/json.hpp> | ||||||||||||||||||||||||||||||||
#include <spdlog/spdlog.h> | ||||||||||||||||||||||||||||||||
#include <ystdlib/containers/Array.hpp> | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
#include <clp_ffi_js/ClpFfiJsException.hpp> | ||||||||||||||||||||||||||||||||
#include <clp_ffi_js/constants.hpp> | ||||||||||||||||||||||||||||||||
#include <clp_ffi_js/ir/decoding_methods.hpp> | ||||||||||||||||||||||||||||||||
#include <clp_ffi_js/ir/LogEventWithFilterData.hpp> | ||||||||||||||||||||||||||||||||
#include <clp_ffi_js/ir/query_methods.hpp> | ||||||||||||||||||||||||||||||||
#include <clp_ffi_js/ir/StreamReader.hpp> | ||||||||||||||||||||||||||||||||
#include <clp_ffi_js/ir/StreamReaderDataContext.hpp> | ||||||||||||||||||||||||||||||||
#include <clp_ffi_js/ir/StructuredIrUnitHandler.hpp> | ||||||||||||||||||||||||||||||||
|
@@ -139,12 +144,57 @@ auto StructuredIrStreamReader::get_filtered_log_event_map() const -> FilteredLog | |||||||||||||||||||||||||||||||
return FilteredLogEventMapTsType{emscripten::val::array(m_filtered_log_event_map.value())}; | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
void StructuredIrStreamReader::filter_log_events(LogLevelFilterTsType const& log_level_filter) { | ||||||||||||||||||||||||||||||||
generic_filter_log_events( | ||||||||||||||||||||||||||||||||
m_filtered_log_event_map, | ||||||||||||||||||||||||||||||||
log_level_filter, | ||||||||||||||||||||||||||||||||
*m_deserialized_log_events | ||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||
void StructuredIrStreamReader::filter_log_events( | ||||||||||||||||||||||||||||||||
LogLevelFilterTsType const& log_level_filter, | ||||||||||||||||||||||||||||||||
std::string const& kql_filter | ||||||||||||||||||||||||||||||||
) { | ||||||||||||||||||||||||||||||||
Comment on lines
+147
to
+150
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm ok with the current implementation. There can be a more efficient way: we can embed this log-level filtering using a lambda into the query method. But that might be over-engineering at this point. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||||||||||||||
m_filtered_log_event_map.reset(); | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
if (false == kql_filter.empty()) { | ||||||||||||||||||||||||||||||||
auto& reader{m_stream_reader_data_context->get_reader()}; | ||||||||||||||||||||||||||||||||
reader.seek_from_begin(0); | ||||||||||||||||||||||||||||||||
m_filtered_log_event_map.emplace(collect_matched_log_event_indices(reader, kql_filter)); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
if (false == log_level_filter.isNull()) { | ||||||||||||||||||||||||||||||||
std::vector<size_t> filtered_log_event_map; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
auto const filter_levels{ | ||||||||||||||||||||||||||||||||
emscripten::vecFromJSArray<std::underlying_type_t<LogLevel>>(log_level_filter) | ||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
auto filter_and_collect_idx = [&](size_t const log_event_idx) { | ||||||||||||||||||||||||||||||||
auto const& log_event{m_deserialized_log_events->at(log_event_idx)}; | ||||||||||||||||||||||||||||||||
if (std::ranges::find( | ||||||||||||||||||||||||||||||||
filter_levels, | ||||||||||||||||||||||||||||||||
clp::enum_to_underlying_type(log_event.get_log_level()) | ||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||
!= filter_levels.end()) | ||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||
filtered_log_event_map.emplace_back(log_event_idx); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
if (m_filtered_log_event_map.has_value()) { | ||||||||||||||||||||||||||||||||
for (auto const log_event_idx : m_filtered_log_event_map.value()) { | ||||||||||||||||||||||||||||||||
hoophalab marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||
filter_and_collect_idx(log_event_idx); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||||||||
for (size_t log_event_idx{0}; log_event_idx < m_deserialized_log_events->size(); | ||||||||||||||||||||||||||||||||
++log_event_idx) | ||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||
filter_and_collect_idx(log_event_idx); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
m_filtered_log_event_map = std::move(filtered_log_event_map); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
if (m_filtered_log_event_map.has_value() | ||||||||||||||||||||||||||||||||
&& m_filtered_log_event_map->size() == m_deserialized_log_events->size()) | ||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||
m_filtered_log_event_map = std::nullopt; | ||||||||||||||||||||||||||||||||
hoophalab marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
Comment on lines
+193
to
+197
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Document “null = all events match” behaviour in the public API This normalisation is fine; ensure the header/TS typings and README explicitly state that get_filtered_log_event_map returns null when the filtered set equals the full set. I can update the doxygen in StructuredIrStreamReader.hpp and the TS wrapper comments to make this explicit; let me know if you want a follow-up PR. 🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
auto StructuredIrStreamReader::deserialize_stream() -> size_t { | ||||||||||||||||||||||||||||||||
|
@@ -157,28 +207,7 @@ auto StructuredIrStreamReader::deserialize_stream() -> size_t { | |||||||||||||||||||||||||||||||
auto& reader{m_stream_reader_data_context->get_reader()}; | ||||||||||||||||||||||||||||||||
auto& deserializer = m_stream_reader_data_context->get_deserializer(); | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
while (false == deserializer.is_stream_completed()) { | ||||||||||||||||||||||||||||||||
auto result{deserializer.deserialize_next_ir_unit(reader)}; | ||||||||||||||||||||||||||||||||
if (false == result.has_error()) { | ||||||||||||||||||||||||||||||||
continue; | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
auto const error{result.error()}; | ||||||||||||||||||||||||||||||||
if (std::errc::result_out_of_range == error) { | ||||||||||||||||||||||||||||||||
SPDLOG_ERROR("File contains an incomplete IR stream"); | ||||||||||||||||||||||||||||||||
break; | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
throw ClpFfiJsException{ | ||||||||||||||||||||||||||||||||
clp::ErrorCode::ErrorCode_Corrupt, | ||||||||||||||||||||||||||||||||
__FILENAME__, | ||||||||||||||||||||||||||||||||
__LINE__, | ||||||||||||||||||||||||||||||||
std::format( | ||||||||||||||||||||||||||||||||
"Failed to deserialize IR unit: {}:{}", | ||||||||||||||||||||||||||||||||
error.category().name(), | ||||||||||||||||||||||||||||||||
error.message() | ||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
m_stream_reader_data_context.reset(nullptr); | ||||||||||||||||||||||||||||||||
deserialize_log_events(deserializer, reader); | ||||||||||||||||||||||||||||||||
return m_deserialized_log_events->size(); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
|
@@ -188,11 +217,13 @@ auto StructuredIrStreamReader::decode_range(size_t begin_idx, size_t end_idx, bo | |||||||||||||||||||||||||||||||
auto json_pair_result{log_event.serialize_to_json()}; | ||||||||||||||||||||||||||||||||
if (json_pair_result.has_error()) { | ||||||||||||||||||||||||||||||||
auto const error_code{json_pair_result.error()}; | ||||||||||||||||||||||||||||||||
// NOLINTBEGIN(bugprone-lambda-function-name) | ||||||||||||||||||||||||||||||||
SPDLOG_ERROR( | ||||||||||||||||||||||||||||||||
"Failed to deserialize log event to JSON: {}:{}", | ||||||||||||||||||||||||||||||||
error_code.category().name(), | ||||||||||||||||||||||||||||||||
error_code.message() | ||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||
// NOLINTEND(bugprone-lambda-function-name) | ||||||||||||||||||||||||||||||||
return std::string{cEmptyJsonStr}; | ||||||||||||||||||||||||||||||||
Comment on lines
+220
to
227
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Localise the lint suppression Use NOLINTNEXTLINE to target the SPDLOG call, keeping the suppression as narrow as possible. - // NOLINTBEGIN(bugprone-lambda-function-name)
- SPDLOG_ERROR(
+ // NOLINTNEXTLINE(bugprone-lambda-function-name)
+ SPDLOG_ERROR(
"Failed to deserialize log event to JSON: {}:{}",
error_code.category().name(),
error_code.message()
);
- // NOLINTEND(bugprone-lambda-function-name) 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -80,7 +80,16 @@ auto UnstructuredIrStreamReader::get_filtered_log_event_map() const -> FilteredL | |||||||||||||||||||||||||||||||||||||||||||
return FilteredLogEventMapTsType{emscripten::val::array(m_filtered_log_event_map.value())}; | ||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
void UnstructuredIrStreamReader::filter_log_events(LogLevelFilterTsType const& log_level_filter) { | ||||||||||||||||||||||||||||||||||||||||||||
void UnstructuredIrStreamReader::filter_log_events( | ||||||||||||||||||||||||||||||||||||||||||||
LogLevelFilterTsType const& log_level_filter, | ||||||||||||||||||||||||||||||||||||||||||||
[[maybe_unused]] std::string const& kql_filter | ||||||||||||||||||||||||||||||||||||||||||||
) { | ||||||||||||||||||||||||||||||||||||||||||||
if (false == kql_filter.empty()) { | ||||||||||||||||||||||||||||||||||||||||||||
SPDLOG_WARN( | ||||||||||||||||||||||||||||||||||||||||||||
"KQL filters aren't supported for unstructured IR streams, so they're being " | ||||||||||||||||||||||||||||||||||||||||||||
"ignored." | ||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+83
to
+91
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Remove [[maybe_unused]] and keep warning conditional You’re using kql_filter in the condition; the [[maybe_unused]] attribute is now incorrect. The conditional warning is good and matches team guidance. void UnstructuredIrStreamReader::filter_log_events(
LogLevelFilterTsType const& log_level_filter,
- [[maybe_unused]] std::string const& kql_filter
+ std::string const& kql_filter
) {
if (false == kql_filter.empty()) {
SPDLOG_WARN(
"KQL filters aren't supported for unstructured IR streams, so they're being "
"ignored."
);
} 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||
generic_filter_log_events(m_filtered_log_event_map, log_level_filter, m_encoded_log_events); | ||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,10 +1,15 @@ | ||||||||||||||||||||||||||||||||||||||||||||||
#ifndef CLP_FFI_JS_IR_DECODING_METHODS_HPP | ||||||||||||||||||||||||||||||||||||||||||||||
#define CLP_FFI_JS_IR_DECODING_METHODS_HPP | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
#include <clp/ffi/ir_stream/Deserializer.hpp> | ||||||||||||||||||||||||||||||||||||||||||||||
#include <clp/ffi/ir_stream/IrUnitHandlerReq.hpp> | ||||||||||||||||||||||||||||||||||||||||||||||
#include <clp/ffi/ir_stream/search/QueryHandlerReq.hpp> | ||||||||||||||||||||||||||||||||||||||||||||||
#include <clp/ReaderInterface.hpp> | ||||||||||||||||||||||||||||||||||||||||||||||
#include <nlohmann/json.hpp> | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
#include <clp_ffi_js/ClpFfiJsException.hpp> | ||||||||||||||||||||||||||||||||||||||||||||||
#include <clp_ffi_js/ir/StreamReader.hpp> | ||||||||||||||||||||||||||||||||||||||||||||||
#include <clp_ffi_js/ir/StructuredIrStreamReader.hpp> | ||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
11
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Decouple: remove unnecessary include of StructuredIrStreamReader.hpp This header doesn’t reference StructuredIrStreamReader; drop the include to reduce compile-time and coupling. -#include <clp_ffi_js/ir/StreamReader.hpp>
-#include <clp_ffi_js/ir/StructuredIrStreamReader.hpp>
+#include <clp_ffi_js/ir/StreamReader.hpp> 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+4
to
13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add required headers for std::format and logging; avoid relying on transitive includes This TU uses std::format and SPDLOG_WARN; include their headers explicitly. Also include <system_error> for std::errc. #include <clp/ffi/ir_stream/Deserializer.hpp>
#include <clp/ffi/ir_stream/IrUnitHandlerReq.hpp>
#include <clp/ffi/ir_stream/search/QueryHandlerReq.hpp>
#include <clp/ReaderInterface.hpp>
#include <nlohmann/json.hpp>
#include <clp_ffi_js/ClpFfiJsException.hpp>
#include <clp_ffi_js/ir/StreamReader.hpp>
#include <clp_ffi_js/ir/StructuredIrStreamReader.hpp>
+#include <format>
+#include <spdlog/spdlog.h>
+#include <system_error> 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||
namespace clp_ffi_js::ir { | ||||||||||||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -32,6 +37,36 @@ auto rewind_reader_and_validate_encoding_type(clp::ReaderInterface& reader) -> v | |||||||||||||||||||||||||||||||||||||||||||||
* @return The converted JavaScript object. | ||||||||||||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||||||||||||
[[nodiscard]] auto convert_metadata_to_js_object(nlohmann::json const& metadata) -> MetadataTsType; | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
template < | ||||||||||||||||||||||||||||||||||||||||||||||
clp::ffi::ir_stream::IrUnitHandlerReq IrUnitHandlerType, | ||||||||||||||||||||||||||||||||||||||||||||||
clp::ffi::ir_stream::search::QueryHandlerReq QueryHandlerType> | ||||||||||||||||||||||||||||||||||||||||||||||
auto deserialize_log_events( | ||||||||||||||||||||||||||||||||||||||||||||||
clp::ffi::ir_stream::Deserializer<IrUnitHandlerType, QueryHandlerType>& deserializer, | ||||||||||||||||||||||||||||||||||||||||||||||
clp::ReaderInterface& reader | ||||||||||||||||||||||||||||||||||||||||||||||
) -> void { | ||||||||||||||||||||||||||||||||||||||||||||||
while (false == deserializer.is_stream_completed()) { | ||||||||||||||||||||||||||||||||||||||||||||||
auto const result{deserializer.deserialize_next_ir_unit(reader)}; | ||||||||||||||||||||||||||||||||||||||||||||||
if (false == result.has_error()) { | ||||||||||||||||||||||||||||||||||||||||||||||
continue; | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
auto const error{result.error()}; | ||||||||||||||||||||||||||||||||||||||||||||||
if (std::errc::result_out_of_range == error) { | ||||||||||||||||||||||||||||||||||||||||||||||
SPDLOG_WARN("File contains an incomplete IR stream"); | ||||||||||||||||||||||||||||||||||||||||||||||
break; | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
throw ClpFfiJsException{ | ||||||||||||||||||||||||||||||||||||||||||||||
clp::ErrorCode::ErrorCode_Corrupt, | ||||||||||||||||||||||||||||||||||||||||||||||
__FILENAME__, | ||||||||||||||||||||||||||||||||||||||||||||||
__LINE__, | ||||||||||||||||||||||||||||||||||||||||||||||
std::format( | ||||||||||||||||||||||||||||||||||||||||||||||
"Failed to deserialize IR unit: {}:{}", | ||||||||||||||||||||||||||||||||||||||||||||||
error.category().name(), | ||||||||||||||||||||||||||||||||||||||||||||||
error.message() | ||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
} // namespace clp_ffi_js::ir | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
#endif // CLP_FFI_JS_IR_DECODING_METHODS_HPP |
Uh oh!
There was an error while loading. Please reload this page.