@@ -74,15 +74,15 @@ pub struct StaticSortedFileMetaData {
7474}
7575
7676impl StaticSortedFileMetaData {
77- pub fn block_offsets_start ( & self ) -> usize {
78- let k: usize = self . key_compression_dictionary_length . into ( ) ;
79- let v: usize = self . value_compression_dictionary_length . into ( ) ;
80- k + v
77+ pub fn block_offsets_start ( & self , sst_len : usize ) -> usize {
78+ let bc: usize = self . block_count . into ( ) ;
79+ sst_len - ( bc * size_of :: < u32 > ( ) )
8180 }
8281
8382 pub fn blocks_start ( & self ) -> usize {
84- let bc: usize = self . block_count . into ( ) ;
85- self . block_offsets_start ( ) + bc * size_of :: < u32 > ( )
83+ let k: usize = self . key_compression_dictionary_length . into ( ) ;
84+ let v: usize = self . value_compression_dictionary_length . into ( ) ;
85+ k + v
8686 }
8787
8888 pub fn key_compression_dictionary_range ( & self ) -> Range < usize > {
@@ -347,11 +347,11 @@ impl StaticSortedFile {
347347 self . meta. sequence_number,
348348 block_index,
349349 self . meta. block_count,
350- self . meta. block_offsets_start( ) ,
350+ self . meta. block_offsets_start( self . mmap . len ( ) ) ,
351351 self . meta. blocks_start( )
352352 ) ;
353353 }
354- let offset = self . meta . block_offsets_start ( ) + block_index as usize * 4 ;
354+ let offset = self . meta . block_offsets_start ( self . mmap . len ( ) ) + block_index as usize * 4 ;
355355 #[ cfg( feature = "strict_checks" ) ]
356356 if offset + 4 > self . mmap . len ( ) {
357357 bail ! (
@@ -361,7 +361,7 @@ impl StaticSortedFile {
361361 block_index,
362362 offset,
363363 self . mmap. len( ) ,
364- self . meta. block_offsets_start( ) ,
364+ self . meta. block_offsets_start( self . mmap . len ( ) ) ,
365365 self . meta. blocks_start( )
366366 ) ;
367367 }
@@ -382,7 +382,7 @@ impl StaticSortedFile {
382382 block_start,
383383 block_end,
384384 self . mmap. len( ) ,
385- self . meta. block_offsets_start( ) ,
385+ self . meta. block_offsets_start( self . mmap . len ( ) ) ,
386386 self . meta. blocks_start( )
387387 ) ;
388388 }
0 commit comments