50 &footer_input, footer_space);
51 if (!s.
ok())
return s;
55 if (!s.
ok())
return s;
59 Block* index_block = NULL;
63 index_block =
new Block(contents);
78 *table =
new Table(rep);
79 (*table)->ReadMeta(footer);
81 if (index_block)
delete index_block;
103 std::string key =
"filter.";
114 Slice v = filter_handle_value;
137 static void DeleteBlock(
void*
arg,
void* ignored) {
138 delete reinterpret_cast<Block*
>(
arg);
141 static void DeleteCachedBlock(
const Slice& key,
void*
value) {
142 Block* block =
reinterpret_cast<Block*
>(
value);
146 static void ReleaseBlock(
void*
arg,
void* h) {
147 Cache* cache =
reinterpret_cast<Cache*
>(
arg);
148 Cache::Handle* handle =
reinterpret_cast<Cache::Handle*
>(h);
149 cache->Release(handle);
156 const Slice& index_value) {
163 Slice input = index_value;
170 if (block_cache != NULL) {
171 char cache_key_buffer[16];
174 Slice key(cache_key_buffer,
sizeof(cache_key_buffer));
175 cache_handle = block_cache->
Lookup(key);
176 if (cache_handle != NULL) {
177 block =
reinterpret_cast<Block*
>(block_cache->
Value(cache_handle));
181 block =
new Block(contents);
183 cache_handle = block_cache->
Insert(
184 key, block, block->
size(), &DeleteCachedBlock);
191 block =
new Block(contents);
199 if (cache_handle == NULL) {
218 void (*saver)(
void*,
const Slice&,
const Slice&)) {
222 if (iiter->
Valid()) {
226 if (filter != NULL &&
233 if (block_iter->
Valid()) {
234 (*saver)(
arg, block_iter->
key(), block_iter->
value());
251 index_iter->
Seek(key);
253 if (index_iter->
Valid()) {
virtual Status Read(uint64_t offset, size_t n, Slice *result, char *scratch) const =0
BlockHandle metaindex_handle
virtual void * Value(Handle *handle)=0
void ReadFilter(const Slice &filter_handle_value)
uint64_t ApproximateOffsetOf(const Slice &key) const
void ReadMeta(const Footer &footer)
const char * data() const
Status DecodeFrom(Slice *input)
bool KeyMayMatch(uint64_t block_offset, const Slice &key)
virtual Handle * Insert(const Slice &key, void *value, size_t charge, void(*deleter)(const Slice &key, void *value))=0
FilterBlockReader * filter
Status InternalGet(const ReadOptions &, const Slice &key, void *arg, void(*handle_result)(void *arg, const Slice &k, const Slice &v))
virtual Status status() const =0
virtual Slice value() const =0
virtual const char * Name() const =0
Iterator * NewIterator(const ReadOptions &) const
static Status InvalidArgument(const Slice &msg, const Slice &msg2=Slice())
Iterator * NewIterator(const Comparator *comparator)
virtual Handle * Lookup(const Slice &key)=0
void EncodeFixed64(char *buf, uint64_t value)
unsigned long long uint64_t
Iterator * NewErrorIterator(const Status &status)
virtual void Seek(const Slice &target)=0
void RegisterCleanup(CleanupFunction function, void *arg1, void *arg2)
const FilterPolicy * filter_policy
const Comparator * BytewiseComparator()
Iterator * NewTwoLevelIterator(Iterator *index_iter, BlockFunction block_function, void *arg, const ReadOptions &options)
virtual bool Valid() const =0
static Status Open(const Options &options, RandomAccessFile *file, uint64_t file_size, Table **table)
virtual Slice key() const =0
virtual uint64_t NewId()=0
static Iterator * BlockReader(void *, const ReadOptions &, const Slice &)
Status ReadBlock(RandomAccessFile *file, const ReadOptions &options, const BlockHandle &handle, BlockContents *result)
const Comparator * comparator