MCPcopy Create free account
hub / github.com/apache/arrow / GetStringArraySize

Function GetStringArraySize

cpp/src/arrow/compute/kernels/vector_sort_benchmark.cc:79–92  ·  view source on GitHub ↗

Compute the number of values in a StringArray based on a target `num_bytes`

Source from the content-addressed store, hash-verified

77
78// Compute the number of values in a StringArray based on a target `num_bytes`
79static 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
94template <typename Runner>
95static void ArraySortFuncInt64Benchmark(benchmark::State& state, const Runner& runner,

Calls

no outgoing calls

Tested by

no test coverage detected