File tree Expand file tree Collapse file tree
datafusion/execution/src/cache Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -112,7 +112,12 @@ impl DefaultFileStatisticsCacheState {
112112 }
113113
114114 fn remove ( & mut self , k : & Path ) -> Option < CachedFileMetadata > {
115- self . lru_queue . remove ( k)
115+ if let Some ( old_entry) = self . lru_queue . remove ( k) {
116+ self . memory_used -= old_entry. heap_size ( ) ;
117+ Some ( old_entry)
118+ } else {
119+ None
120+ }
116121 }
117122
118123 fn contains_key ( & self , k : & Path ) -> bool {
@@ -567,11 +572,14 @@ mod tests {
567572 assert_eq ! ( result_3. unwrap( ) , value_3) ;
568573
569574 cache. remove ( & meta_2. location ) ;
570-
571575 assert_eq ! ( cache. len( ) , 1 ) ;
576+ assert_eq ! ( cache. memory_used( ) , value_3. heap_size( ) ) ;
577+
572578
573579 cache. clear ( ) ;
574580 assert_eq ! ( cache. len( ) , 0 ) ;
581+ assert_eq ! ( cache. memory_used( ) , 0 ) ;
582+
575583 }
576584
577585 #[ test]
You can’t perform that action at this time.
0 commit comments