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

Function GenerateRandomValuesForPacking

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

Source from the content-addressed store, hash-verified

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