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

Function GetCastToInteger

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

Source from the content-addressed store, hash-verified

790
791template <typename OutType>
792std::shared_ptr<CastFunction> GetCastToInteger(std::string name) {
793 auto func = std::make_shared<CastFunction>(std::move(name), OutType::type_id);
794 auto out_ty = TypeTraits<OutType>::type_singleton();
795
796 for (const std::shared_ptr<DataType>& in_ty : IntTypes()) {
797 DCHECK_OK(func->AddKernel(in_ty->id(), {in_ty}, out_ty, CastIntegerToInteger));
798 }
799
800 // Cast from floating point
801 for (const std::shared_ptr<DataType>& in_ty : FloatingPointTypes()) {
802 DCHECK_OK(func->AddKernel(in_ty->id(), {in_ty}, out_ty, CastFloatingToInteger));
803 }
804
805 // Cast from half-float
806 DCHECK_OK(func->AddKernel(Type::HALF_FLOAT, {InputType(Type::HALF_FLOAT)}, out_ty,
807 CastFloatingToInteger));
808
809 // From other numbers to integer
810 AddCommonNumberCasts<OutType>(out_ty, func.get());
811
812 // From decimal to integer
813 DCHECK_OK(func->AddKernel(Type::DECIMAL, {InputType(Type::DECIMAL)}, out_ty,
814 CastFunctor<OutType, Decimal128Type>::Exec));
815 DCHECK_OK(func->AddKernel(Type::DECIMAL32, {InputType(Type::DECIMAL32)}, out_ty,
816 CastFunctor<OutType, Decimal32Type>::Exec));
817 DCHECK_OK(func->AddKernel(Type::DECIMAL64, {InputType(Type::DECIMAL64)}, out_ty,
818 CastFunctor<OutType, Decimal64Type>::Exec));
819 DCHECK_OK(func->AddKernel(Type::DECIMAL256, {InputType(Type::DECIMAL256)}, out_ty,
820 CastFunctor<OutType, Decimal256Type>::Exec));
821 return func;
822}
823
824template <typename OutType>
825std::shared_ptr<CastFunction> GetCastToFloating(std::string name) {

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