| 1021 | /// encoded). If true, Nulls are skipped and only valid values are encoded. |
| 1022 | template <typename Type> |
| 1023 | std::vector<uint8_t> EncodeTestArray(const Array& data, int bit_width, |
| 1024 | bool spaced = false) { |
| 1025 | using ArrayType = typename TypeTraits<Type>::ArrayType; |
| 1026 | |
| 1027 | const auto data_size = static_cast<rle_size_t>(data.length()); |
| 1028 | const auto values_count = |
| 1029 | static_cast<rle_size_t>(data.length() - (spaced ? data.null_count() : 0)); |
| 1030 | const int buffer_size = |
| 1031 | static_cast<int>(RleBitPackedEncoder::MaxBufferSize(bit_width, values_count) + |
| 1032 | RleBitPackedEncoder::MinBufferSize(bit_width)); |
| 1033 | const auto* data_values = static_cast<const ArrayType&>(data).raw_values(); |
| 1034 | |
| 1035 | std::vector<uint8_t> buffer(buffer_size); |
| 1036 | RleBitPackedEncoder encoder(buffer.data(), buffer_size, bit_width); |
| 1037 | rle_size_t encoded_values_count = 0; |
| 1038 | for (rle_size_t i = 0; i < data_size; ++i) { |
| 1039 | if (data.IsValid(i) || !spaced) { |
| 1040 | EXPECT_TRUE(encoder.Put(static_cast<uint64_t>(data_values[i]))) |
| 1041 | << "Encoding failed in pos " << i << ", current encoder len: " << encoder.len(); |
| 1042 | ++encoded_values_count; |
| 1043 | } |
| 1044 | } |
| 1045 | EXPECT_EQ(encoded_values_count, values_count) |
| 1046 | << "All values input were not encoded successfully by the encoder"; |
| 1047 | buffer.resize(encoder.Flush()); |
| 1048 | return buffer; |
| 1049 | } |
| 1050 | |
| 1051 | /// Check RleBitPacked encoding/decoding round trip. |
| 1052 | /// |
nothing calls this directly
no test coverage detected