@ -176,16 +176,20 @@ Cache::Handle* GetEntryFromCache(Cache* block_cache, const Slice& key,
// For hash based index, return true if prefix_extractor and
// For hash based index, return true if prefix_extractor and
// prefix_extractor_block mismatch, false otherwise. This flag will be used
// prefix_extractor_block mismatch, false otherwise. This flag will be used
// as total_order_seek via NewIndexIterator
// as total_order_seek via NewIndexIterator
bool PrefixExtractorChanged ( std : : string prefix_extractor_block ,
bool PrefixExtractorChanged (
const SliceTransform * prefix_extractor ) {
std : : shared_ptr < const TableProperties > table_properties ,
const SliceTransform * prefix_extractor ) {
// BlockBasedTableOptions::kHashSearch requires prefix_extractor to be set.
// BlockBasedTableOptions::kHashSearch requires prefix_extractor to be set.
// Turn off hash index in prefix_extractor is not set; if prefix_extractor
// Turn off hash index in prefix_extractor is not set; if prefix_extractor
// is set but prefix_extractor_block is not set, also disable hash index
// is set but prefix_extractor_block is not set, also disable hash index
if ( prefix_extractor = = nullptr | | prefix_extractor_block . empty ( ) ) {
if ( prefix_extractor = = nullptr | | table_properties = = nullptr | |
table_properties - > prefix_extractor_name . empty ( ) ) {
return true ;
return true ;
}
}
// prefix_extractor and prefix_extractor_block are both non-empty
// prefix_extractor and prefix_extractor_block are both non-empty
if ( prefix_extractor_block . compare ( prefix_extractor - > Name ( ) ) ! = 0 ) {
if ( table_properties - > prefix_extractor_name . compare (
prefix_extractor - > Name ( ) ) ! = 0 ) {
return true ;
return true ;
} else {
} else {
return false ;
return false ;
@ -887,8 +891,8 @@ Status BlockBasedTable::Open(const ImmutableCFOptions& ioptions,
bool prefix_extractor_changed = false ;
bool prefix_extractor_changed = false ;
// check prefix_extractor match only if hash based index is used
// check prefix_extractor match only if hash based index is used
if ( rep - > index_type = = BlockBasedTableOptions : : kHashSearch ) {
if ( rep - > index_type = = BlockBasedTableOptions : : kHashSearch ) {
prefix_extractor_changed = PrefixExtractorChanged (
prefix_extractor_changed =
rep - > table_properties - > prefix_extractor_name , prefix_extractor ) ;
PrefixExtractorChanged ( rep - > table_properties , prefix_extractor ) ;
}
}
unique_ptr < InternalIterator > iter ( new_table - > NewIndexIterator (
unique_ptr < InternalIterator > iter ( new_table - > NewIndexIterator (
ReadOptions ( ) , prefix_extractor_changed , nullptr , & index_entry ) ) ;
ReadOptions ( ) , prefix_extractor_changed , nullptr , & index_entry ) ) ;
@ -2018,8 +2022,8 @@ void BlockBasedTableIterator::FindKeyBackward() {
InternalIterator * BlockBasedTable : : NewIterator (
InternalIterator * BlockBasedTable : : NewIterator (
const ReadOptions & read_options , const SliceTransform * prefix_extractor ,
const ReadOptions & read_options , const SliceTransform * prefix_extractor ,
Arena * arena , bool skip_filters ) {
Arena * arena , bool skip_filters ) {
bool prefix_extractor_changed = PrefixExtractorChanged (
bool prefix_extractor_changed =
rep_ - > table_properties - > prefix_extractor_name , prefix_extractor ) ;
PrefixExtractorChanged ( rep_ - > table_properties , prefix_extractor ) ;
if ( arena = = nullptr ) {
if ( arena = = nullptr ) {
return new BlockBasedTableIterator (
return new BlockBasedTableIterator (
this , read_options , rep_ - > internal_comparator ,
this , read_options , rep_ - > internal_comparator ,
@ -2124,8 +2128,8 @@ Status BlockBasedTable::Get(const ReadOptions& read_options, const Slice& key,
// BlockPrefixIndex. Only do this check when index_type is kHashSearch.
// BlockPrefixIndex. Only do this check when index_type is kHashSearch.
bool prefix_extractor_changed = false ;
bool prefix_extractor_changed = false ;
if ( rep_ - > index_type = = BlockBasedTableOptions : : kHashSearch ) {
if ( rep_ - > index_type = = BlockBasedTableOptions : : kHashSearch ) {
prefix_extractor_changed = PrefixExtractorChanged (
prefix_extractor_changed =
rep_ - > table_properties - > prefix_extractor_name , prefix_extractor ) ;
PrefixExtractorChanged ( rep_ - > table_properties , prefix_extractor ) ;
}
}
auto iiter = NewIndexIterator ( read_options , prefix_extractor_changed ,
auto iiter = NewIndexIterator ( read_options , prefix_extractor_changed ,
& iiter_on_stack , /* index_entry */ nullptr ,
& iiter_on_stack , /* index_entry */ nullptr ,