From 19de6a7aadf333d4c3a6bb5a790e21cfa597448f Mon Sep 17 00:00:00 2001 From: sdong Date: Tue, 24 Jun 2014 17:52:30 -0700 Subject: [PATCH] Remove MemTableRep::GetIterator(const Slice& slice) Summary: It seems to me that when ever function MemTableRep::GetIterator(const Slice& slice) is used, we can use MemTableRep::GetDynamicPrefixIterator() instead. Just delete it to simplify the codes. Test Plan: make all check Reviewers: yhchiang, ljin Reviewed By: ljin Subscribers: xjin, dhruba, haobo, leveldb Differential Revision: https://reviews.facebook.net/D19281 --- db/memtable.cc | 8 ++++---- include/rocksdb/memtablerep.h | 7 ------- util/hash_cuckoo_rep.cc | 2 -- util/hash_linklist_rep.cc | 10 ---------- util/hash_skiplist_rep.cc | 10 ---------- util/skiplistrep.cc | 3 --- util/vectorrep.cc | 3 --- 7 files changed, 4 insertions(+), 39 deletions(-) diff --git a/db/memtable.cc b/db/memtable.cc index 1dd9dc0ca..f6d322d83 100644 --- a/db/memtable.cc +++ b/db/memtable.cc @@ -449,7 +449,7 @@ void MemTable::Update(SequenceNumber seq, Slice mem_key = lkey.memtable_key(); std::unique_ptr iter( - table_->GetIterator(lkey.user_key())); + table_->GetDynamicPrefixIterator()); iter->Seek(lkey.internal_key(), mem_key.data()); if (iter->Valid()) { @@ -508,7 +508,7 @@ bool MemTable::UpdateCallback(SequenceNumber seq, Slice memkey = lkey.memtable_key(); std::unique_ptr iter( - table_->GetIterator(lkey.user_key())); + table_->GetDynamicPrefixIterator()); iter->Seek(lkey.internal_key(), memkey.data()); if (iter->Valid()) { @@ -583,7 +583,7 @@ size_t MemTable::CountSuccessiveMergeEntries(const LookupKey& key) { // reps). By passing in the user key, we allow efficient iterator creation. // The iterator only needs to be ordered within the same user key. std::unique_ptr iter( - table_->GetIterator(key.user_key())); + table_->GetDynamicPrefixIterator()); iter->Seek(key.internal_key(), memkey.data()); size_t num_successive_merges = 0; @@ -610,7 +610,7 @@ size_t MemTable::CountSuccessiveMergeEntries(const LookupKey& key) { void MemTableRep::Get(const LookupKey& k, void* callback_args, bool (*callback_func)(void* arg, const char* entry)) { - auto iter = GetIterator(k.user_key()); + auto iter = GetDynamicPrefixIterator(); for (iter->Seek(k.internal_key(), k.memtable_key().data()); iter->Valid() && callback_func(callback_args, iter->key()); iter->Next()) { diff --git a/include/rocksdb/memtablerep.h b/include/rocksdb/memtablerep.h index 525c1565d..4dc8d7680 100644 --- a/include/rocksdb/memtablerep.h +++ b/include/rocksdb/memtablerep.h @@ -148,13 +148,6 @@ class MemTableRep { // all the states but those allocated in arena. virtual Iterator* GetIterator(Arena* arena = nullptr) = 0; - // Return an iterator over at least the keys with the specified user key. The - // iterator may also allow access to other keys, but doesn't have to. Default: - // GetIterator(). - virtual Iterator* GetIterator(const Slice& user_key) { - return GetIterator(nullptr); - } - // Return an iterator that has a special Seek semantics. The result of // a Seek might only include keys with the same prefix as the target key. // arena: If not null, the arena needs to be used to allocate the Iterator. diff --git a/util/hash_cuckoo_rep.cc b/util/hash_cuckoo_rep.cc index e6426a91c..a9a79a274 100644 --- a/util/hash_cuckoo_rep.cc +++ b/util/hash_cuckoo_rep.cc @@ -244,8 +244,6 @@ class HashCuckooRep : public MemTableRep { bool QuickInsert(const char* internal_key, const Slice& user_key, int bucket_ids[], const int initial_hash_id); - // Unhide default implementations of GetIterator - using MemTableRep::GetIterator; // Returns the pointer to the internal iterator to the buckets where buckets // are sorted according to the user specified KeyComparator. Note that // any insert after this function call may affect the sorted nature of diff --git a/util/hash_linklist_rep.cc b/util/hash_linklist_rep.cc index 2c546236d..22bb7ffb1 100644 --- a/util/hash_linklist_rep.cc +++ b/util/hash_linklist_rep.cc @@ -75,8 +75,6 @@ class HashLinkListRep : public MemTableRep { virtual MemTableRep::Iterator* GetIterator(Arena* arena = nullptr) override; - virtual MemTableRep::Iterator* GetIterator(const Slice& slice) override; - virtual MemTableRep::Iterator* GetDynamicPrefixIterator( Arena* arena = nullptr) override; @@ -466,14 +464,6 @@ MemTableRep::Iterator* HashLinkListRep::GetIterator(Arena* alloc_arena) { } } -MemTableRep::Iterator* HashLinkListRep::GetIterator(const Slice& slice) { - auto bucket = GetBucket(transform_->Transform(slice)); - if (bucket == nullptr) { - return new EmptyIterator(); - } - return new Iterator(this, bucket); -} - MemTableRep::Iterator* HashLinkListRep::GetDynamicPrefixIterator( Arena* alloc_arena) { if (alloc_arena == nullptr) { diff --git a/util/hash_skiplist_rep.cc b/util/hash_skiplist_rep.cc index baee12ad5..85d4e3356 100644 --- a/util/hash_skiplist_rep.cc +++ b/util/hash_skiplist_rep.cc @@ -40,8 +40,6 @@ class HashSkipListRep : public MemTableRep { virtual MemTableRep::Iterator* GetIterator(Arena* arena = nullptr) override; - virtual MemTableRep::Iterator* GetIterator(const Slice& slice) override; - virtual MemTableRep::Iterator* GetDynamicPrefixIterator( Arena* arena = nullptr) override; @@ -310,14 +308,6 @@ MemTableRep::Iterator* HashSkipListRep::GetIterator(Arena* arena) { } } -MemTableRep::Iterator* HashSkipListRep::GetIterator(const Slice& slice) { - auto bucket = GetBucket(transform_->Transform(slice)); - if (bucket == nullptr) { - return new EmptyIterator(); - } - return new Iterator(bucket, false); -} - MemTableRep::Iterator* HashSkipListRep::GetDynamicPrefixIterator(Arena* arena) { if (arena == nullptr) { return new DynamicIterator(*this); diff --git a/util/skiplistrep.cc b/util/skiplistrep.cc index 895343001..a3c940d0e 100644 --- a/util/skiplistrep.cc +++ b/util/skiplistrep.cc @@ -106,9 +106,6 @@ public: std::string tmp_; // For passing to EncodeKey }; - // Unhide default implementations of GetIterator - using MemTableRep::GetIterator; - virtual MemTableRep::Iterator* GetIterator(Arena* arena = nullptr) override { if (arena == nullptr) { return new SkipListRep::Iterator(&skip_list_); diff --git a/util/vectorrep.cc b/util/vectorrep.cc index 0fa10a50f..599076c30 100644 --- a/util/vectorrep.cc +++ b/util/vectorrep.cc @@ -91,9 +91,6 @@ class VectorRep : public MemTableRep { virtual void SeekToLast() override; }; - // Unhide default implementations of GetIterator() - using MemTableRep::GetIterator; - // Return an iterator over the keys in this representation. virtual MemTableRep::Iterator* GetIterator(Arena* arena) override;