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

Function PackValues

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

Source from the content-addressed store, hash-verified

81/// Use BitWriter to pack values into a vector.
82template <typename Int>
83std::vector<uint8_t> PackValues(const std::vector<Int>& values, int num_values,
84 int bit_width, int bit_offset) {
85 if (bit_width == 0) {
86 return {};
87 }
88
89 const auto num_bytes = GetNumBytes(num_values, bit_width, bit_offset);
90
91 std::vector<uint8_t> out(static_cast<std::size_t>(num_bytes));
92 bit_util::BitWriter writer(out.data(), num_bytes);
93
94 // Write a first 0 value to make an offset
95 const bool written = writer.PutValue(0, bit_offset);
96 ARROW_DCHECK(written);
97 for (const auto& v : values) {
98 const bool written = writer.PutValue(v, bit_width);
99 ARROW_DCHECK(written);
100 }
101
102 writer.Flush();
103
104 return out;
105}
106
107class TestUnpack : public ::testing::TestWithParam<int> {
108 protected:

Callers 1

Calls 4

PutValueMethod · 0.80
GetNumBytesFunction · 0.70
dataMethod · 0.45
FlushMethod · 0.45

Tested by

no test coverage detected