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

Function PackValues

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

Source from the content-addressed store, hash-verified

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