GCC Code Coverage Report


Directory: src/
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 20.5% 8 / 0 / 39
Functions: 26.7% 4 / 0 / 15
Branches: 5.6% 2 / 0 / 36

storage/index/index.h
Line Branch Exec Source
1 #pragma once
2 #include <atomic>
3 #include <boost/coroutine2/all.hpp>
4 #include <cstddef>
5 #include <glog/logging.h>
6 #include "base/array.h"
7 #include "base/log.h"
8 #include "utils/pair.h"
9 #include "storage/kv_engine/base_kv.h"
10
11 using boost::coroutines2::coroutine;
12
13 class Index {
14 public:
15 1396 virtual ~Index() { std::cout << "exit Index" << std::endl; }
16 1396 explicit Index(const BaseKVConfig& config){};
17
18 201374 virtual void Get(Key_t key, Value_t& pointer) {
19 201374 Get(key, pointer, CurrentTid());
20 201374 }
21 virtual void Get(Key_t key, Value_t& pointer, unsigned tid) = 0;
22 virtual void GetAsync(coroutine<void>::push_type& sink,
23 int index,
24 Key_t key,
25 Value_t& pointer) {
26 Get(sink, index, key, pointer, CurrentTid());
27 }
28 virtual void
29 Get(coroutine<void>::push_type& sink,
30 int index,
31 Key_t key,
32 Value_t& pointer,
33 unsigned tid) {
34 LOG(FATAL) << "not implemented";
35 }
36 virtual Value_t Put(Key_t key, Value_t pointer) {
37 return Put(key, pointer, CurrentTid());
38 }
39 virtual Value_t Put(Key_t key, Value_t pointer, unsigned tid) = 0;
40 virtual Value_t
41 Put(coroutine<void>::push_type& sink,
42 int index,
43 Key_t key,
44 Value_t pointer,
45 unsigned tid) {
46 LOG(FATAL) << "not implemented";
47 return NONE;
48 }
49 virtual void BatchPut(base::ConstArray<Key_t> keys, Value_t* pointers) {
50 BatchPut(keys, pointers, CurrentTid());
51 }
52 virtual void
53 BatchPut(base::ConstArray<Key_t> keys, Value_t* pointers, unsigned tid) = 0;
54 virtual void BatchGet(base::ConstArray<Key_t> keys, Value_t* pointers) {
55 BatchGet(keys, pointers, CurrentTid());
56 }
57 virtual void
58 BatchGet(base::ConstArray<Key_t> keys, Value_t* pointers, unsigned tid) = 0;
59 virtual bool Delete(Key_t& key) = 0;
60 virtual double Utilization() { LOG(FATAL) << "not implemented"; }
61 virtual size_t Capacity() { LOG(FATAL) << "not implemented"; }
62 virtual void BulkLoad(base::ConstArray<uint64_t> keys, const void* value) {
63 LOG(FATAL) << "not implemented";
64 };
65 virtual void LoadFakeData(int64_t key_capacity, int value_size) {
66 std::vector<uint64_t> keys;
67 uint64_t* values =
68 new uint64_t[value_size / sizeof(uint64_t) * key_capacity];
69 keys.reserve(key_capacity);
70 for (int64_t i = 0; i < key_capacity; i++) {
71 keys.push_back(i);
72 *(values + i) = i;
73 uint64_t ptr_value = *reinterpret_cast<const uint64_t*>(values + i);
74 }
75 this->BulkLoad(base::ConstArray<uint64_t>(keys), values);
76 delete[] values;
77 };
78 virtual void DebugInfo() const {}
79
80 protected:
81 201374 static unsigned CurrentTid() {
82 static std::atomic<unsigned> counter{0};
83
2/2
✓ Branch 0 taken 488 times.
✓ Branch 1 taken 200886 times.
201862 thread_local unsigned tid = counter.fetch_add(1, std::memory_order_relaxed);
84 201374 return tid;
85 }
86 };
87
88 static constexpr Value_t kValueHandleNone = NONE;
89