// For hash based index, return true if prefix_extractor and
// prefix_extractor_block mismatch, false otherwise. This flag will be used
// as total_order_seek via NewIndexIterator
-bool PrefixExtractorChanged(std::string prefix_extractor_block,
- const SliceTransform* prefix_extractor) {
+bool PrefixExtractorChanged(
+ std::shared_ptr<const TableProperties> table_properties,
+ const SliceTransform* prefix_extractor) {
// BlockBasedTableOptions::kHashSearch requires prefix_extractor to be set.
// 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
- if (prefix_extractor == nullptr || prefix_extractor_block.empty()) {
+ if (prefix_extractor == nullptr || table_properties == nullptr ||
+ table_properties->prefix_extractor_name.empty()) {
return true;
}
+
// 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;
} else {
return false;
bool prefix_extractor_changed = false;
// check prefix_extractor match only if hash based index is used
if (rep->index_type == BlockBasedTableOptions::kHashSearch) {
- prefix_extractor_changed = PrefixExtractorChanged(
- rep->table_properties->prefix_extractor_name, prefix_extractor);
+ prefix_extractor_changed =
+ PrefixExtractorChanged(rep->table_properties, prefix_extractor);
}
unique_ptr<InternalIterator> iter(new_table->NewIndexIterator(
ReadOptions(), prefix_extractor_changed, nullptr, &index_entry));
InternalIterator* BlockBasedTable::NewIterator(
const ReadOptions& read_options, const SliceTransform* prefix_extractor,
Arena* arena, bool skip_filters) {
- bool prefix_extractor_changed = PrefixExtractorChanged(
- rep_->table_properties->prefix_extractor_name, prefix_extractor);
+ bool prefix_extractor_changed =
+ PrefixExtractorChanged(rep_->table_properties, prefix_extractor);
if (arena == nullptr) {
return new BlockBasedTableIterator(
this, read_options, rep_->internal_comparator,
// BlockPrefixIndex. Only do this check when index_type is kHashSearch.
bool prefix_extractor_changed = false;
if (rep_->index_type == BlockBasedTableOptions::kHashSearch) {
- prefix_extractor_changed = PrefixExtractorChanged(
- rep_->table_properties->prefix_extractor_name, prefix_extractor);
+ prefix_extractor_changed =
+ PrefixExtractorChanged(rep_->table_properties, prefix_extractor);
}
auto iiter = NewIndexIterator(read_options, prefix_extractor_changed,
&iiter_on_stack, /* index_entry */ nullptr,