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

Function StatisticInit

cpp/src/arrow/compute/kernels/aggregate_var_std.cc:238–261  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

236
237template <typename OptionsType>
238Result<std::unique_ptr<KernelState>> StatisticInit(
239 StatisticType stat_type, const DataType& in_type,
240 const std::shared_ptr<DataType>& out_type, const OptionsType& options) {
241 auto make_kernel_state = [&](auto&& type, int32_t decimal_scale = 0) {
242 using Type = std::decay_t<decltype(type)>;
243 return std::unique_ptr<KernelState>(
244 new StatisticImpl<Type>(stat_type, decimal_scale, out_type, options));
245 };
246
247 auto visit = [&](auto&& type) -> Result<std::unique_ptr<KernelState>> {
248 using Type = std::decay_t<decltype(type)>;
249 // Decimals
250 if constexpr (is_decimal_type<Type>::value) {
251 return make_kernel_state(type, type.scale());
252 }
253 // Numbers (except half-float)
254 if constexpr (is_number_type<Type>::value && !is_half_float_type<Type>::value) {
255 return make_kernel_state(type);
256 }
257 return Status::NotImplemented("No variance/stddev implemented for ",
258 in_type.ToString());
259 };
260 return VisitType(in_type, visit);
261}
262
263template <typename OptionsType, StatisticType kStatType>
264Result<std::unique_ptr<KernelState>> StatisticInit(KernelContext* ctx,

Callers

nothing calls this directly

Calls 6

NotImplementedFunction · 0.50
VisitTypeFunction · 0.50
scaleMethod · 0.45
ToStringMethod · 0.45
typeMethod · 0.45
out_typeMethod · 0.45

Tested by

no test coverage detected