@@ -1271,7 +1271,6 @@ impl Column {
12711271
12721272/// Encapsulates storage and a file handle.
12731273struct ImmutableFileRef {
1274- path : StoragePath ,
12751274 cache : fn ( ) -> Arc < BufferCache > ,
12761275 file_handle : Arc < dyn FileReader > ,
12771276 compression : Option < Compression > ,
@@ -1280,9 +1279,7 @@ struct ImmutableFileRef {
12801279
12811280impl Debug for ImmutableFileRef {
12821281 fn fmt ( & self , f : & mut Formatter < ' _ > ) -> FmtResult {
1283- f. debug_struct ( "ImmutableFileRef" )
1284- . field ( "path" , & self . path )
1285- . finish ( )
1282+ write ! ( f, "ImmutableFileRef({:?})" , & self . file_handle)
12861283 }
12871284}
12881285impl Drop for ImmutableFileRef {
@@ -1297,13 +1294,11 @@ impl ImmutableFileRef {
12971294 fn new (
12981295 cache : fn ( ) -> Arc < BufferCache > ,
12991296 file_handle : Arc < dyn FileReader > ,
1300- path : StoragePath ,
13011297 compression : Option < Compression > ,
13021298 stats : AtomicCacheStats ,
13031299 ) -> Self {
13041300 Self {
13051301 cache,
1306- path,
13071302 file_handle,
13081303 compression,
13091304 stats,
@@ -1436,20 +1431,19 @@ where
14361431 /// Creates and returns a new `Reader` for `file`.
14371432 pub ( crate ) fn new (
14381433 factories : & [ & AnyFactories ] ,
1439- path : StoragePath ,
14401434 cache : fn ( ) -> Arc < BufferCache > ,
1441- file_handle : Arc < dyn FileReader > ,
1435+ file : Arc < dyn FileReader > ,
14421436 bloom_filter : Option < BloomFilter > ,
14431437 ) -> Result < Self , Error > {
1444- let file_size = file_handle . get_size ( ) ?;
1438+ let file_size = file . get_size ( ) ?;
14451439 if file_size < 512 || ( file_size % 512 ) != 0 {
14461440 return Err ( CorruptionError :: InvalidFileSize ( file_size) . into ( ) ) ;
14471441 }
14481442
14491443 let stats = AtomicCacheStats :: default ( ) ;
14501444 let file_trailer = FileTrailer :: new (
14511445 cache,
1452- & * file_handle ,
1446+ & * file ,
14531447 BlockLocation :: new ( file_size - 512 , 512 ) . unwrap ( ) ,
14541448 & stats,
14551449 ) ?;
@@ -1460,7 +1454,7 @@ where
14601454 }
14611455 2 => {
14621456 // Version before [fastbloom] crate was upgraded to one with an incompatible format.
1463- warn ! ( "{path }: reading old format storage file, performance may be reduced due to incompatible Bloom filters" ) ;
1457+ warn ! ( "{}: reading old format storage file, performance may be reduced due to incompatible Bloom filters" , file . path ( ) ) ;
14641458 Some ( false )
14651459 }
14661460 VERSION_NUMBER => Some ( true ) ,
@@ -1473,7 +1467,8 @@ where
14731467
14741468 if file_trailer. compatible_features != 0 {
14751469 info ! (
1476- "{path}: storage file uses unsupported compatible features {:#x}" ,
1470+ "{}: storage file uses unsupported compatible features {:#x}" ,
1471+ file. path( ) ,
14771472 file_trailer. compatible_features
14781473 ) ;
14791474 }
@@ -1519,7 +1514,7 @@ where
15191514 Some ( bloom_filter) => Some ( bloom_filter) ,
15201515 None if has_compatible_bloom_filter && file_trailer. filter_offset != 0 => Some (
15211516 FilterBlock :: new (
1522- & * file_handle ,
1517+ & * file ,
15231518 BlockLocation :: new (
15241519 file_trailer. filter_offset ,
15251520 file_trailer. filter_size as usize ,
@@ -1534,7 +1529,7 @@ where
15341529 } ;
15351530
15361531 Ok ( Self {
1537- file : ImmutableFileRef :: new ( cache, file_handle , path , file_trailer. compression , stats) ,
1532+ file : ImmutableFileRef :: new ( cache, file , file_trailer. compression , stats) ,
15381533 columns,
15391534 bloom_filter,
15401535 _phantom : PhantomData ,
@@ -1553,13 +1548,7 @@ where
15531548 storage_backend : & dyn StorageBackend ,
15541549 path : & StoragePath ,
15551550 ) -> Result < Self , Error > {
1556- Self :: new (
1557- factories,
1558- path. clone ( ) ,
1559- cache,
1560- storage_backend. open ( path) ?,
1561- None ,
1562- )
1551+ Self :: new ( factories, cache, storage_backend. open ( path) ?, None )
15631552 }
15641553
15651554 /// The number of columns in the layer file.
@@ -1580,8 +1569,8 @@ where
15801569 }
15811570
15821571 /// Returns the storage path for the underlying object.
1583- pub fn path ( & self ) -> StoragePath {
1584- self . file . path . clone ( )
1572+ pub fn path ( & self ) -> & StoragePath {
1573+ self . file . file_handle . path ( )
15851574 }
15861575
15871576 /// Returns the size of the underlying file in bytes.
@@ -1602,8 +1591,8 @@ where
16021591 }
16031592
16041593 /// Returns the `FileReader` embedded in this `Reader`.
1605- pub fn file_handle ( & self ) -> & dyn FileReader {
1606- & * self . file . file_handle
1594+ pub fn file_handle ( & self ) -> & Arc < dyn FileReader > {
1595+ & self . file . file_handle
16071596 }
16081597}
16091598
0 commit comments