Compute the number of values in a StringArray based on a target `num_bytes`
| 77 | |
| 78 | // Compute the number of values in a StringArray based on a target `num_bytes` |
| 79 | static int64_t GetStringArraySize(int64_t num_bytes, int32_t min_length, |
| 80 | int32_t max_length, double null_proportion, |
| 81 | int num_chunks = 1) { |
| 82 | // The array_size is derived from these two equations: |
| 83 | // |
| 84 | // num_bytes = array_size * (1.0 - null_proportion) * string_mean_length |
| 85 | // string_mean_length = (max_length + min_length) / 2.0 |
| 86 | const double valid_proportion = 1.0 - null_proportion; |
| 87 | const double array_size = |
| 88 | (valid_proportion > std::numeric_limits<double>::epsilon()) |
| 89 | ? (num_bytes * 2) / (valid_proportion * (max_length + min_length)) |
| 90 | : (num_bytes * 2) / (max_length + min_length); |
| 91 | return static_cast<int64_t>(std::round(array_size / num_chunks)); |
| 92 | } |
| 93 | |
| 94 | template <typename Runner> |
| 95 | static void ArraySortFuncInt64Benchmark(benchmark::State& state, const Runner& runner, |
no outgoing calls
no test coverage detected