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

Function GetCastToFloating

cpp/src/arrow/compute/kernels/scalar_cast_numeric.cc:825–857  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

823
824template <typename OutType>
825std::shared_ptr<CastFunction> GetCastToFloating(std::string name) {
826 auto func = std::make_shared<CastFunction>(std::move(name), OutType::type_id);
827 auto out_ty = TypeTraits<OutType>::type_singleton();
828
829 // Casts from integer to floating point
830 for (const std::shared_ptr<DataType>& in_ty : IntTypes()) {
831 DCHECK_OK(func->AddKernel(in_ty->id(), {in_ty}, out_ty, CastIntegerToFloating));
832 }
833
834 // Cast from floating point
835 for (const std::shared_ptr<DataType>& in_ty : FloatingPointTypes()) {
836 DCHECK_OK(func->AddKernel(in_ty->id(), {in_ty}, out_ty, CastFloatingToFloating));
837 }
838
839 // From half-float to float/double
840 DCHECK_OK(func->AddKernel(Type::HALF_FLOAT, {InputType(Type::HALF_FLOAT)}, out_ty,
841 CastFloatingToFloating));
842
843 // From other numbers to floating point
844 AddCommonNumberCasts<OutType>(out_ty, func.get());
845
846 // From decimal to floating point
847 DCHECK_OK(func->AddKernel(Type::DECIMAL32, {InputType(Type::DECIMAL32)}, out_ty,
848 CastFunctor<OutType, Decimal32Type>::Exec));
849 DCHECK_OK(func->AddKernel(Type::DECIMAL64, {InputType(Type::DECIMAL64)}, out_ty,
850 CastFunctor<OutType, Decimal64Type>::Exec));
851 DCHECK_OK(func->AddKernel(Type::DECIMAL, {InputType(Type::DECIMAL)}, out_ty,
852 CastFunctor<OutType, Decimal128Type>::Exec));
853 DCHECK_OK(func->AddKernel(Type::DECIMAL256, {InputType(Type::DECIMAL256)}, out_ty,
854 CastFunctor<OutType, Decimal256Type>::Exec));
855
856 return func;
857}
858
859std::shared_ptr<CastFunction> GetCastToDecimal32() {
860 OutputType sig_out_ty(ResolveOutputFromOptions);

Callers

nothing calls this directly

Calls 5

InputTypeFunction · 0.85
type_singletonFunction · 0.70
AddKernelMethod · 0.45
idMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected