@ -409,7 +409,8 @@ Status PlainTableReader::PopulateIndex(TableProperties* props,
return Status : : OK ( ) ;
return Status : : OK ( ) ;
}
}
Status PlainTableReader : : GetOffset ( const Slice & target , const Slice & prefix ,
Status PlainTableReader : : GetOffset ( PlainTableKeyDecoder * decoder ,
const Slice & target , const Slice & prefix ,
uint32_t prefix_hash , bool & prefix_matched ,
uint32_t prefix_hash , bool & prefix_matched ,
uint32_t * offset ) const {
uint32_t * offset ) const {
prefix_matched = false ;
prefix_matched = false ;
@ -435,15 +436,12 @@ Status PlainTableReader::GetOffset(const Slice& target, const Slice& prefix,
return Status : : Corruption ( Slice ( ) ) ;
return Status : : Corruption ( Slice ( ) ) ;
}
}
PlainTableKeyDecoder decoder ( & file_info_ , encoding_type_ , user_key_len_ ,
ioptions_ . prefix_extractor ) ;
// The key is between [low, high). Do a binary search between it.
// The key is between [low, high). Do a binary search between it.
while ( high - low > 1 ) {
while ( high - low > 1 ) {
uint32_t mid = ( high + low ) / 2 ;
uint32_t mid = ( high + low ) / 2 ;
uint32_t file_offset = GetFixed32Element ( base_ptr , mid ) ;
uint32_t file_offset = GetFixed32Element ( base_ptr , mid ) ;
uint32_t tmp ;
uint32_t tmp ;
Status s = decoder . NextKeyNoValue ( file_offset , & mid_key , nullptr , & tmp ) ;
Status s = decoder - > NextKeyNoValue ( file_offset , & mid_key , nullptr , & tmp ) ;
if ( ! s . ok ( ) ) {
if ( ! s . ok ( ) ) {
return s ;
return s ;
}
}
@ -468,7 +466,7 @@ Status PlainTableReader::GetOffset(const Slice& target, const Slice& prefix,
ParsedInternalKey low_key ;
ParsedInternalKey low_key ;
uint32_t tmp ;
uint32_t tmp ;
uint32_t low_key_offset = GetFixed32Element ( base_ptr , low ) ;
uint32_t low_key_offset = GetFixed32Element ( base_ptr , low ) ;
Status s = decoder . NextKeyNoValue ( low_key_offset , & low_key , nullptr , & tmp ) ;
Status s = decoder - > NextKeyNoValue ( low_key_offset , & low_key , nullptr , & tmp ) ;
if ( ! s . ok ( ) ) {
if ( ! s . ok ( ) ) {
return s ;
return s ;
}
}
@ -559,8 +557,10 @@ Status PlainTableReader::Get(const ReadOptions& ro, const Slice& target,
}
}
uint32_t offset ;
uint32_t offset ;
bool prefix_match ;
bool prefix_match ;
Status s =
PlainTableKeyDecoder decoder ( & file_info_ , encoding_type_ , user_key_len_ ,
GetOffset ( target , prefix_slice , prefix_hash , prefix_match , & offset ) ;
ioptions_ . prefix_extractor ) ;
Status s = GetOffset ( & decoder , target , prefix_slice , prefix_hash ,
prefix_match , & offset ) ;
if ( ! s . ok ( ) ) {
if ( ! s . ok ( ) ) {
return s ;
return s ;
@ -571,8 +571,6 @@ Status PlainTableReader::Get(const ReadOptions& ro, const Slice& target,
return Status : : Corruption ( Slice ( ) ) ;
return Status : : Corruption ( Slice ( ) ) ;
}
}
Slice found_value ;
Slice found_value ;
PlainTableKeyDecoder decoder ( & file_info_ , encoding_type_ , user_key_len_ ,
ioptions_ . prefix_extractor ) ;
while ( offset < file_info_ . data_end_offset ) {
while ( offset < file_info_ . data_end_offset ) {
s = Next ( & decoder , & offset , & found_key , nullptr , & found_value ) ;
s = Next ( & decoder , & offset , & found_key , nullptr , & found_value ) ;
if ( ! s . ok ( ) ) {
if ( ! s . ok ( ) ) {
@ -662,8 +660,8 @@ void PlainTableIterator::Seek(const Slice& target) {
}
}
}
}
bool prefix_match ;
bool prefix_match ;
status_ = table_ - > GetOffset ( target , prefix_slice , prefix_hash , prefix_matc h ,
status_ = table_ - > GetOffset ( & decoder_ , target , prefix_slice , prefix_hash ,
& next_offset_ ) ;
prefix_match , & next_offset_ ) ;
if ( ! status_ . ok ( ) ) {
if ( ! status_ . ok ( ) ) {
offset_ = next_offset_ = table_ - > file_info_ . data_end_offset ;
offset_ = next_offset_ = table_ - > file_info_ . data_end_offset ;
return ;
return ;