@@ -23,6 +23,7 @@ use itertools::Itertools;
2323use once_cell:: sync:: Lazy ;
2424use serde_json:: Value ;
2525use std:: collections:: HashMap ;
26+ use std:: num:: NonZeroU32 ;
2627use std:: sync:: { Arc , RwLock } ;
2728
2829use self :: error:: stream_info:: { CheckAlertError , LoadError , MetadataError } ;
@@ -53,7 +54,7 @@ pub struct LogStreamMetadata {
5354 pub created_at : String ,
5455 pub first_event_at : Option < String > ,
5556 pub time_partition : Option < String > ,
56- pub time_partition_limit : Option < String > ,
57+ pub time_partition_limit : Option < NonZeroU32 > ,
5758 pub custom_partition : Option < String > ,
5859 pub static_schema_flag : Option < String > ,
5960 pub hot_tier_enabled : Option < bool > ,
@@ -113,11 +114,11 @@ impl StreamInfo {
113114 pub fn get_time_partition_limit (
114115 & self ,
115116 stream_name : & str ,
116- ) -> Result < Option < String > , MetadataError > {
117+ ) -> Result < Option < NonZeroU32 > , MetadataError > {
117118 let map = self . read ( ) . expect ( LOCK_EXPECT ) ;
118119 map. get ( stream_name)
119120 . ok_or ( MetadataError :: StreamMetaNotFound ( stream_name. to_string ( ) ) )
120- . map ( |metadata| metadata. time_partition_limit . clone ( ) )
121+ . map ( |metadata| metadata. time_partition_limit )
121122 }
122123
123124 pub fn get_custom_partition ( & self , stream_name : & str ) -> Result < Option < String > , MetadataError > {
@@ -202,7 +203,7 @@ impl StreamInfo {
202203 pub fn update_time_partition_limit (
203204 & self ,
204205 stream_name : & str ,
205- time_partition_limit : String ,
206+ time_partition_limit : NonZeroU32 ,
206207 ) -> Result < ( ) , MetadataError > {
207208 let mut map = self . write ( ) . expect ( LOCK_EXPECT ) ;
208209 map. get_mut ( stream_name)
@@ -244,7 +245,7 @@ impl StreamInfo {
244245 stream_name : String ,
245246 created_at : String ,
246247 time_partition : String ,
247- time_partition_limit : String ,
248+ time_partition_limit : Option < NonZeroU32 > ,
248249 custom_partition : String ,
249250 static_schema_flag : String ,
250251 static_schema : HashMap < String , Arc < Field > > ,
@@ -262,11 +263,7 @@ impl StreamInfo {
262263 } else {
263264 Some ( time_partition)
264265 } ,
265- time_partition_limit : if time_partition_limit. is_empty ( ) {
266- None
267- } else {
268- Some ( time_partition_limit)
269- } ,
266+ time_partition_limit,
270267 custom_partition : if custom_partition. is_empty ( ) {
271268 None
272269 } else {
@@ -320,7 +317,9 @@ impl StreamInfo {
320317 created_at : meta. created_at ,
321318 first_event_at : meta. first_event_at ,
322319 time_partition : meta. time_partition ,
323- time_partition_limit : meta. time_partition_limit ,
320+ time_partition_limit : meta
321+ . time_partition_limit
322+ . and_then ( |limit| limit. parse ( ) . ok ( ) ) ,
324323 custom_partition : meta. custom_partition ,
325324 static_schema_flag : meta. static_schema_flag ,
326325 hot_tier_enabled : meta. hot_tier_enabled ,
@@ -473,7 +472,9 @@ pub async fn load_stream_metadata_on_server_start(
473472 created_at : meta. created_at ,
474473 first_event_at : meta. first_event_at ,
475474 time_partition : meta. time_partition ,
476- time_partition_limit : meta. time_partition_limit ,
475+ time_partition_limit : meta
476+ . time_partition_limit
477+ . and_then ( |limit| limit. parse ( ) . ok ( ) ) ,
477478 custom_partition : meta. custom_partition ,
478479 static_schema_flag : meta. static_schema_flag ,
479480 hot_tier_enabled : meta. hot_tier_enabled ,
0 commit comments