MCPcopy Create free account
hub / github.com/apache/arrow / BitmapReader

Class BitmapReader

cpp/src/arrow/util/bitmap_reader.h:32–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30namespace internal {
31
32class BitmapReader {
33 public:
34 BitmapReader() = default;
35
36 BitmapReader(const uint8_t* bitmap, int64_t start_offset, int64_t length)
37 : bitmap_(bitmap), position_(0), length_(length) {
38 current_byte_ = 0;
39 byte_offset_ = start_offset / 8;
40 bit_offset_ = start_offset % 8;
41 if (length > 0) {
42 current_byte_ = bitmap[byte_offset_];
43 }
44 }
45
46 bool IsSet() const { return (current_byte_ & (1 << bit_offset_)) != 0; }
47
48 bool IsNotSet() const { return (current_byte_ & (1 << bit_offset_)) == 0; }
49
50 void Next() {
51 ++bit_offset_;
52 ++position_;
53 if (ARROW_PREDICT_FALSE(bit_offset_ == 8)) {
54 bit_offset_ = 0;
55 ++byte_offset_;
56 if (ARROW_PREDICT_TRUE(position_ < length_)) {
57 current_byte_ = bitmap_[byte_offset_];
58 }
59 }
60 }
61
62 int64_t position() const { return position_; }
63
64 int64_t length() const { return length_; }
65
66 private:
67 const uint8_t* bitmap_;
68 int64_t position_;
69 int64_t length_;
70
71 uint8_t current_byte_;
72 int64_t byte_offset_;
73 int64_t bit_offset_;
74};
75
76// XXX Cannot name it BitmapWordReader because the name is already used
77// in bitmap_ops.cc

Callers 5

TESTFunction · 0.70
TestAlignedMethod · 0.70
TestUnalignedMethod · 0.70
SimpleScalarArrayCompareFunction · 0.50

Calls

no outgoing calls

Tested by 5

TESTFunction · 0.56
TestAlignedMethod · 0.56
TestUnalignedMethod · 0.56
SimpleScalarArrayCompareFunction · 0.40