From 9281a826f1f80b0e6d423f296ef5639aa48a331a Mon Sep 17 00:00:00 2001 From: kailiu Date: Thu, 2 Jan 2014 10:29:48 -0800 Subject: [PATCH] Hotfix the bug in table cache's GetSliceForFileNumber Forgot to fix this problem in master branch. Already fixed it in performance branch. --- db/table_cache.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/db/table_cache.cc b/db/table_cache.cc index 20eb68e4b..593352dde 100644 --- a/db/table_cache.cc +++ b/db/table_cache.cc @@ -29,9 +29,9 @@ static void UnrefEntry(void* arg1, void* arg2) { cache->Release(h); } -static Slice GetSliceForFileNumber(uint64_t file_number) { - return Slice(reinterpret_cast(&file_number), - sizeof(file_number)); +static Slice GetSliceForFileNumber(uint64_t* file_number) { + return Slice(reinterpret_cast(file_number), + sizeof(*file_number)); } TableCache::TableCache(const std::string& dbname, @@ -55,7 +55,7 @@ Status TableCache::FindTable(const EnvOptions& toptions, Cache::Handle** handle, bool* table_io, const bool no_io) { Status s; - Slice key = GetSliceForFileNumber(file_number); + Slice key = GetSliceForFileNumber(&file_number); *handle = cache_->Lookup(key); if (*handle == nullptr) { if (no_io) { // Dont do IO and return a not-found status @@ -168,7 +168,7 @@ bool TableCache::PrefixMayMatch(const ReadOptions& options, } void TableCache::Evict(uint64_t file_number) { - cache_->Erase(GetSliceForFileNumber(file_number)); + cache_->Erase(GetSliceForFileNumber(&file_number)); } } // namespace rocksdb