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

Method DispatchBest

cpp/src/arrow/compute/kernels/scalar_if_else.cc:1245–1287  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1243 using ScalarFunction::ScalarFunction;
1244
1245 Result<const Kernel*> DispatchBest(std::vector<TypeHolder>* types) const override {
1246 RETURN_NOT_OK(CheckArity(types->size()));
1247
1248 using arrow::compute::detail::DispatchExactImpl;
1249 // Do not DispatchExact here because it'll let through something like (bool,
1250 // timestamp[s], timestamp[s, "UTC"])
1251
1252 // if 0th type is null, replace with bool
1253 if (types->at(0).id() == Type::NA) {
1254 (*types)[0] = boolean();
1255 }
1256
1257 // if-else 0'th type is bool, so skip it
1258 TypeHolder* left_arg = &(*types)[1];
1259 constexpr size_t num_args = 2;
1260
1261 internal::ReplaceNullWithOtherType(left_arg, num_args);
1262
1263 // If both are identical dictionary types, dispatch to the dictionary kernel
1264 // TODO(ARROW-14105): apply implicit casts to dictionary types too
1265 TypeHolder* right_arg = &(*types)[2];
1266 if (is_dictionary(left_arg->id()) && left_arg->type->Equals(*right_arg->type)) {
1267 auto kernel = DispatchExactImpl(this, *types);
1268 DCHECK(kernel);
1269 return kernel;
1270 }
1271
1272 internal::EnsureDictionaryDecoded(left_arg, num_args);
1273
1274 if (auto type = internal::CommonNumeric(left_arg, num_args)) {
1275 internal::ReplaceTypes(type, left_arg, num_args);
1276 } else if (auto type = internal::CommonTemporal(left_arg, num_args)) {
1277 internal::ReplaceTypes(type, left_arg, num_args);
1278 } else if (auto type = internal::CommonBinary(left_arg, num_args)) {
1279 internal::ReplaceTypes(type, left_arg, num_args);
1280 } else if (HasDecimal(*types)) {
1281 RETURN_NOT_OK(CastDecimalArgs(left_arg, num_args));
1282 }
1283
1284 if (auto kernel = DispatchExactImpl(this, *types)) return kernel;
1285
1286 return arrow::compute::detail::NoMatchingKernel(this, *types);
1287 }
1288};
1289
1290void AddNullIfElseKernel(const std::shared_ptr<IfElseFunction>& scalar_function) {

Callers

nothing calls this directly

Calls 14

ReplaceNullWithOtherTypeFunction · 0.85
DispatchExactImplFunction · 0.85
EnsureDictionaryDecodedFunction · 0.85
CommonNumericFunction · 0.85
ReplaceTypesFunction · 0.85
CommonTemporalFunction · 0.85
CommonBinaryFunction · 0.85
HasDecimalFunction · 0.85
CastDecimalArgsFunction · 0.85
NoMatchingKernelFunction · 0.85
is_dictionaryFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected