| 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) { |
nothing calls this directly
no test coverage detected