MCPcopy Create free account
hub / github.com/apache/kvrocks / ExpandBitmapSegment

Function ExpandBitmapSegment

src/types/redis_bitmap.cc:74–89  ·  view source on GitHub ↗

Resize the segment to makes its new length at least min_bytes, new bytes will be set to 0. min_bytes can not more than kBitmapSegmentBytes

Source from the content-addressed store, hash-verified

72// Resize the segment to makes its new length at least min_bytes, new bytes will be set to 0.
73// min_bytes can not more than kBitmapSegmentBytes
74void ExpandBitmapSegment(std::string *segment, size_t min_bytes) {
75 assert(min_bytes <= kBitmapSegmentBytes);
76
77 auto old_size = segment->size();
78 if (min_bytes > old_size) {
79 size_t new_size = 0;
80 if (min_bytes > old_size * 2) {
81 new_size = min_bytes;
82 } else if (old_size * 2 > kBitmapSegmentBytes) {
83 new_size = kBitmapSegmentBytes;
84 } else {
85 new_size = old_size * 2;
86 }
87 segment->resize(new_size, 0);
88 }
89}
90
91// Constructing sub-key index, see:
92// https://kvrocks.apache.org/community/data-structure-on-rocksdb#bitmap-sub-keys-values

Callers 1

SetBitMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected