MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / FindTable

Method FindTable

src/leveldb/db/table_cache.cc:45–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43}
44
45Status TableCache::FindTable(uint64_t file_number, uint64_t file_size,
46 Cache::Handle** handle) {
47 Status s;
48 char buf[sizeof(file_number)];
49 EncodeFixed64(buf, file_number);
50 Slice key(buf, sizeof(buf));
51 *handle = cache_->Lookup(key);
52 if (*handle == NULL) {
53 std::string fname = TableFileName(dbname_, file_number);
54 RandomAccessFile* file = NULL;
55 Table* table = NULL;
56 s = env_->NewRandomAccessFile(fname, &file);
57 if (!s.ok()) {
58 std::string old_fname = SSTTableFileName(dbname_, file_number);
59 if (env_->NewRandomAccessFile(old_fname, &file).ok()) {
60 s = Status::OK();
61 }
62 }
63 if (s.ok()) {
64 s = Table::Open(*options_, file, file_size, &table);
65 }
66
67 if (!s.ok()) {
68 assert(table == NULL);
69 delete file;
70 // We do not cache error results so that if the error is transient,
71 // or somebody repairs the file, we recover automatically.
72 } else {
73 TableAndFile* tf = new TableAndFile;
74 tf->file = file;
75 tf->table = table;
76 *handle = cache_->Insert(key, tf, 1, &DeleteEntry);
77 }
78 }
79 return s;
80}
81
82Iterator* TableCache::NewIterator(const ReadOptions& options,
83 uint64_t file_number,

Callers

nothing calls this directly

Calls 7

EncodeFixed64Function · 0.85
TableFileNameFunction · 0.85
SSTTableFileNameFunction · 0.85
LookupMethod · 0.45
NewRandomAccessFileMethod · 0.45
okMethod · 0.45
InsertMethod · 0.45

Tested by

no test coverage detected