MCPcopy Create free account
hub / github.com/apache/impala / TestBitArrayValues

Function TestBitArrayValues

be/src/kudu/util/rle-test.cc:125–145  ·  view source on GitHub ↗

Writes 'num_vals' values with width 'bit_width' and reads them back.

Source from the content-addressed store, hash-verified

123
124// Writes 'num_vals' values with width 'bit_width' and reads them back.
125void TestBitArrayValues(int bit_width, int num_vals) {
126 const int kTestLen = BitUtil::Ceil<3>(bit_width * num_vals);
127 const uint64_t mod = bit_width == 64? 1 : 1LL << bit_width;
128
129 faststring buffer(kTestLen);
130 BitWriter writer(&buffer);
131 for (int i = 0; i < num_vals; ++i) {
132 writer.PutValue(i % mod, bit_width);
133 }
134 writer.Flush();
135 EXPECT_EQ(writer.bytes_written(), kTestLen);
136
137 BitReader reader(buffer.data(), kTestLen);
138 for (int i = 0; i < num_vals; ++i) {
139 int64_t val = 0;
140 bool result = reader.GetValue(bit_width, &val);
141 EXPECT_TRUE(result);
142 EXPECT_EQ(val, i % mod);
143 }
144 EXPECT_EQ(reader.bytes_left(), 0);
145}
146
147TEST(BitArray, TestValues) {
148 for (int width = 1; width <= kMaxWidth; ++width) {

Callers 1

TESTFunction · 0.70

Calls 6

PutValueMethod · 0.45
FlushMethod · 0.45
bytes_writtenMethod · 0.45
dataMethod · 0.45
GetValueMethod · 0.45
bytes_leftMethod · 0.45

Tested by

no test coverage detected