From 60422f1676799704e97c440cabb83c1a1de80936 Mon Sep 17 00:00:00 2001 From: "ehds@qq.com" Date: Tue, 15 Mar 2022 10:02:33 -0700 Subject: [PATCH] Replace GetUserKey with ExtractUserKey (#9664) Summary: Replace `GetUserKey` with `ExtractUserKey` Pull Request resolved: https://github.com/facebook/rocksdb/pull/9664 Reviewed By: jay-zhuang Differential Revision: D34673571 Pulled By: ajkr fbshipit-source-id: 5acf7d0d1a45efce0ccbe505991acf76c9cdc461 --- table/plain/plain_table_builder.h | 6 +----- table/plain/plain_table_reader.cc | 2 +- table/plain/plain_table_reader.h | 6 +----- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/table/plain/plain_table_builder.h b/table/plain/plain_table_builder.h index d281fdb16..562e6392c 100644 --- a/table/plain/plain_table_builder.h +++ b/table/plain/plain_table_builder.h @@ -122,17 +122,13 @@ class PlainTableBuilder: public TableBuilder { Slice GetPrefix(const Slice& target) const { assert(target.size() >= 8); // target is internal key - return GetPrefixFromUserKey(GetUserKey(target)); + return GetPrefixFromUserKey(ExtractUserKey(target)); } Slice GetPrefix(const ParsedInternalKey& target) const { return GetPrefixFromUserKey(target.user_key); } - Slice GetUserKey(const Slice& key) const { - return Slice(key.data(), key.size() - 8); - } - Slice GetPrefixFromUserKey(const Slice& user_key) const { if (!IsTotalOrderMode()) { return prefix_extractor_->Transform(user_key); diff --git a/table/plain/plain_table_reader.cc b/table/plain/plain_table_reader.cc index 67b16e075..25f2ba95b 100644 --- a/table/plain/plain_table_reader.cc +++ b/table/plain/plain_table_reader.cc @@ -563,7 +563,7 @@ Status PlainTableReader::Get(const ReadOptions& /*ro*/, const Slice& target, Status::InvalidArgument("Get() is not allowed in full scan mode."); } // Match whole user key for bloom filter check. - if (!MatchBloom(GetSliceHash(GetUserKey(target)))) { + if (!MatchBloom(GetSliceHash(ExtractUserKey(target)))) { return Status::OK(); } // in total order mode, there is only one bucket 0, and we always use empty diff --git a/table/plain/plain_table_reader.h b/table/plain/plain_table_reader.h index 8e1995590..168beac48 100644 --- a/table/plain/plain_table_reader.h +++ b/table/plain/plain_table_reader.h @@ -179,17 +179,13 @@ class PlainTableReader: public TableReader { Slice GetPrefix(const Slice& target) const { assert(target.size() >= 8); // target is internal key - return GetPrefixFromUserKey(GetUserKey(target)); + return GetPrefixFromUserKey(ExtractUserKey(target)); } Slice GetPrefix(const ParsedInternalKey& target) const { return GetPrefixFromUserKey(target.user_key); } - Slice GetUserKey(const Slice& key) const { - return Slice(key.data(), key.size() - 8); - } - Slice GetPrefixFromUserKey(const Slice& user_key) const { if (!IsTotalOrderMode()) { return prefix_extractor_->Transform(user_key);