1 // Copyright (c) 2011 The LevelDB Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. See the AUTHORS file for names of contributors.
5 // Thread-safe (provides internal synchronization)
7 #ifndef STORAGE_LEVELDB_DB_TABLE_CACHE_H_
8 #define STORAGE_LEVELDB_DB_TABLE_CACHE_H_
12 #include "db/dbformat.h"
13 #include "leveldb/cache.h"
14 #include "leveldb/table.h"
15 #include "port/port.h"
23 TableCache(const std::string
& dbname
, const Options
* options
, int entries
);
26 // Return an iterator for the specified file number (the corresponding
27 // file length must be exactly "file_size" bytes). If "tableptr" is
28 // non-NULL, also sets "*tableptr" to point to the Table object
29 // underlying the returned iterator, or NULL if no Table object underlies
30 // the returned iterator. The returned "*tableptr" object is owned by
31 // the cache and should not be deleted, and is valid for as long as the
32 // returned iterator is live.
33 Iterator
* NewIterator(const ReadOptions
& options
,
36 Table
** tableptr
= NULL
);
38 // If a seek to internal key "k" in specified file finds an entry,
39 // call (*handle_result)(arg, found_key, found_value).
40 Status
Get(const ReadOptions
& options
,
45 void (*handle_result
)(void*, const Slice
&, const Slice
&));
47 // Evict any entry for the specified file number
48 void Evict(uint64_t file_number
);
52 const std::string dbname_
;
53 const Options
* options_
;
56 Status
FindTable(uint64_t file_number
, uint64_t file_size
, Cache::Handle
**);
59 } // namespace leveldb
61 #endif // STORAGE_LEVELDB_DB_TABLE_CACHE_H_