@ -1902,6 +1902,10 @@ Status BlockBasedTable::DumpTable(WritableFile* out_file) {
out_file - > Append ( " Filter block handle: " ) ;
out_file - > Append ( " Filter block handle: " ) ;
out_file - > Append ( meta_iter - > value ( ) . ToString ( true ) . c_str ( ) ) ;
out_file - > Append ( meta_iter - > value ( ) . ToString ( true ) . c_str ( ) ) ;
out_file - > Append ( " \n " ) ;
out_file - > Append ( " \n " ) ;
} else if ( meta_iter - > key ( ) = = rocksdb : : kRangeDelBlock ) {
out_file - > Append ( " Range deletion block handle: " ) ;
out_file - > Append ( meta_iter - > value ( ) . ToString ( true ) . c_str ( ) ) ;
out_file - > Append ( " \n " ) ;
}
}
}
}
out_file - > Append ( " \n " ) ;
out_file - > Append ( " \n " ) ;
@ -1961,6 +1965,19 @@ Status BlockBasedTable::DumpTable(WritableFile* out_file) {
if ( ! s . ok ( ) ) {
if ( ! s . ok ( ) ) {
return s ;
return s ;
}
}
// Output range deletions block
auto range_del_iter = NewRangeTombstoneIterator ( ReadOptions ( ) ) ;
range_del_iter - > SeekToFirst ( ) ;
if ( range_del_iter - > Valid ( ) ) {
out_file - > Append (
" Range deletions: \n "
" -------------------------------------- \n "
" " ) ;
for ( ; range_del_iter - > Valid ( ) ; range_del_iter - > Next ( ) ) {
DumpKeyValue ( range_del_iter - > key ( ) , range_del_iter - > value ( ) , out_file ) ;
}
out_file - > Append ( " \n " ) ;
}
// Output Data blocks
// Output Data blocks
s = DumpDataBlocks ( out_file ) ;
s = DumpDataBlocks ( out_file ) ;
@ -2085,8 +2102,33 @@ Status BlockBasedTable::DumpDataBlocks(WritableFile* out_file) {
out_file - > Append ( " Error reading the block - Skipped \n " ) ;
out_file - > Append ( " Error reading the block - Skipped \n " ) ;
break ;
break ;
}
}
Slice key = datablock_iter - > key ( ) ;
DumpKeyValue ( datablock_iter - > key ( ) , datablock_iter - > value ( ) , out_file ) ;
Slice value = datablock_iter - > value ( ) ;
}
out_file - > Append ( " \n " ) ;
}
uint64_t num_datablocks = block_id - 1 ;
if ( num_datablocks ) {
double datablock_size_avg =
static_cast < double > ( datablock_size_sum ) / num_datablocks ;
out_file - > Append ( " Data Block Summary: \n " ) ;
out_file - > Append ( " -------------------------------------- " ) ;
out_file - > Append ( " \n # data blocks: " ) ;
out_file - > Append ( rocksdb : : ToString ( num_datablocks ) ) ;
out_file - > Append ( " \n min data block size: " ) ;
out_file - > Append ( rocksdb : : ToString ( datablock_size_min ) ) ;
out_file - > Append ( " \n max data block size: " ) ;
out_file - > Append ( rocksdb : : ToString ( datablock_size_max ) ) ;
out_file - > Append ( " \n avg data block size: " ) ;
out_file - > Append ( rocksdb : : ToString ( datablock_size_avg ) ) ;
out_file - > Append ( " \n " ) ;
}
return Status : : OK ( ) ;
}
void BlockBasedTable : : DumpKeyValue ( const Slice & key , const Slice & value ,
WritableFile * out_file ) {
InternalKey ikey ;
InternalKey ikey ;
ikey . DecodeFrom ( key ) ;
ikey . DecodeFrom ( key ) ;
@ -2115,28 +2157,6 @@ Status BlockBasedTable::DumpDataBlocks(WritableFile* out_file) {
out_file - > Append ( res_value . c_str ( ) ) ;
out_file - > Append ( res_value . c_str ( ) ) ;
out_file - > Append ( " \n ------ \n " ) ;
out_file - > Append ( " \n ------ \n " ) ;
}
}
out_file - > Append ( " \n " ) ;
}
uint64_t num_datablocks = block_id - 1 ;
if ( num_datablocks ) {
double datablock_size_avg =
static_cast < double > ( datablock_size_sum ) / num_datablocks ;
out_file - > Append ( " Data Block Summary: \n " ) ;
out_file - > Append ( " -------------------------------------- " ) ;
out_file - > Append ( " \n # data blocks: " ) ;
out_file - > Append ( rocksdb : : ToString ( num_datablocks ) ) ;
out_file - > Append ( " \n min data block size: " ) ;
out_file - > Append ( rocksdb : : ToString ( datablock_size_min ) ) ;
out_file - > Append ( " \n max data block size: " ) ;
out_file - > Append ( rocksdb : : ToString ( datablock_size_max ) ) ;
out_file - > Append ( " \n avg data block size: " ) ;
out_file - > Append ( rocksdb : : ToString ( datablock_size_avg ) ) ;
out_file - > Append ( " \n " ) ;
}
return Status : : OK ( ) ;
}
namespace {
namespace {