* @brief Create a reader from the parameters * * @param trace_type_str * @param trace_path * @param trace_type_params * @param n_req * @param ignore_obj_size * @param sample_ratio * @return reader_t* */
| 306 | * @return reader_t* |
| 307 | */ |
| 308 | reader_t *create_reader(const char *trace_type_str, const char *trace_path, |
| 309 | const char *trace_type_params, const int64_t n_req, |
| 310 | const bool ignore_obj_size, const int sample_ratio) { |
| 311 | /* convert trace type string to enum */ |
| 312 | trace_type_e trace_type = trace_type_str_to_enum(trace_type_str, trace_path); |
| 313 | |
| 314 | reader_init_param_t reader_init_params; |
| 315 | // memset(&reader_init_params, 0, sizeof(reader_init_params)); |
| 316 | set_default_reader_init_params(&reader_init_params); |
| 317 | reader_init_params.ignore_obj_size = ignore_obj_size; |
| 318 | reader_init_params.ignore_size_zero_req = true; |
| 319 | reader_init_params.obj_id_is_num = true; |
| 320 | reader_init_params.cap_at_n_req = n_req; |
| 321 | reader_init_params.sampler = NULL; |
| 322 | |
| 323 | parse_reader_params(trace_type_params, &reader_init_params); |
| 324 | |
| 325 | if (sample_ratio > 0 && sample_ratio < 1 - 1e-6) { |
| 326 | sampler_t *sampler = create_spatial_sampler(sample_ratio); |
| 327 | reader_init_params.sampler = sampler; |
| 328 | } |
| 329 | |
| 330 | reader_t *reader = setup_reader(trace_path, trace_type, &reader_init_params); |
| 331 | |
| 332 | return reader; |
| 333 | } |
| 334 | |
| 335 | #ifdef __cplusplus |
| 336 | } |
no test coverage detected