@@ -280,6 +280,7 @@ impl SstableMeta {
280
280
/// | smallest key len (4B) | smallest key |
281
281
/// | largest key len (4B) | largest key |
282
282
/// | range-tombstone 0 | ... | range-tombstone M-1 |
283
+ /// | file offset of this meta block (8B) |
283
284
/// | checksum (8B) | version (4B) | magic (4B) |
284
285
/// ```
285
286
pub fn encode_to_bytes ( & self ) -> Vec < u8 > {
@@ -299,11 +300,11 @@ impl SstableMeta {
299
300
buf. put_u32_le ( self . key_count ) ;
300
301
put_length_prefixed_slice ( buf, & self . smallest_key ) ;
301
302
put_length_prefixed_slice ( buf, & self . largest_key ) ;
302
- buf. put_u64_le ( self . meta_offset ) ;
303
303
buf. put_u32_le ( self . range_tombstone_list . len ( ) as u32 ) ;
304
304
for tombstone in & self . range_tombstone_list {
305
305
tombstone. encode ( buf) ;
306
306
}
307
+ buf. put_u64_le ( self . meta_offset ) ;
307
308
let checksum = xxhash64_checksum ( & buf[ start_offset..] ) ;
308
309
buf. put_u64_le ( checksum) ;
309
310
buf. put_u32_le ( VERSION ) ;
@@ -340,13 +341,13 @@ impl SstableMeta {
340
341
let key_count = buf. get_u32_le ( ) ;
341
342
let smallest_key = get_length_prefixed_slice ( buf) ;
342
343
let largest_key = get_length_prefixed_slice ( buf) ;
343
- let meta_offset = buf. get_u64_le ( ) ;
344
344
let range_del_count = buf. get_u32_le ( ) as usize ;
345
345
let mut range_tombstone_list = Vec :: with_capacity ( range_del_count) ;
346
346
for _ in 0 ..range_del_count {
347
347
let tombstone = DeleteRangeTombstone :: decode ( buf) ;
348
348
range_tombstone_list. push ( tombstone) ;
349
349
}
350
+ let meta_offset = buf. get_u64_le ( ) ;
350
351
351
352
Ok ( Self {
352
353
block_metas,
0 commit comments