MCPcopy Create free account
hub / github.com/apple/foundationdb / read

Method read

fdbclient/ReadYourWrites.actor.cpp:96–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94
95 ACTOR template <class Iter>
96 static Future<Optional<Value>> read(ReadYourWritesTransaction* ryw, GetValueReq read, Iter* it) {
97 // This overload is required to provide postcondition: it->extractWriteMapIterator().segmentContains(read.key)
98
99 if (ryw->options.bypassUnreadable) {
100 it->bypassUnreadableProtection();
101 }
102 it->skip(read.key);
103 state bool dependent = it->is_dependent();
104 if (it->is_kv()) {
105 const KeyValueRef* result = it->kv(ryw->arena);
106 if (result != nullptr) {
107 return result->value;
108 } else {
109 return Optional<Value>();
110 }
111 } else if (it->is_empty_range()) {
112 return Optional<Value>();
113 } else {
114 Optional<Value> res = wait(ryw->tr.get(read.key, Snapshot::True));
115 KeyRef k(ryw->arena, read.key);
116
117 if (res.present()) {
118 if (ryw->cache.insert(k, res.get()))
119 ryw->arena.dependsOn(res.get().arena());
120 if (!dependent)
121 return res;
122 } else {
123 ryw->cache.insert(k, Optional<ValueRef>());
124 if (!dependent)
125 return Optional<Value>();
126 }
127
128 // There was a dependent write at the key, so we need to lookup the iterator again
129 it->skip(k);
130
131 ASSERT(it->is_kv());
132 const KeyValueRef* result = it->kv(ryw->arena);
133 if (result != nullptr) {
134 return result->value;
135 } else {
136 return Optional<Value>();
137 }
138 }
139 }
140
141 ACTOR template <class Iter>
142 static Future<Key> read(ReadYourWritesTransaction* ryw, GetKeyReq read, Iter* it) {

Callers

nothing calls this directly

Calls 14

dependsOnMethod · 0.80
getMaxReadKeyMethod · 0.80
getMethod · 0.65
firstGreaterOrEqualFunction · 0.50
GetRangeLimitsClass · 0.50
skipMethod · 0.45
is_dependentMethod · 0.45
is_kvMethod · 0.45
kvMethod · 0.45
is_empty_rangeMethod · 0.45
presentMethod · 0.45

Tested by

no test coverage detected