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

Function getLogRanges

fdbclient/BackupAgentBase.actor.cpp:169–194  ·  view source on GitHub ↗

Transaction log data is stored by the FoundationDB core in the "backupLogKeys" (i.e., \xff\x02/blog/) keyspace in a funny order for performance reasons. Returns the ranges of keys that contain the data for the given range of versions. assert CLIENT_KNOBS->LOG_RANGE_BLOCK_SIZE % blocksize = 0. Otherwise calculation of hash will be incorrect

Source from the content-addressed store, hash-verified

167// of versions.
168// assert CLIENT_KNOBS->LOG_RANGE_BLOCK_SIZE % blocksize = 0. Otherwise calculation of hash will be incorrect
169Standalone<VectorRef<KeyRangeRef>> getLogRanges(Version beginVersion,
170 Version endVersion,
171 Key destUidValue,
172 int blockSize) {
173 Standalone<VectorRef<KeyRangeRef>> ret;
174
175 Key baLogRangePrefix = destUidValue.withPrefix(backupLogKeys.begin);
176
177 //TraceEvent("GetLogRanges").detail("DestUidValue", destUidValue).detail("Prefix", baLogRangePrefix);
178
179 for (int64_t vblock = beginVersion / blockSize; vblock < (endVersion + blockSize - 1) / blockSize; ++vblock) {
180 int64_t tb = vblock * blockSize / CLIENT_KNOBS->LOG_RANGE_BLOCK_SIZE;
181 uint64_t bv = bigEndian64(std::max(beginVersion, vblock * blockSize));
182 uint64_t ev = bigEndian64(std::min(endVersion, (vblock + 1) * blockSize));
183 uint32_t data = tb & 0xffffffff;
184 uint8_t hash = (uint8_t)hashlittle(&data, sizeof(uint32_t), 0);
185
186 Key vblockPrefix = StringRef(&hash, sizeof(uint8_t)).withPrefix(baLogRangePrefix);
187
188 ret.push_back_deep(ret.arena(),
189 KeyRangeRef(StringRef((uint8_t*)&bv, sizeof(uint64_t)).withPrefix(vblockPrefix),
190 StringRef((uint8_t*)&ev, sizeof(uint64_t)).withPrefix(vblockPrefix)));
191 }
192
193 return ret;
194}
195
196Standalone<VectorRef<KeyRangeRef>> getApplyRanges(Version beginVersion, Version endVersion, Key backupUid) {
197 Standalone<VectorRef<KeyRangeRef>> ret;

Callers 3

Future<Void> _executeFunction · 0.85

Calls 5

hashlittleFunction · 0.85
StringRefClass · 0.50
KeyRangeRefClass · 0.50
withPrefixMethod · 0.45
push_back_deepMethod · 0.45

Tested by

no test coverage detected