@@ -61,7 +61,7 @@ use crate::{
6161 metadata:: { LogStreamMetadata , SchemaVersion } ,
6262 metrics,
6363 option:: Mode ,
64- parseable:: { DEFAULT_TENANT , PARSEABLE , staging :: writer :: ENABLE_MEMORY_STAGING } ,
64+ parseable:: { DEFAULT_TENANT , PARSEABLE } ,
6565 storage:: { StreamType , object_storage:: to_bytes, retention:: Retention } ,
6666 sync:: FLUSH_AND_CONVERT_RUNTIME ,
6767 utils:: time:: { Minute , TimeRange } ,
@@ -202,8 +202,8 @@ impl Stream {
202202 guard. push_disk ( filename, record, file_path, range, * DISK_WRITE_BATCH_ROWS ) ?;
203203 }
204204
205- if * ENABLE_MEMORY_STAGING {
206- guard . mem . push ( schema_key, record) ?;
205+ if let Some ( mem ) = guard . mem . as_mut ( ) {
206+ mem. push ( schema_key, record) ?;
207207 }
208208
209209 Ok ( ( ) )
@@ -560,22 +560,23 @@ impl Stream {
560560 & self ,
561561 schema : & Arc < Schema > ,
562562 ) -> Result < Vec < RecordBatch > , StagingError > {
563- let writer = self . writer . lock ( ) . map_err ( |poisoned| {
563+ let mut writer = self . writer . lock ( ) . map_err ( |poisoned| {
564564 StagingError :: PoisonError ( PoisonError :: new ( format ! (
565565 "Writer lock poisoned while cloning record batches for stream {} - {}" ,
566566 self . stream_name, poisoned
567567 ) ) )
568568 } ) ?;
569569
570- if * ENABLE_MEMORY_STAGING {
571- writer . mem . recordbatch_cloned ( schema)
570+ if let Some ( mem ) = writer . mem . as_mut ( ) {
571+ mem. recordbatch_cloned ( schema)
572572 } else {
573573 Ok ( Vec :: new ( ) )
574574 }
575575 }
576576
577577 pub fn clear ( & self ) -> Result < ( ) , StagingError > {
578- self . writer
578+ if let Some ( m) = self
579+ . writer
579580 . lock ( )
580581 . map_err ( |poisoned| {
581582 StagingError :: PoisonError ( PoisonError :: new ( format ! (
@@ -584,7 +585,10 @@ impl Stream {
584585 ) ) )
585586 } ) ?
586587 . mem
587- . clear ( ) ;
588+ . as_mut ( )
589+ {
590+ m. clear ( )
591+ }
588592 Ok ( ( ) )
589593 }
590594
@@ -601,9 +605,9 @@ impl Stream {
601605 self . stream_name, poisoned
602606 ) ) )
603607 } ) ?;
604- // why clean Writer.MemWriter?
605- if * ENABLE_MEMORY_STAGING {
606- writer . mem . clear ( ) ;
608+
609+ if let Some ( mem ) = writer . mem . as_mut ( ) {
610+ mem. clear ( ) ;
607611 }
608612 writer. take_flushable_disk ( forced)
609613 } ;
0 commit comments