| 81 | /// Use BitWriter to pack values into a vector. |
| 82 | template <typename Int> |
| 83 | std::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 | |
| 107 | class TestUnpack : public ::testing::TestWithParam<int> { |
| 108 | protected: |
no test coverage detected