@ -1201,28 +1201,29 @@ Status BlockBasedTable::Open(
rep - > compression_dict_handle = BlockHandle : : NullBlockHandle ( ) ;
// Read metaindex
std : : unique_ptr < Block > meta ;
std : : unique_ptr < InternalIterator > meta_iter ;
s = new_table - > ReadMetaBlock ( prefetch_buffer . get ( ) , & meta , & meta_iter ) ;
std : : unique_ptr < Block > metaindex ;
std : : unique_ptr < InternalIterator > metaindex_iter ;
s = new_table - > ReadMetaIndexBlock ( prefetch_buffer . get ( ) , & metaindex ,
& metaindex_iter ) ;
if ( ! s . ok ( ) ) {
return s ;
}
// Populates table_properties and some fields that depend on it,
// such as index_type.
s = new_table - > ReadPropertiesBlock ( prefetch_buffer . get ( ) , meta_iter . get ( ) ,
largest_seqno ) ;
s = new_table - > ReadPropertiesBlock ( prefetch_buffer . get ( ) ,
metaindex_iter . get ( ) , largest_seqno ) ;
if ( ! s . ok ( ) ) {
return s ;
}
s = new_table - > ReadRangeDelBlock ( prefetch_buffer . get ( ) , meta_iter . get ( ) ,
s = new_table - > ReadRangeDelBlock ( prefetch_buffer . get ( ) , metaindex _iter . get ( ) ,
internal_comparator , & lookup_context ) ;
if ( ! s . ok ( ) ) {
return s ;
}
s = new_table - > PrefetchIndexAndFilterBlocks (
prefetch_buffer . get ( ) , meta_iter . get ( ) , new_table . get ( ) , prefetch_all ,
table_options , level , & lookup_context ) ;
prefetch_buffer . get ( ) , metaindex _iter . get ( ) , new_table . get ( ) ,
prefetch_all , table_options , level , & lookup_context ) ;
if ( s . ok ( ) ) {
// Update tail prefetch stats
@ -1634,17 +1635,19 @@ size_t BlockBasedTable::ApproximateMemoryUsage() const {
return usage ;
}
// Load the meta-block from the file. On success, return the loaded meta block
// and its iterator.
Status BlockBasedTable : : ReadMetaBlock ( FilePrefetchBuffer * prefetch_buffer ,
std : : unique_ptr < Block > * meta_block ,
std : : unique_ptr < InternalIterator > * iter ) {
// Load the meta-index-block from the file. On success, return the loaded
// metaindex
// block and its iterator.
Status BlockBasedTable : : ReadMetaIndexBlock (
FilePrefetchBuffer * prefetch_buffer ,
std : : unique_ptr < Block > * metaindex_block ,
std : : unique_ptr < InternalIterator > * iter ) {
// TODO(sanjay): Skip this if footer.metaindex_handle() size indicates
// it is an empty block.
std : : unique_ptr < Block > meta ;
std : : unique_ptr < Block > metaindex ;
Status s = ReadBlockFromFile (
rep_ - > file . get ( ) , prefetch_buffer , rep_ - > footer , ReadOptions ( ) ,
rep_ - > footer . metaindex_handle ( ) , & meta , rep_ - > ioptions ,
rep_ - > footer . metaindex_handle ( ) , & metaindex , rep_ - > ioptions ,
true /* decompress */ , true /*maybe_compressed*/ , BlockType : : kMetaIndex ,
UncompressionDict : : GetEmptyDict ( ) , rep_ - > persistent_cache_options ,
kDisableGlobalSequenceNumber , 0 /* read_amp_bytes_per_bit */ ,
@ -1659,10 +1662,10 @@ Status BlockBasedTable::ReadMetaBlock(FilePrefetchBuffer* prefetch_buffer,
return s ;
}
* meta_block = std : : move ( meta ) ;
* metaindex _block = std : : move ( metaindex ) ;
// meta block uses bytewise comparator.
iter - > reset ( meta_block - > get ( ) - > NewDataIterator ( BytewiseComparator ( ) ,
BytewiseComparator ( ) ) ) ;
iter - > reset ( metaindex _block - > get ( ) - > NewDataIterator ( BytewiseComparator ( ) ,
BytewiseComparator ( ) ) ) ;
return Status : : OK ( ) ;
}
@ -3743,11 +3746,12 @@ Status BlockBasedTable::VerifyChecksum(const ReadOptions& read_options,
TableReaderCaller caller ) {
Status s ;
// Check Meta blocks
std : : unique_ptr < Block > meta ;
std : : unique_ptr < InternalIterator > meta_iter ;
s = ReadMetaBlock ( nullptr /* prefetch buffer */ , & meta , & meta_iter ) ;
std : : unique_ptr < Block > metaindex ;
std : : unique_ptr < InternalIterator > metaindex_iter ;
s = ReadMetaIndexBlock ( nullptr /* prefetch buffer */ , & metaindex ,
& metaindex_iter ) ;
if ( s . ok ( ) ) {
s = VerifyChecksumInMetaBlocks ( meta_iter . get ( ) ) ;
s = VerifyChecksumInMetaBlocks ( metaindex _iter . get ( ) ) ;
if ( ! s . ok ( ) ) {
return s ;
}
@ -3938,11 +3942,12 @@ Status BlockBasedTable::CreateIndexReader(
index_reader ) ;
}
case BlockBasedTableOptions : : kHashSearch : {
std : : unique_ptr < Block > meta_guard ;
std : : unique_ptr < InternalIterator > meta_iter_guard ;
std : : unique_ptr < Block > metaindex _guard ;
std : : unique_ptr < InternalIterator > metaindex _iter_guard ;
auto meta_index_iter = preloaded_meta_index_iter ;
if ( meta_index_iter = = nullptr ) {
auto s = ReadMetaBlock ( prefetch_buffer , & meta_guard , & meta_iter_guard ) ;
auto s = ReadMetaIndexBlock ( prefetch_buffer , & metaindex_guard ,
& metaindex_iter_guard ) ;
if ( ! s . ok ( ) ) {
// we simply fall back to binary search in case there is any
// problem with prefix hash index loading.
@ -3953,7 +3958,7 @@ Status BlockBasedTable::CreateIndexReader(
use_cache , prefetch , pin ,
lookup_context , index_reader ) ;
}
meta_index_iter = meta_iter_guard . get ( ) ;
meta_index_iter = metaindex _iter_guard . get ( ) ;
}
return HashIndexReader : : Create ( this , prefetch_buffer , meta_index_iter ,
@ -4110,31 +4115,33 @@ Status BlockBasedTable::DumpTable(WritableFile* out_file) {
out_file - > Append (
" Metaindex Details: \n "
" -------------------------------------- \n " ) ;
std : : unique_ptr < Block > meta ;
std : : unique_ptr < InternalIterator > meta_iter ;
Status s = ReadMetaBlock ( nullptr /* prefetch_buffer */ , & meta , & meta_iter ) ;
std : : unique_ptr < Block > metaindex ;
std : : unique_ptr < InternalIterator > metaindex_iter ;
Status s = ReadMetaIndexBlock ( nullptr /* prefetch_buffer */ , & metaindex ,
& metaindex_iter ) ;
if ( s . ok ( ) ) {
for ( meta_iter - > SeekToFirst ( ) ; meta_iter - > Valid ( ) ; meta_iter - > Next ( ) ) {
s = meta_iter - > status ( ) ;
for ( metaindex_iter - > SeekToFirst ( ) ; metaindex_iter - > Valid ( ) ;
metaindex_iter - > Next ( ) ) {
s = metaindex_iter - > status ( ) ;
if ( ! s . ok ( ) ) {
return s ;
}
if ( meta_iter - > key ( ) = = rocksdb : : kPropertiesBlock ) {
if ( metaindex _iter - > key ( ) = = rocksdb : : kPropertiesBlock ) {
out_file - > Append ( " Properties block handle: " ) ;
out_file - > Append ( meta_iter - > value ( ) . ToString ( true ) . c_str ( ) ) ;
out_file - > Append ( metaindex _iter - > value ( ) . ToString ( true ) . c_str ( ) ) ;
out_file - > Append ( " \n " ) ;
} else if ( meta_iter - > key ( ) = = rocksdb : : kCompressionDictBlock ) {
} else if ( metaindex _iter - > key ( ) = = rocksdb : : kCompressionDictBlock ) {
out_file - > Append ( " Compression dictionary block handle: " ) ;
out_file - > Append ( meta_iter - > value ( ) . ToString ( true ) . c_str ( ) ) ;
out_file - > Append ( metaindex _iter - > value ( ) . ToString ( true ) . c_str ( ) ) ;
out_file - > Append ( " \n " ) ;
} else if ( strstr ( meta_iter - > key ( ) . ToString ( ) . c_str ( ) ,
} else if ( strstr ( metaindex _iter - > key ( ) . ToString ( ) . c_str ( ) ,
" filter.rocksdb. " ) ! = nullptr ) {
out_file - > Append ( " Filter block handle: " ) ;
out_file - > Append ( meta_iter - > value ( ) . ToString ( true ) . c_str ( ) ) ;
out_file - > Append ( metaindex _iter - > value ( ) . ToString ( true ) . c_str ( ) ) ;
out_file - > Append ( " \n " ) ;
} else if ( meta_iter - > key ( ) = = rocksdb : : kRangeDelBlock ) {
} else if ( metaindex _iter - > key ( ) = = rocksdb : : kRangeDelBlock ) {
out_file - > Append ( " Range deletion block handle: " ) ;
out_file - > Append ( meta_iter - > value ( ) . ToString ( true ) . c_str ( ) ) ;
out_file - > Append ( metaindex _iter - > value ( ) . ToString ( true ) . c_str ( ) ) ;
out_file - > Append ( " \n " ) ;
}
}