@@ -45,7 +45,6 @@ use iter::Iter;
4545use std:: {
4646 borrow:: Cow ,
4747 fs:: File ,
48- io:: { BufReader , Read , Seek } ,
4948 ops:: { Bound , RangeBounds } ,
5049 path:: PathBuf ,
5150 sync:: Arc ,
@@ -115,14 +114,29 @@ impl Table {
115114 use byteorder:: { ReadBytesExt , LE } ;
116115
117116 Ok ( if let Some ( handle) = & self . regions . linked_blob_files {
118- let reader = File :: open ( & * self . path ) ? ;
119- let mut reader = BufReader :: new ( reader ) ;
120- reader . seek ( std :: io :: SeekFrom :: Start ( * handle . offset ( ) ) ) ? ;
121- let mut reader = reader . take ( u64 :: from ( handle . size ( ) ) ) ;
117+ // Try to get FD from descriptor table first, similar to util::load_block
118+ let table_id = self . global_id ( ) ;
119+ let cached_fd = self . descriptor_table . access_for_table ( & table_id ) ;
120+ let fd_cache_miss = cached_fd . is_none ( ) ;
122121
123- let mut blob_files = vec ! [ ] ;
122+ let fd = if let Some ( fd) = cached_fd {
123+ fd
124+ } else {
125+ Arc :: new ( File :: open ( & * self . path ) ?)
126+ } ;
127+
128+ // Read the exact region using pread-style helper
129+ let buf = crate :: file:: read_exact ( & fd, * handle. offset ( ) , handle. size ( ) as usize ) ?;
130+
131+ // If we opened the file here, cache the FD for future accesses
132+ if fd_cache_miss {
133+ self . descriptor_table . insert_for_table ( table_id, fd) ;
134+ }
124135
136+ // Parse the buffer
137+ let mut reader = & buf[ ..] ;
125138 let len = reader. read_u32 :: < LE > ( ) ?;
139+ let mut blob_files = Vec :: with_capacity ( len as usize ) ;
126140
127141 for _ in 0 ..len {
128142 let blob_file_id = reader. read_u64 :: < LE > ( ) ?;
0 commit comments