168 Cache* block_cache = table->rep_->options.block_cache;
170 Cache::Handle* cache_handle = NULL;
173 Slice input = index_value;
174 Status s = handle.DecodeFrom(&input);
179 BlockContents contents;
180 if (block_cache != NULL) {
181 char cache_key_buffer[16];
184 Slice key(cache_key_buffer,
sizeof(cache_key_buffer));
185 cache_handle = block_cache->Lookup(key);
186 if (cache_handle != NULL) {
187 block =
reinterpret_cast<Block*
>(block_cache->Value(cache_handle));
189 s =
ReadBlock(table->rep_->file, options, handle, &contents);
191 block =
new Block(contents);
192 if (contents.cachable && options.fill_cache) {
193 cache_handle = block_cache->Insert(
199 s =
ReadBlock(table->rep_->file, options, handle, &contents);
201 block =
new Block(contents);
208 iter = block->NewIterator(table->rep_->options.comparator);
209 if (cache_handle == NULL) {
212 iter->RegisterCleanup(&
ReleaseBlock, block_cache, cache_handle);
void EncodeFixed64(char *buf, uint64_t value)
static void ReleaseBlock(void *arg, void *h)
Iterator * NewErrorIterator(const Status &status)
static void DeleteCachedBlock(const Slice &key, void *value)
static void DeleteBlock(void *arg, void *ignored)
Status ReadBlock(RandomAccessFile *file, const ReadOptions &options, const BlockHandle &handle, BlockContents *result)