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

Function GenerateRandomValuesForPacking

cpp/src/arrow/util/bpacking_test.cc:46–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44/// Generate random values that can be packed within the given bit width.
45template <typename Uint>
46std::vector<Uint> GenerateRandomValuesForPacking(int num_values, int bit_width) {
47 constexpr uint32_t kSeed = 3214;
48
49 num_values = std::max(1, num_values); // We need a valid pointer for size 0
50 std::vector<Uint> out(num_values);
51
52 if (bit_width == 0) {
53 return out;
54 }
55
56 if constexpr (std::is_same_v<Uint, bool>) {
57 random_is_valid(num_values, 0.5, &out, kSeed);
58 } else {
59 const uint64_t max = bit_util::LeastSignificantBitMask<uint64_t, true>(bit_width);
60 rand_uniform_int(out.size(), kSeed, /* min= */ decltype(max){0}, max, out.data());
61 }
62 return out;
63}
64
65/// Convenience wrapper to unpack into a vector
66template <typename Int>

Callers

nothing calls this directly

Calls 4

random_is_validFunction · 0.85
rand_uniform_intFunction · 0.85
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected