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

Function PackValues

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

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 4

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

Tested by

no test coverage detected