-
-
Notifications
You must be signed in to change notification settings - Fork 153
fix: fetch first-event-at from storage #1130
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
Merged
nitisht
merged 4 commits into
parseablehq:main
from
nikhilsinhaparseable:first-event-at-fix
Jan 27, 2025
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c26b6b1
fix: fetch first-event-at from storage
nikhilsinhaparseable b618c47
updated comments and styling changes
nikhilsinhaparseable 3700cb2
moved to ObjectStorage trait
nikhilsinhaparseable 91c5d5d
Merge branch 'main' into first-event-at-fix
nikhilsinhaparseable File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -212,13 +212,46 @@ impl StreamInfo { | |
pub fn set_first_event_at( | ||
&self, | ||
stream_name: &str, | ||
first_event_at: Option<String>, | ||
first_event_at: &str, | ||
) -> Result<(), MetadataError> { | ||
let mut map = self.write().expect(LOCK_EXPECT); | ||
map.get_mut(stream_name) | ||
.ok_or(MetadataError::StreamMetaNotFound(stream_name.to_string())) | ||
.map(|metadata| { | ||
metadata.first_event_at = first_event_at; | ||
metadata.first_event_at = Some(first_event_at.to_owned()); | ||
}) | ||
} | ||
|
||
/// Removes the `first_event_at` timestamp for the specified stream from the LogStreamMetadata. | ||
/// | ||
/// This function is called during the retention task, when the parquet files along with the manifest files are deleted from the storage. | ||
/// The manifest path is removed from the snapshot in the stream.json | ||
/// and the first_event_at value in the stream.json is removed. | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `stream_name` - The name of the stream for which the `first_event_at` timestamp is to be removed. | ||
/// | ||
/// # Returns | ||
/// | ||
/// * `Result<(), MetadataError>` - Returns `Ok(())` if the `first_event_at` timestamp is successfully removed, | ||
/// or a `MetadataError` if the stream metadata is not found. | ||
/// | ||
/// # Examples | ||
/// ```ignore | ||
/// ```rust | ||
/// let result = metadata.remove_first_event_at("my_stream"); | ||
/// match result { | ||
/// Ok(()) => println!("first-event-at removed successfully"), | ||
/// Err(e) => eprintln!("Error removing first-event-at from STREAM_INFO: {}", e), | ||
/// } | ||
/// ``` | ||
pub fn reset_first_event_at(&self, stream_name: &str) -> Result<(), MetadataError> { | ||
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 feel a good comment would explain where we are using this function, e.g. when retention threshold is met and we are removing first event time since that information is outdated. |
||
let mut map = self.write().expect(LOCK_EXPECT); | ||
map.get_mut(stream_name) | ||
.ok_or(MetadataError::StreamMetaNotFound(stream_name.to_string())) | ||
.map(|metadata| { | ||
metadata.first_event_at.take(); | ||
}) | ||
} | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Maybe we should pass
DateTime
/NaiveDateTime
instead of using&str
to represent this information?