選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

50 行
1.5 KiB

  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. #ifndef STORAGE_LEVELDB_DB_TABLE_CACHE_H_
  7. #define STORAGE_LEVELDB_DB_TABLE_CACHE_H_
  8. #include <string>
  9. #include <stdint.h>
  10. #include "db/dbformat.h"
  11. #include "leveldb/cache.h"
  12. #include "leveldb/table.h"
  13. #include "port/port.h"
  14. namespace leveldb {
  15. class Env;
  16. class TableCache {
  17. public:
  18. TableCache(const std::string& dbname, const Options* options, int entries);
  19. ~TableCache();
  20. // Return an iterator for the specified file number (the corresponding
  21. // file length must be exactly "file_size" bytes). If "tableptr" is
  22. // non-NULL, also sets "*tableptr" to point to the Table object
  23. // underlying the returned iterator, or NULL if no Table object underlies
  24. // the returned iterator. The returned "*tableptr" object is owned by
  25. // the cache and should not be deleted, and is valid for as long as the
  26. // returned iterator is live.
  27. Iterator* NewIterator(const ReadOptions& options,
  28. uint64_t file_number,
  29. uint64_t file_size,
  30. Table** tableptr = NULL);
  31. // Evict any entry for the specified file number
  32. void Evict(uint64_t file_number);
  33. private:
  34. Env* const env_;
  35. const std::string dbname_;
  36. const Options* options_;
  37. Cache* cache_;
  38. };
  39. }
  40. #endif // STORAGE_LEVELDB_DB_TABLE_CACHE_H_