| 182 | |
| 183 | template <typename INT_T> |
| 184 | std::pair<std::vector<uint8_t>, int> DictEncodeAll(const std::vector<INT_T>& plain) { |
| 185 | MemTracker track_encoder; |
| 186 | MemTracker tracker; |
| 187 | MemPool pool(&tracker); |
| 188 | |
| 189 | int dict_len; |
| 190 | std::vector<uint8_t> output; |
| 191 | |
| 192 | { |
| 193 | DictEncoder<INT_T> encoder(&pool, sizeof(INT_T), &track_encoder); |
| 194 | |
| 195 | for (const INT_T value : plain) { |
| 196 | int success = encoder.Put(value); |
| 197 | DCHECK_GE(success, 0); |
| 198 | } |
| 199 | |
| 200 | dict_len = encoder.dict_encoded_size(); |
| 201 | const int data_len = encoder.EstimatedDataEncodedSize(); |
| 202 | |
| 203 | output = std::vector<uint8_t>(dict_len + data_len, 0); |
| 204 | |
| 205 | encoder.WriteDict(output.data()); |
| 206 | const int data_written = encoder.WriteData(output.data() + dict_len, data_len); |
| 207 | DCHECK_GE(data_written, 0); |
| 208 | |
| 209 | output.resize(dict_len + data_written); |
| 210 | |
| 211 | encoder.Close(); |
| 212 | } |
| 213 | |
| 214 | pool.FreeAll(); |
| 215 | tracker.Close(); |
| 216 | track_encoder.Close(); |
| 217 | |
| 218 | return std::make_pair(output, dict_len); |
| 219 | } |
| 220 | |
| 221 | /// This struct holds the information that is given to the benchmark functions. |
| 222 | struct DeltaBenchmarkData { |
nothing calls this directly
no test coverage detected