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

Function GenerateRandomValuesForPacking

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

Source from the content-addressed store, hash-verified

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