-
Notifications
You must be signed in to change notification settings - Fork 6
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
feat: Support search logs by timestamp for structured and unstructured logs. #42
base: main
Are you sure you want to change the base?
Conversation
# Conflicts: # src/clp_ffi_js/ir/StreamReader.cpp # src/clp_ffi_js/ir/StreamReader.hpp
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For future commits, you may follow https://github.com/y-scope/clp-ffi-js?tab=readme-ov-file#linting to run the linter
@@ -124,6 +125,10 @@ class StreamReader { | |||
[[nodiscard]] virtual auto decode_range(size_t begin_idx, size_t end_idx, bool use_filter) const | |||
-> DecodedResultsTsType = 0; | |||
|
|||
[[nodiscard]] virtual auto find_timestamp_last_occurrence( | |||
clp::ir::epoch_time_ms_t input_timestamp | |||
) -> std::ptrdiff_t = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we discussed offline that there would be some changes in both clp-ffi-js and ylv to return a nullable-integer instead, we ended up with a temporary conclusion that using a const value -1
was sufficient to indicate that no matching log event can be found.
However, returning null
may only seem necessary now I realize that we have been (implicitly) using size_t
as the type of LogEventIdx
and such values are always non-negative. Can we declare a TS type and change the return type to it? You may refer to to FilteredLogEventMapTsType
for such type declarations and usages; let me know if you need more help.
|
||
// Adjust the iterator to find the last valid index | ||
if (it == m_deserialized_log_events->end() || it->get_timestamp() > input_timestamp) { | ||
if (it == m_deserialized_log_events->begin()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to check against m_deserialized_log_events->empty()
at the beginning of the method and early return, so that we can avoid checking it == m_deserialized_log_events->end() && it == m_deserialized_log_events->begin()
?
if (it == m_deserialized_log_events->begin()) { | ||
return -1; // No element satisfies the condition | ||
} | ||
--it; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use std::range::upper_bound
instead and always it--
after, so that we can avoid checking (it == m_deserialized_log_events->end() || it->get_timestamp() > input_timestamp)
?
@@ -158,6 +158,29 @@ auto UnstructuredIrStreamReader::decode_range(size_t begin_idx, size_t end_idx, | |||
); | |||
} | |||
|
|||
auto UnstructuredIrStreamReader::find_timestamp_last_occurrence( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's deduplicate this with StructuredIrStreamReader::find_timestamp_last_occurrence
.
You may refer to generic_decode_range
.
Description
Validation performed