MCPcopy Create free account
hub / github.com/ceph/ceph / insert_range

Method insert_range

src/common/bitset_set.h:199–219  ·  view source on GitHub ↗

Efficiently insert a range of values. When N is small, this is * essentially an O(1) algorithm, although technically it is O(N) */

Source from the content-addressed store, hash-verified

197 * essentially an O(1) algorithm, although technically it is O(N)
198 */
199 void insert_range(const KeyT start, int length) {
200 unsigned start_word = int(start) / bits_per_uint64_t;
201 // This is not an off-by-one error. Conventionally this would have length
202 // - 1, but the logic below is simpler with it as follows.
203 unsigned end_word = (int(start) + length) / bits_per_uint64_t;
204 ceph_assert(end_word < word_count + 1);
205
206 if (start_word == end_word) {
207 words[start_word] |=
208 ((1ULL << length) - 1) << (int(start) % bits_per_uint64_t);
209 } else {
210 words[start_word] |= -1ULL << (int(start) % bits_per_uint64_t);
211 while (++start_word < end_word) {
212 words[start_word] = -1ULL;
213 }
214 if (end_word < word_count) {
215 words[end_word] |=
216 (1ULL << ((int(start) + length) % bits_per_uint64_t)) - 1;
217 }
218 }
219 }
220
221 /** Efficiently erase a range of values. When N is small, this is
222 * essentially an O(1) algorithm, although technically it is O(N)

Callers 13

decode_chunksMethod · 0.80
decode_chunksMethod · 0.80
TESTFunction · 0.80
TESTFunction · 0.80
TESTFunction · 0.80
TESTFunction · 0.80
TESTFunction · 0.80
test_insert_rangeFunction · 0.80
test_erase_rangeFunction · 0.80
TESTFunction · 0.80
all_shards_writtenMethod · 0.80
calc_all_shardsMethod · 0.80

Calls

no outgoing calls

Tested by 8

TESTFunction · 0.64
TESTFunction · 0.64
TESTFunction · 0.64
TESTFunction · 0.64
TESTFunction · 0.64
test_insert_rangeFunction · 0.64
test_erase_rangeFunction · 0.64
TESTFunction · 0.64