1818
1919use std:: { io:: ErrorKind , sync:: Arc } ;
2020
21- use self :: { column:: Column , snapshot:: ManifestItem } ;
22- use crate :: handlers;
23- use crate :: handlers:: http:: base_path_without_preceding_slash;
24- use crate :: metadata:: STREAM_INFO ;
25- use crate :: metrics:: { EVENTS_INGESTED_DATE , EVENTS_INGESTED_SIZE_DATE , EVENTS_STORAGE_SIZE_DATE } ;
26- use crate :: option:: { Mode , CONFIG } ;
27- use crate :: stats:: {
28- event_labels_date, get_current_stats, storage_size_labels_date, update_deleted_stats,
29- } ;
30- use crate :: {
31- catalog:: manifest:: Manifest ,
32- event:: DEFAULT_TIMESTAMP_KEY ,
33- query:: PartialTimeFilter ,
34- storage:: { object_storage:: manifest_path, ObjectStorage , ObjectStorageError } ,
35- } ;
3621use chrono:: { DateTime , Local , NaiveTime , Utc } ;
22+ use column:: Column ;
23+ use manifest:: Manifest ;
3724use relative_path:: RelativePathBuf ;
25+ use snapshot:: ManifestItem ;
3826use std:: io:: Error as IOError ;
3927use tracing:: { error, info} ;
28+
29+ use crate :: {
30+ event:: DEFAULT_TIMESTAMP_KEY ,
31+ handlers:: { self , http:: base_path_without_preceding_slash} ,
32+ metrics:: { EVENTS_INGESTED_DATE , EVENTS_INGESTED_SIZE_DATE , EVENTS_STORAGE_SIZE_DATE } ,
33+ option:: Mode ,
34+ parseable:: PARSEABLE ,
35+ query:: PartialTimeFilter ,
36+ stats:: { event_labels_date, get_current_stats, storage_size_labels_date, update_deleted_stats} ,
37+ storage:: {
38+ object_storage:: manifest_path, ObjectStorage , ObjectStorageError , ObjectStoreFormat ,
39+ } ,
40+ } ;
41+ pub use manifest:: create_from_parquet_file;
42+
4043pub mod column;
4144pub mod manifest;
4245pub mod snapshot;
43- use crate :: storage:: ObjectStoreFormat ;
44- pub use manifest:: create_from_parquet_file;
4546pub trait Snapshot {
4647 fn manifests ( & self , time_predicates : & [ PartialTimeFilter ] ) -> Vec < ManifestItem > ;
4748}
@@ -263,7 +264,7 @@ async fn create_manifest(
263264 files : vec ! [ change] ,
264265 ..Manifest :: default ( )
265266 } ;
266- let mut first_event_at = STREAM_INFO . get_first_event ( stream_name) ?;
267+ let mut first_event_at = PARSEABLE . get_stream ( stream_name) ?. get_first_event ( ) ;
267268 if first_event_at. is_none ( ) {
268269 if let Some ( first_event) = manifest. files . first ( ) {
269270 let time_partition = & meta. time_partition ;
@@ -279,13 +280,11 @@ async fn create_manifest(
279280 }
280281 } ;
281282 first_event_at = Some ( lower_bound. with_timezone ( & Local ) . to_rfc3339 ( ) ) ;
282- if let Err ( err) =
283- STREAM_INFO . set_first_event_at ( stream_name, first_event_at. as_ref ( ) . unwrap ( ) )
284- {
285- error ! (
286- "Failed to update first_event_at in streaminfo for stream {:?} {err:?}" ,
287- stream_name
288- ) ;
283+ match PARSEABLE . get_stream ( stream_name) {
284+ Ok ( stream) => stream. set_first_event_at ( first_event_at. as_ref ( ) . unwrap ( ) ) ,
285+ Err ( err) => error ! (
286+ "Failed to update first_event_at in streaminfo for stream {stream_name:?}, error = {err:?}"
287+ ) ,
289288 }
290289 }
291290 }
@@ -332,11 +331,11 @@ pub async fn remove_manifest_from_snapshot(
332331 let manifests = & mut meta. snapshot . manifest_list ;
333332 // Filter out items whose manifest_path contains any of the dates_to_delete
334333 manifests. retain ( |item| !dates. iter ( ) . any ( |date| item. manifest_path . contains ( date) ) ) ;
335- STREAM_INFO . reset_first_event_at ( stream_name) ?;
334+ PARSEABLE . get_stream ( stream_name) ?. reset_first_event_at ( ) ;
336335 meta. first_event_at = None ;
337336 storage. put_snapshot ( stream_name, meta. snapshot ) . await ?;
338337 }
339- match CONFIG . options . mode {
338+ match PARSEABLE . options . mode {
340339 Mode :: All | Mode :: Ingest => {
341340 Ok ( get_first_event ( storage. clone ( ) , stream_name, Vec :: new ( ) ) . await ?)
342341 }
@@ -350,10 +349,10 @@ pub async fn get_first_event(
350349 dates : Vec < String > ,
351350) -> Result < Option < String > , ObjectStorageError > {
352351 let mut first_event_at: String = String :: default ( ) ;
353- match CONFIG . options . mode {
352+ match PARSEABLE . options . mode {
354353 Mode :: All | Mode :: Ingest => {
355354 // get current snapshot
356- let stream_first_event = STREAM_INFO . get_first_event ( stream_name) ?;
355+ let stream_first_event = PARSEABLE . get_stream ( stream_name) ?. get_first_event ( ) ;
357356 if stream_first_event. is_some ( ) {
358357 first_event_at = stream_first_event. unwrap ( ) ;
359358 } else {
@@ -393,7 +392,9 @@ pub async fn get_first_event(
393392 first_event_at = lower_bound. with_timezone ( & Local ) . to_rfc3339 ( ) ;
394393 meta. first_event_at = Some ( first_event_at. clone ( ) ) ;
395394 storage. put_stream_manifest ( stream_name, & meta) . await ?;
396- STREAM_INFO . set_first_event_at ( stream_name, & first_event_at) ?;
395+ PARSEABLE
396+ . get_stream ( stream_name) ?
397+ . set_first_event_at ( & first_event_at) ;
397398 }
398399 }
399400 }
0 commit comments