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

Function CheckBinaryBitBlockOp

cpp/src/arrow/util/bit_block_counter_test.cc:209–245  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207
208template <class Op, typename NextWordFunc>
209void CheckBinaryBitBlockOp(NextWordFunc&& get_next_word) {
210 const int64_t nbytes = 1024;
211 auto left = *AllocateBuffer(nbytes);
212 auto right = *AllocateBuffer(nbytes);
213 random_bytes(nbytes, 0, left->mutable_data());
214 random_bytes(nbytes, 0, right->mutable_data());
215
216 auto CheckWithOffsets = [&](int left_offset, int right_offset) {
217 int64_t overlap_length = nbytes * 8 - std::max(left_offset, right_offset);
218 BinaryBitBlockCounter counter(left->data(), left_offset, right->data(), right_offset,
219 overlap_length);
220 int64_t position = 0;
221 do {
222 BitBlockCount block = get_next_word(&counter);
223 int expected_popcount = 0;
224 for (int j = 0; j < block.length; ++j) {
225 expected_popcount += static_cast<int>(
226 Op::Call(bit_util::GetBit(left->data(), position + left_offset + j),
227 bit_util::GetBit(right->data(), position + right_offset + j)));
228 }
229 ASSERT_EQ(block.popcount, expected_popcount);
230 position += block.length;
231 } while (position < overlap_length);
232 // We made it through all the data
233 ASSERT_EQ(position, overlap_length);
234
235 BitBlockCount block = get_next_word(&counter);
236 ASSERT_EQ(block.length, 0);
237 ASSERT_EQ(block.popcount, 0);
238 };
239
240 for (int left_i = 0; left_i < 8; ++left_i) {
241 for (int right_i = 0; right_i < 8; ++right_i) {
242 CheckWithOffsets(left_i, right_i);
243 }
244 }
245}
246
247TEST(TestBinaryBitBlockCounter, NextAndWord) {
248 CheckBinaryBitBlockOp<detail::BitBlockAnd>(

Callers

nothing calls this directly

Calls 6

CallClass · 0.85
GetBitFunction · 0.70
AllocateBufferFunction · 0.50
random_bytesFunction · 0.50
mutable_dataMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected