| 96 | |
| 97 | template <typename PT> |
| 98 | void test_column(const alp_bench::ALPColumnDescriptor& column) { |
| 99 | using UT = typename alp::inner_t<PT>::ut; |
| 100 | using ST = typename alp::inner_t<PT>::st; |
| 101 | |
| 102 | auto* input_arr = reinterpret_cast<PT*>(intput_buf); |
| 103 | auto* sample_arr = reinterpret_cast<PT*>(sample_buf); |
| 104 | auto* right_arr = reinterpret_cast<UT*>(right_buf); |
| 105 | auto* ffor_right_arr = reinterpret_cast<UT*>(ffor_right_buf); |
| 106 | auto* unffor_right_arr = reinterpret_cast<UT*>(unffor_right_buf); |
| 107 | auto* glue_arr = reinterpret_cast<PT*>(glue_buf); |
| 108 | auto* exc_arr = reinterpret_cast<PT*>(exception_buf); |
| 109 | auto* dec_dbl_arr = reinterpret_cast<PT*>(decoded_buf); |
| 110 | auto* encoded_arr = reinterpret_cast<ST*>(encoded_buf); |
| 111 | auto* base_arr = reinterpret_cast<ST*>(base_buf); |
| 112 | auto* ffor_arr = reinterpret_cast<ST*>(ffor_buf); |
| 113 | |
| 114 | std::ifstream file(column.csv_file_path, std::ios::in); |
| 115 | if (!file) { throw std::runtime_error(column.csv_file_path + " : " + strerror(errno)); } |
| 116 | |
| 117 | alp::state<PT> stt; |
| 118 | size_t tuples_count {alp::config::VECTOR_SIZE}; |
| 119 | size_t rowgroup_offset {0}; |
| 120 | |
| 121 | double value_to_encode; |
| 122 | std::string val_str; |
| 123 | // keep storing values from the text file so long as data exists: |
| 124 | size_t row_idx {0}; |
| 125 | while (file >> val_str) { |
| 126 | if constexpr (std::is_same_v<PT, double>) { |
| 127 | value_to_encode = std::stod(val_str); |
| 128 | } else { |
| 129 | value_to_encode = std::stof(val_str); |
| 130 | } |
| 131 | |
| 132 | input_arr[row_idx] = value_to_encode; |
| 133 | row_idx += 1; |
| 134 | } |
| 135 | |
| 136 | // Init |
| 137 | alp::encoder<PT>::init(input_arr, rowgroup_offset, tuples_count, sample_arr, stt); |
| 138 | |
| 139 | switch (stt.scheme) { |
| 140 | case alp::Scheme::ALP_RD: { |
| 141 | alp::rd_encoder<PT>::init(input_arr, rowgroup_offset, tuples_count, sample_arr, stt); |
| 142 | |
| 143 | alp::rd_encoder<PT>::encode(input_arr, rd_exc_arr, pos_arr, exc_c_arr, right_arr, left_arr, stt); |
| 144 | ffor::ffor(right_arr, ffor_right_arr, stt.right_bit_width, &stt.right_for_base); |
| 145 | ffor::ffor(left_arr, ffor_left_arr, stt.left_bit_width, &stt.left_for_base); |
| 146 | |
| 147 | // Decode |
| 148 | unffor::unffor(ffor_right_arr, unffor_right_arr, stt.right_bit_width, &stt.right_for_base); |
| 149 | unffor::unffor(ffor_left_arr, unffor_left_arr, stt.left_bit_width, &stt.left_for_base); |
| 150 | alp::rd_encoder<PT>::decode( |
| 151 | glue_arr, unffor_right_arr, unffor_left_arr, rd_exc_arr, pos_arr, exc_c_arr, stt); |
| 152 | |
| 153 | for (size_t i = 0; i < alp::config::VECTOR_SIZE; ++i) { |
| 154 | auto l = input_arr[i]; |
| 155 | auto r = glue_arr[i]; |
nothing calls this directly
no test coverage detected