@ -80,14 +80,14 @@ Status ReadBlockFromFile(
RandomAccessFileReader * file , FilePrefetchBuffer * prefetch_buffer ,
const Footer & footer , const ReadOptions & options , const BlockHandle & handle ,
std : : unique_ptr < Block > * result , const ImmutableCFOptions & ioptions ,
bool do_uncompress , bool maybe_compressed ,
bool do_uncompress , bool maybe_compressed , BlockType block_type ,
const UncompressionDict & uncompression_dict ,
const PersistentCacheOptions & cache_options , SequenceNumber global_seqno ,
size_t read_amp_bytes_per_bit , MemoryAllocator * memory_allocator ) {
BlockContents contents ;
BlockFetcher block_fetcher ( file , prefetch_buffer , footer , options , handle ,
& contents , ioptions , do_uncompress ,
maybe_compressed , uncompression_dict ,
maybe_compressed , block_type , uncompression_dict ,
cache_options , memory_allocator ) ;
Status s = block_fetcher . ReadBlockContents ( ) ;
if ( s . ok ( ) ) {
@ -603,8 +603,8 @@ class HashIndexReader : public BlockBasedTable::IndexReaderCommon {
BlockFetcher prefixes_block_fetcher (
file , prefetch_buffer , footer , ReadOptions ( ) , prefixes_handle ,
& prefixes_contents , ioptions , true /*decompress*/ ,
true /*maybe_compressed*/ , UncompressionDict : : GetEmptyDict ( ) ,
cache_options , memory_allocator ) ;
true /*maybe_compressed*/ , BlockType : : kHashIndexPrefixes ,
UncompressionDict : : GetEmptyDict ( ) , cache_options , memory_allocator ) ;
s = prefixes_block_fetcher . ReadBlockContents ( ) ;
if ( ! s . ok ( ) ) {
return s ;
@ -613,8 +613,8 @@ class HashIndexReader : public BlockBasedTable::IndexReaderCommon {
BlockFetcher prefixes_meta_block_fetcher (
file , prefetch_buffer , footer , ReadOptions ( ) , prefixes_meta_handle ,
& prefixes_meta_contents , ioptions , true /*decompress*/ ,
true /*maybe_compressed*/ , UncompressionDict : : GetEmptyDict ( ) ,
cache_options , memory_allocator ) ;
true /*maybe_compressed*/ , BlockType : : kHashIndexMetadata ,
UncompressionDict : : GetEmptyDict ( ) , cache_options , memory_allocator ) ;
s = prefixes_meta_block_fetcher . ReadBlockContents ( ) ;
if ( ! s . ok ( ) ) {
// TODO: log error
@ -1373,7 +1373,8 @@ Status BlockBasedTable::ReadCompressionDictBlock(
rep_ - > file . get ( ) , prefetch_buffer , rep_ - > footer , read_options ,
rep_ - > compression_dict_handle , compression_dict_cont . get ( ) ,
rep_ - > ioptions , false /* decompress */ , false /*maybe_compressed*/ ,
UncompressionDict : : GetEmptyDict ( ) , cache_options ) ;
BlockType : : kCompressionDictionary , UncompressionDict : : GetEmptyDict ( ) ,
cache_options ) ;
s = compression_block_fetcher . ReadBlockContents ( ) ;
if ( ! s . ok ( ) ) {
@ -1583,7 +1584,7 @@ Status BlockBasedTable::ReadMetaBlock(FilePrefetchBuffer* prefetch_buffer,
Status s = ReadBlockFromFile (
rep_ - > file . get ( ) , prefetch_buffer , rep_ - > footer , ReadOptions ( ) ,
rep_ - > footer . metaindex_handle ( ) , & meta , rep_ - > ioptions ,
true /* decompress */ , true /*maybe_compressed*/ ,
true /* decompress */ , true /*maybe_compressed*/ , BlockType : : kMetaIndex ,
UncompressionDict : : GetEmptyDict ( ) , rep_ - > persistent_cache_options ,
kDisableGlobalSequenceNumber , 0 /* read_amp_bytes_per_bit */ ,
GetMemoryAllocator ( rep_ - > table_options ) ) ;
@ -1818,8 +1819,9 @@ FilterBlockReader* BlockBasedTable::ReadFilter(
BlockFetcher block_fetcher (
rep - > file . get ( ) , prefetch_buffer , rep - > footer , ReadOptions ( ) ,
filter_handle , & block , rep - > ioptions , false /* decompress */ ,
false /*maybe_compressed*/ , UncompressionDict : : GetEmptyDict ( ) ,
rep - > persistent_cache_options , GetMemoryAllocator ( rep - > table_options ) ) ;
false /*maybe_compressed*/ , BlockType : : kFilter ,
UncompressionDict : : GetEmptyDict ( ) , rep - > persistent_cache_options ,
GetMemoryAllocator ( rep - > table_options ) ) ;
Status s = block_fetcher . ReadBlockContents ( ) ;
if ( ! s . ok ( ) ) {
@ -1940,7 +1942,6 @@ CachableEntry<FilterBlockReader> BlockBasedTable::GetFilter(
? Cache : : Priority : : HIGH
: Cache : : Priority : : LOW ) ;
if ( s . ok ( ) ) {
PERF_COUNTER_ADD ( filter_block_read_count , 1 ) ;
UpdateCacheInsertionMetrics ( BlockType : : kFilter , get_context , usage ) ;
} else {
RecordTick ( rep_ - > ioptions . statistics , BLOCK_CACHE_ADD_FAILURES ) ;
@ -2021,7 +2022,6 @@ CachableEntry<UncompressionDict> BlockBasedTable::GetUncompressionDict(
: Cache : : Priority : : LOW ) ;
if ( s . ok ( ) ) {
PERF_COUNTER_ADD ( compression_dict_block_read_count , 1 ) ;
UpdateCacheInsertionMetrics ( BlockType : : kCompressionDictionary ,
get_context , usage ) ;
dict = uncompression_dict . release ( ) ;
@ -2217,7 +2217,7 @@ Status BlockBasedTable::MaybeReadBlockAndLoadToCache(
rep_ - > file . get ( ) , prefetch_buffer , rep_ - > footer , ro , handle ,
& raw_block_contents , rep_ - > ioptions ,
do_decompress /* do uncompress */ , rep_ - > blocks_maybe_compressed ,
uncompression_dict , rep_ - > persistent_cache_options ,
block_type , uncompression_dict , rep_ - > persistent_cache_options ,
GetMemoryAllocator ( rep_ - > table_options ) ,
GetMemoryAllocatorForCompressedBlock ( rep_ - > table_options ) ) ;
s = block_fetcher . ReadBlockContents ( ) ;
@ -2335,7 +2335,7 @@ Status BlockBasedTable::RetrieveBlock(
s = ReadBlockFromFile (
rep_ - > file . get ( ) , prefetch_buffer , rep_ - > footer , ro , handle , & block ,
rep_ - > ioptions , rep_ - > blocks_maybe_compressed ,
rep_ - > blocks_maybe_compressed , uncompression_dict ,
rep_ - > blocks_maybe_compressed , block_type , uncompression_dict ,
rep_ - > persistent_cache_options , rep_ - > get_global_seqno ( block_type ) ,
block_type = = BlockType : : kData
? rep_ - > table_options . read_amp_bytes_per_bit
@ -3335,7 +3335,7 @@ Status BlockBasedTable::VerifyChecksumInBlocks(
BlockFetcher block_fetcher (
rep_ - > file . get ( ) , nullptr /* prefetch buffer */ , rep_ - > footer ,
ReadOptions ( ) , handle , & contents , rep_ - > ioptions ,
false /* decompress */ , false /*maybe_compressed*/ ,
false /* decompress */ , false /*maybe_compressed*/ , BlockType : : kData ,
UncompressionDict : : GetEmptyDict ( ) , rep_ - > persistent_cache_options ) ;
s = block_fetcher . ReadBlockContents ( ) ;
if ( ! s . ok ( ) ) {
@ -3345,6 +3345,38 @@ Status BlockBasedTable::VerifyChecksumInBlocks(
return s ;
}
BlockType BlockBasedTable : : GetBlockTypeForMetaBlockByName (
const Slice & meta_block_name ) {
if ( meta_block_name . starts_with ( kFilterBlockPrefix ) | |
meta_block_name . starts_with ( kFullFilterBlockPrefix ) | |
meta_block_name . starts_with ( kPartitionedFilterBlockPrefix ) ) {
return BlockType : : kFilter ;
}
if ( meta_block_name = = kPropertiesBlock ) {
return BlockType : : kProperties ;
}
if ( meta_block_name = = kCompressionDictBlock ) {
return BlockType : : kCompressionDictionary ;
}
if ( meta_block_name = = kRangeDelBlock ) {
return BlockType : : kRangeDeletion ;
}
if ( meta_block_name = = kHashIndexPrefixesBlock ) {
return BlockType : : kHashIndexPrefixes ;
}
if ( meta_block_name = = kHashIndexPrefixesMetadataBlock ) {
return BlockType : : kHashIndexMetadata ;
}
assert ( false ) ;
return BlockType : : kInvalid ;
}
Status BlockBasedTable : : VerifyChecksumInMetaBlocks (
InternalIteratorBase < Slice > * index_iter ) {
Status s ;
@ -3357,13 +3389,15 @@ Status BlockBasedTable::VerifyChecksumInMetaBlocks(
Slice input = index_iter - > value ( ) ;
s = handle . DecodeFrom ( & input ) ;
BlockContents contents ;
const Slice meta_block_name = index_iter - > key ( ) ;
BlockFetcher block_fetcher (
rep_ - > file . get ( ) , nullptr /* prefetch buffer */ , rep_ - > footer ,
ReadOptions ( ) , handle , & contents , rep_ - > ioptions ,
false /* decompress */ , false /*maybe_compressed*/ ,
GetBlockTypeForMetaBlockByName ( meta_block_name ) ,
UncompressionDict : : GetEmptyDict ( ) , rep_ - > persistent_cache_options ) ;
s = block_fetcher . ReadBlockContents ( ) ;
if ( s . IsCorruption ( ) & & index_iter - > key ( ) = = kPropertiesBlock ) {
if ( s . IsCorruption ( ) & & meta_block_name = = kPropertiesBlock ) {
TableProperties * table_properties ;
s = TryReadPropertiesWithGlobalSeqno ( nullptr /* prefetch_buffer */ ,
index_iter - > value ( ) ,
@ -3662,7 +3696,7 @@ Status BlockBasedTable::DumpTable(WritableFile* out_file,
rep_ - > file . get ( ) , nullptr /* prefetch_buffer */ , rep_ - > footer ,
ReadOptions ( ) , handle , & block , rep_ - > ioptions ,
false /*decompress*/ , false /*maybe_compressed*/ ,
UncompressionDict : : GetEmptyDict ( ) ,
BlockType : : kFilter , UncompressionDict : : GetEmptyDict ( ) ,
rep_ - > persistent_cache_options ) ;
s = block_fetcher . ReadBlockContents ( ) ;
if ( ! s . ok ( ) ) {