@@ -36,61 +36,6 @@ class AbstractBuffer;
36
36
// default max input buffer size to 1MB
37
37
#define MAX_INPUT_BUF_SIZE 1048576
38
38
39
- class DecimalOverflowValidator {
40
- public:
41
- DecimalOverflowValidator (const hdk::ir::Type* type) {
42
- if (type && type->isArray ()) {
43
- type = type->as <hdk::ir::ArrayBaseType>()->elemType ();
44
- }
45
-
46
- if (type && type->isDecimal ()) {
47
- do_check_ = true ;
48
- int precision = type->as <hdk::ir::DecimalType>()->precision ();
49
- int scale = type->as <hdk::ir::DecimalType>()->scale ();
50
- max_ = (int64_t )std::pow ((double )10.0 , precision);
51
- min_ = -max_;
52
- pow10_ = precision - scale;
53
-
54
- } else {
55
- do_check_ = false ;
56
- max_ = 1 ;
57
- min_ = -1 ;
58
- pow10_ = 0 ;
59
- }
60
- }
61
-
62
- template <typename T>
63
- void validate (T value) const {
64
- if (std::is_integral<T>::value) {
65
- do_validate (static_cast <int64_t >(value));
66
- }
67
- }
68
-
69
- void do_validate (int64_t value) const {
70
- if (!do_check_) {
71
- return ;
72
- }
73
-
74
- if (value >= max_) {
75
- throw std::runtime_error (" Decimal overflow: value is greater than 10^" +
76
- std::to_string (pow10_) + " max " + std::to_string (max_) +
77
- " value " + std::to_string (value));
78
- }
79
-
80
- if (value <= min_) {
81
- throw std::runtime_error (" Decimal overflow: value is less than -10^" +
82
- std::to_string (pow10_) + " min " + std::to_string (min_) +
83
- " value " + std::to_string (value));
84
- }
85
- }
86
-
87
- private:
88
- bool do_check_;
89
- int64_t max_;
90
- int64_t min_;
91
- int pow10_;
92
- };
93
-
94
39
template <typename INNER_VALIDATOR>
95
40
class NullAwareValidator {
96
41
public:
@@ -253,7 +198,6 @@ class Encoder {
253
198
254
199
Data_Namespace::AbstractBuffer* buffer_;
255
200
256
- DecimalOverflowValidator decimal_overflow_validator_;
257
201
DateDaysOverflowValidator date_days_overflow_validator_;
258
202
};
259
203
0 commit comments