* Test to encode and decode whole datasets using ALP RD (aka ALP Cutter) * This test will output and write a file with the estimated bits/value after compression with alp */
| 128 | * This test will output and write a file with the estimated bits/value after compression with alp |
| 129 | */ |
| 130 | TEST_F(alp32_test, test_alprd32_on_whole_datasets) { |
| 131 | std::ofstream ofile(alp_bench::get_paths().result_dir_path + "compression_ratio_result/float/alp.csv", std::ios::out); |
| 132 | ofile << "dataset,size,rowgroups_count,vectors_count\n"; |
| 133 | |
| 134 | for (auto& dataset : alp_bench::get_sp_datasets()) { |
| 135 | if (!dataset.suitable_for_cutting) { continue; } |
| 136 | |
| 137 | std::cout << dataset.name << std::endl; |
| 138 | |
| 139 | std::vector<alp_bench::VectorMetadata> compression_metadata; |
| 140 | size_t tuples_count; |
| 141 | auto* data_column = mapper::mmap_file<float>(tuples_count, dataset.binary_file_path); |
| 142 | float value_to_encode = 0.0; |
| 143 | size_t vector_idx {0}; |
| 144 | size_t rowgroup_counter {0}; |
| 145 | size_t rowgroup_offset {0}; |
| 146 | alp::state<float> stt; |
| 147 | size_t rowgroups_count {1}; |
| 148 | size_t vectors_count {1}; |
| 149 | |
| 150 | /* Init */ |
| 151 | alp::encoder<float>::init(data_column, rowgroup_offset, tuples_count, smp_arr, stt); |
| 152 | |
| 153 | ASSERT_EQ(stt.scheme, alp::Scheme::ALP_RD); |
| 154 | |
| 155 | alp::rd_encoder<float>::init(data_column, rowgroup_offset, tuples_count, smp_arr, stt); |
| 156 | |
| 157 | /* Encode - Decode - Validate. */ |
| 158 | for (size_t i = 0; i < tuples_count; i++) { |
| 159 | value_to_encode = data_column[i]; |
| 160 | dbl_arr[vector_idx] = value_to_encode; |
| 161 | vector_idx = vector_idx + 1; |
| 162 | rowgroup_offset = rowgroup_offset + 1; |
| 163 | rowgroup_counter = rowgroup_counter + 1; |
| 164 | |
| 165 | if (vector_idx != VECTOR_SIZE) { continue; } |
| 166 | |
| 167 | if (rowgroup_counter == ROWGROUP_SIZE) { |
| 168 | rowgroup_counter = 0; |
| 169 | rowgroups_count = rowgroups_count + 1; |
| 170 | } |
| 171 | |
| 172 | // Encode |
| 173 | alp::rd_encoder<float>::encode(dbl_arr, rd_exc_arr, pos_arr, exc_c_arr, right_arr, left_arr, stt); |
| 174 | uint32_t right_for_base = 0; |
| 175 | ffor:: ffor(right_arr, ffor_right_arr, stt.right_bit_width, &right_for_base); |
| 176 | ffor:: ffor(left_arr, ffor_left_arr, stt.left_bit_width, &stt.left_for_base); |
| 177 | |
| 178 | // Decode |
| 179 | unffor::unffor(ffor_right_arr, unffor_right_arr, stt.right_bit_width, &right_for_base); |
| 180 | unffor::unffor(ffor_left_arr, unffor_left_arr, stt.left_bit_width, &stt.left_for_base); |
| 181 | alp::rd_encoder<float>::decode( |
| 182 | glue_arr, unffor_right_arr, unffor_left_arr, rd_exc_arr, pos_arr, exc_c_arr, stt); |
| 183 | |
| 184 | auto* dbl_glue_arr = reinterpret_cast<float*>(glue_arr); |
| 185 | for (size_t j = 0; j < VECTOR_SIZE; ++j) { |
| 186 | auto l = dbl_arr[j]; |
| 187 | auto r = dbl_glue_arr[j]; |
nothing calls this directly
no test coverage detected