Hotfix the bug in table cache's GetSliceForFileNumber

Forgot to fix this problem in master branch. Already fixed it in performance branch.
main
kailiu 11 years ago
parent b60c14f6ee
commit 9281a826f1
  1. 10
      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<const char*>(&file_number),
sizeof(file_number));
static Slice GetSliceForFileNumber(uint64_t* file_number) {
return Slice(reinterpret_cast<const char*>(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

Loading…
Cancel
Save