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

Function RandomUnpackAndDecodeTest

be/src/util/bit-packing-test.cc:264–305  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

262// bit-packed literal run (no RLE).
263template <typename UINT_T>
264void RandomUnpackAndDecodeTest() {
265 constexpr int MAX_BITWIDTH = BitPacking::MAX_BITWIDTH;
266 const int max_bit_width = std::min<int>({MAX_BITWIDTH, sizeof(UINT_T) * 8,
267 sizeof(uint32_t) * 8 /* dictionary indices are 32 bit values */});
268
269 const std::vector<int> lengths = GetLengths();
270
271 for (int bit_width = 0; bit_width <= max_bit_width; ++bit_width) {
272 const UINT_T max_dict_size = bit_width == sizeof(UINT_T) * 8
273 ? std::numeric_limits<UINT_T>::max() : (1UL << bit_width);
274
275 const std::vector<UINT_T> input = GenerateRandomInput<UINT_T>(NUM_IN_VALUES, 0,
276 max_dict_size - 1 /* inclusive range */);
277
278 for (int length : lengths) {
279 const std::vector<UINT_T> in_data(input.begin(), input.begin() + length);
280
281 std::pair<std::vector<UINT_T>, std::vector<uint8_t>> dict_and_data
282 = DictEncode(in_data, bit_width);
283 std::vector<UINT_T>& dict = dict_and_data.first;
284 const std::vector<uint8_t>& data = dict_and_data.second;
285
286 const std::vector<int> strides = {sizeof(UINT_T), sizeof(UINT_T) + 5,
287 2 * sizeof(UINT_T) + 5};
288
289 for (int stride : strides) {
290 bool decode_error = false;
291 std::vector<uint8_t> out(in_data.size() * stride);
292
293 std::pair<const uint8_t*, int64_t> res
294 = BitPacking::UnpackAndDecodeValues<UINT_T>(bit_width, data.data(),
295 data.size(), dict.data(), dict.size(), in_data.size(),
296 reinterpret_cast<UINT_T*>(out.data()), stride, &decode_error);
297
298 EXPECT_FALSE(decode_error);
299 EXPECT_EQ(in_data.size(), res.second);
300 ExpectEqualsWithStride<UINT_T>(in_data.data(), in_data.size(), out.data(),
301 out.size(), stride);
302 }
303 }
304 }
305}
306
307TEST(BitPackingTest, RandomUnpackAndDecode8) {
308 RandomUnpackAndDecodeTest<uint8_t>();

Callers

nothing calls this directly

Calls 6

GetLengthsFunction · 0.85
maxFunction · 0.85
DictEncodeFunction · 0.85
beginMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected