MCPcopy Create free account
hub / github.com/ElementsProject/elements / NewRandomAccessFile

Method NewRandomAccessFile

src/leveldb/db/db_test.cc:206–229  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

204 }
205
206 Status NewRandomAccessFile(const std::string& f, RandomAccessFile** r) {
207 class CountingFile : public RandomAccessFile {
208 private:
209 RandomAccessFile* target_;
210 AtomicCounter* counter_;
211
212 public:
213 CountingFile(RandomAccessFile* target, AtomicCounter* counter)
214 : target_(target), counter_(counter) {}
215 ~CountingFile() override { delete target_; }
216 Status Read(uint64_t offset, size_t n, Slice* result,
217 char* scratch) const override {
218 counter_->Increment();
219 return target_->Read(offset, n, result, scratch);
220 }
221 std::string GetName() const override { return ""; }
222 };
223
224 Status s = target()->NewRandomAccessFile(f, r);
225 if (s.ok() && count_random_reads_) {
226 *r = new CountingFile(*r, &random_read_counter_);
227 }
228 return s;
229 }
230};
231
232class DBTest {

Callers 3

NewRandomAccessFileFunction · 0.45
FindTableMethod · 0.45
DumpTableFunction · 0.45

Calls 1

targetFunction · 0.85

Tested by

no test coverage detected