Feathercoin  0.5.0
P2P Digital Currency
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
table_cache.h
Go to the documentation of this file.
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.
4 //
5 // Thread-safe (provides internal synchronization)
6 
7 #ifndef STORAGE_LEVELDB_DB_TABLE_CACHE_H_
8 #define STORAGE_LEVELDB_DB_TABLE_CACHE_H_
9 
10 #include <string>
11 #include <stdint.h>
12 #include "db/dbformat.h"
13 #include "leveldb/cache.h"
14 #include "leveldb/table.h"
15 #include "port/port.h"
16 
17 namespace leveldb {
18 
19 class Env;
20 
21 class TableCache {
22  public:
23  TableCache(const std::string& dbname, const Options* options, int entries);
24  ~TableCache();
25 
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,
34  uint64_t file_number,
35  uint64_t file_size,
36  Table** tableptr = NULL);
37 
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,
41  uint64_t file_number,
42  uint64_t file_size,
43  const Slice& k,
44  void* arg,
45  void (*handle_result)(void*, const Slice&, const Slice&));
46 
47  // Evict any entry for the specified file number
48  void Evict(uint64_t file_number);
49 
50  private:
51  Env* const env_;
52  const std::string dbname_;
53  const Options* options_;
55 
56  Status FindTable(uint64_t file_number, uint64_t file_size, Cache::Handle**);
57 };
58 
59 } // namespace leveldb
60 
61 #endif // STORAGE_LEVELDB_DB_TABLE_CACHE_H_
void Evict(uint64_t file_number)
Definition: table_cache.cc:115
const std::string dbname_
Definition: table_cache.h:52
Status FindTable(uint64_t file_number, uint64_t file_size, Cache::Handle **)
Definition: table_cache.cc:45
const Options * options_
Definition: table_cache.h:53
unsigned long long uint64_t
Definition: stdint.h:22
Status Get(const ReadOptions &options, uint64_t file_number, uint64_t file_size, const Slice &k, void *arg, void(*handle_result)(void *, const Slice &, const Slice &))
Definition: table_cache.cc:99
Iterator * NewIterator(const ReadOptions &options, uint64_t file_number, uint64_t file_size, Table **tableptr=NULL)
Definition: table_cache.cc:76
void * arg
Definition: env_posix.cc:716
TableCache(const std::string &dbname, const Options *options, int entries)
Definition: table_cache.cc:32