|
|
@ -62,6 +62,8 @@ void AppendVarint64(IterKey* key, uint64_t v) { |
|
|
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const int kLoadConcurency = 128; |
|
|
|
|
|
|
|
|
|
|
|
TableCache::TableCache(const ImmutableCFOptions& ioptions, |
|
|
|
TableCache::TableCache(const ImmutableCFOptions& ioptions, |
|
|
|
const FileOptions& file_options, Cache* const cache, |
|
|
|
const FileOptions& file_options, Cache* const cache, |
|
|
|
BlockCacheTracer* const block_cache_tracer) |
|
|
|
BlockCacheTracer* const block_cache_tracer) |
|
|
@ -69,7 +71,8 @@ TableCache::TableCache(const ImmutableCFOptions& ioptions, |
|
|
|
file_options_(file_options), |
|
|
|
file_options_(file_options), |
|
|
|
cache_(cache), |
|
|
|
cache_(cache), |
|
|
|
immortal_tables_(false), |
|
|
|
immortal_tables_(false), |
|
|
|
block_cache_tracer_(block_cache_tracer) { |
|
|
|
block_cache_tracer_(block_cache_tracer), |
|
|
|
|
|
|
|
loader_mutex_(kLoadConcurency, GetSliceNPHash64) { |
|
|
|
if (ioptions_.row_cache) { |
|
|
|
if (ioptions_.row_cache) { |
|
|
|
// If the same cache is shared by multiple instances, we need to
|
|
|
|
// If the same cache is shared by multiple instances, we need to
|
|
|
|
// disambiguate its entries.
|
|
|
|
// disambiguate its entries.
|
|
|
@ -155,6 +158,13 @@ Status TableCache::FindTable(const FileOptions& file_options, |
|
|
|
if (no_io) { // Don't do IO and return a not-found status
|
|
|
|
if (no_io) { // Don't do IO and return a not-found status
|
|
|
|
return Status::Incomplete("Table not found in table_cache, no_io is set"); |
|
|
|
return Status::Incomplete("Table not found in table_cache, no_io is set"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
MutexLock load_lock(loader_mutex_.get(key)); |
|
|
|
|
|
|
|
// We check the cache again under loading mutex
|
|
|
|
|
|
|
|
*handle = cache_->Lookup(key); |
|
|
|
|
|
|
|
if (*handle != nullptr) { |
|
|
|
|
|
|
|
return s; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<TableReader> table_reader; |
|
|
|
std::unique_ptr<TableReader> table_reader; |
|
|
|
s = GetTableReader(file_options, internal_comparator, fd, |
|
|
|
s = GetTableReader(file_options, internal_comparator, fd, |
|
|
|
false /* sequential mode */, record_read_stats, |
|
|
|
false /* sequential mode */, record_read_stats, |
|
|
|