Line | Count | Source |
1 | | // Licensed to the Apache Software Foundation (ASF) under one |
2 | | // or more contributor license agreements. See the NOTICE file |
3 | | // distributed with this work for additional information |
4 | | // regarding copyright ownership. The ASF licenses this file |
5 | | // to you under the Apache License, Version 2.0 (the |
6 | | // "License"); you may not use this file except in compliance |
7 | | // with the License. You may obtain a copy of the License at |
8 | | // |
9 | | // http://www.apache.org/licenses/LICENSE-2.0 |
10 | | // |
11 | | // Unless required by applicable law or agreed to in writing, |
12 | | // software distributed under the License is distributed on an |
13 | | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
14 | | // KIND, either express or implied. See the License for the |
15 | | // specific language governing permissions and limitations |
16 | | // under the License. |
17 | | |
18 | | #pragma once |
19 | | |
20 | | #include <fmt/compile.h> |
21 | | #include <gen_cpp/data.pb.h> |
22 | | #include <snappy/snappy.h> |
23 | | |
24 | | #include <iostream> |
25 | | #include <type_traits> |
26 | | |
27 | | #include "common/exception.h" |
28 | | #include "core/arena.h" |
29 | | #include "core/binary_cast.hpp" |
30 | | #include "core/field.h" |
31 | | #include "core/string_buffer.hpp" |
32 | | #include "core/string_ref.h" |
33 | | #include "core/types.h" |
34 | | #include "core/uint128.h" |
35 | | #include "core/value/ipv4_value.h" |
36 | | #include "core/value/ipv6_value.h" |
37 | | #include "core/value/vdatetime_value.h" |
38 | | #include "util/string_parser.hpp" |
39 | | #include "util/var_int.h" |
40 | | |
41 | | namespace doris { |
42 | | #include "common/compile_check_begin.h" |
43 | 320 | inline std::string int128_to_string(int128_t value) { |
44 | 320 | return fmt::format(FMT_COMPILE("{}"), value); |
45 | 320 | } |
46 | | |
47 | 0 | inline std::string int128_to_string(uint128_t value) { |
48 | 0 | return fmt::format(FMT_COMPILE("{}"), value); |
49 | 0 | } |
50 | | |
51 | 0 | inline std::string int128_to_string(UInt128 value) { |
52 | 0 | return value.to_hex_string(); |
53 | 0 | } |
54 | | |
55 | | template <typename T> |
56 | | void write_text(Decimal<T> value, UInt32 scale, std::ostream& ostr) { |
57 | | if (value < Decimal<T>(0)) { |
58 | | value *= Decimal<T>(-1); |
59 | | if (value > Decimal<T>(0)) { |
60 | | ostr << '-'; |
61 | | } |
62 | | } |
63 | | |
64 | | T whole_part = value; |
65 | | |
66 | | if (scale) { |
67 | | whole_part = value / decimal_scale_multiplier<T>(scale); |
68 | | } |
69 | | if constexpr (std::is_same_v<T, __int128_t>) { |
70 | | ostr << int128_to_string(whole_part); |
71 | | } else { |
72 | | ostr << whole_part; |
73 | | } |
74 | | if (scale) { |
75 | | ostr << '.'; |
76 | | String str_fractional(scale, '0'); |
77 | | Int32 pos = scale - 1; |
78 | | if (value < Decimal<T>(0) && pos >= 0) { |
79 | | // Reach here iff this value is a min value of a signed numeric type. It means min<int>() |
80 | | // which is -2147483648 multiply -1 is still -2147483648. |
81 | | str_fractional[pos] += (value / 10 * 10) - value; |
82 | | pos--; |
83 | | value /= 10; |
84 | | value *= Decimal<T>(-1); |
85 | | } |
86 | | for (; pos >= 0; --pos, value /= 10) { |
87 | | str_fractional[pos] += value % 10; |
88 | | } |
89 | | ostr.write(str_fractional.data(), scale); |
90 | | } |
91 | | } |
92 | | |
93 | | template <typename T> |
94 | 5.56M | bool try_read_float_text(T& x, const StringRef& in) { |
95 | 5.56M | static_assert(std::is_same_v<T, double> || std::is_same_v<T, float>, |
96 | 5.56M | "Argument for readFloatTextImpl must be float or double"); |
97 | 5.56M | static_assert('a' > '.' && 'A' > '.' && '\n' < '.' && '\t' < '.' && '\'' < '.' && '"' < '.', |
98 | 5.56M | "Layout of char is not like ASCII"); //-V590 |
99 | | |
100 | 5.56M | StringParser::ParseResult result; |
101 | 5.56M | x = StringParser::string_to_float<T>(in.data, in.size, &result); |
102 | | |
103 | 5.56M | return result == StringParser::PARSE_SUCCESS; |
104 | 5.56M | } _ZN5doris19try_read_float_textIfEEbRT_RKNS_9StringRefE Line | Count | Source | 94 | 1.56M | bool try_read_float_text(T& x, const StringRef& in) { | 95 | 1.56M | static_assert(std::is_same_v<T, double> || std::is_same_v<T, float>, | 96 | 1.56M | "Argument for readFloatTextImpl must be float or double"); | 97 | 1.56M | static_assert('a' > '.' && 'A' > '.' && '\n' < '.' && '\t' < '.' && '\'' < '.' && '"' < '.', | 98 | 1.56M | "Layout of char is not like ASCII"); //-V590 | 99 | | | 100 | 1.56M | StringParser::ParseResult result; | 101 | 1.56M | x = StringParser::string_to_float<T>(in.data, in.size, &result); | 102 | | | 103 | 1.56M | return result == StringParser::PARSE_SUCCESS; | 104 | 1.56M | } |
_ZN5doris19try_read_float_textIdEEbRT_RKNS_9StringRefE Line | Count | Source | 94 | 3.99M | bool try_read_float_text(T& x, const StringRef& in) { | 95 | 3.99M | static_assert(std::is_same_v<T, double> || std::is_same_v<T, float>, | 96 | 3.99M | "Argument for readFloatTextImpl must be float or double"); | 97 | 3.99M | static_assert('a' > '.' && 'A' > '.' && '\n' < '.' && '\t' < '.' && '\'' < '.' && '"' < '.', | 98 | 3.99M | "Layout of char is not like ASCII"); //-V590 | 99 | | | 100 | 3.99M | StringParser::ParseResult result; | 101 | 3.99M | x = StringParser::string_to_float<T>(in.data, in.size, &result); | 102 | | | 103 | 3.99M | return result == StringParser::PARSE_SUCCESS; | 104 | 3.99M | } |
|
105 | | |
106 | | template <typename T, bool enable_strict_mode = false> |
107 | 133M | bool try_read_int_text(T& x, const StringRef& buf) { |
108 | 133M | StringParser::ParseResult result; |
109 | 133M | x = StringParser::string_to_int<T, enable_strict_mode>(buf.data, buf.size, &result); |
110 | | |
111 | 133M | return result == StringParser::PARSE_SUCCESS; |
112 | 133M | } _ZN5doris17try_read_int_textInLb0EEEbRT_RKNS_9StringRefE Line | Count | Source | 107 | 1.05M | bool try_read_int_text(T& x, const StringRef& buf) { | 108 | 1.05M | StringParser::ParseResult result; | 109 | 1.05M | x = StringParser::string_to_int<T, enable_strict_mode>(buf.data, buf.size, &result); | 110 | | | 111 | 1.05M | return result == StringParser::PARSE_SUCCESS; | 112 | 1.05M | } |
_ZN5doris17try_read_int_textIaLb1EEEbRT_RKNS_9StringRefE Line | Count | Source | 107 | 12.0k | bool try_read_int_text(T& x, const StringRef& buf) { | 108 | 12.0k | StringParser::ParseResult result; | 109 | 12.0k | x = StringParser::string_to_int<T, enable_strict_mode>(buf.data, buf.size, &result); | 110 | | | 111 | 12.0k | return result == StringParser::PARSE_SUCCESS; | 112 | 12.0k | } |
_ZN5doris17try_read_int_textIsLb1EEEbRT_RKNS_9StringRefE Line | Count | Source | 107 | 12.0k | bool try_read_int_text(T& x, const StringRef& buf) { | 108 | 12.0k | StringParser::ParseResult result; | 109 | 12.0k | x = StringParser::string_to_int<T, enable_strict_mode>(buf.data, buf.size, &result); | 110 | | | 111 | 12.0k | return result == StringParser::PARSE_SUCCESS; | 112 | 12.0k | } |
_ZN5doris17try_read_int_textIiLb1EEEbRT_RKNS_9StringRefE Line | Count | Source | 107 | 13.9k | bool try_read_int_text(T& x, const StringRef& buf) { | 108 | 13.9k | StringParser::ParseResult result; | 109 | 13.9k | x = StringParser::string_to_int<T, enable_strict_mode>(buf.data, buf.size, &result); | 110 | | | 111 | 13.9k | return result == StringParser::PARSE_SUCCESS; | 112 | 13.9k | } |
_ZN5doris17try_read_int_textIlLb1EEEbRT_RKNS_9StringRefE Line | Count | Source | 107 | 12.5k | bool try_read_int_text(T& x, const StringRef& buf) { | 108 | 12.5k | StringParser::ParseResult result; | 109 | 12.5k | x = StringParser::string_to_int<T, enable_strict_mode>(buf.data, buf.size, &result); | 110 | | | 111 | 12.5k | return result == StringParser::PARSE_SUCCESS; | 112 | 12.5k | } |
_ZN5doris17try_read_int_textInLb1EEEbRT_RKNS_9StringRefE Line | Count | Source | 107 | 11.8k | bool try_read_int_text(T& x, const StringRef& buf) { | 108 | 11.8k | StringParser::ParseResult result; | 109 | 11.8k | x = StringParser::string_to_int<T, enable_strict_mode>(buf.data, buf.size, &result); | 110 | | | 111 | 11.8k | return result == StringParser::PARSE_SUCCESS; | 112 | 11.8k | } |
_ZN5doris17try_read_int_textIaLb0EEEbRT_RKNS_9StringRefE Line | Count | Source | 107 | 8.99M | bool try_read_int_text(T& x, const StringRef& buf) { | 108 | 8.99M | StringParser::ParseResult result; | 109 | 8.99M | x = StringParser::string_to_int<T, enable_strict_mode>(buf.data, buf.size, &result); | 110 | | | 111 | 8.99M | return result == StringParser::PARSE_SUCCESS; | 112 | 8.99M | } |
_ZN5doris17try_read_int_textIsLb0EEEbRT_RKNS_9StringRefE Line | Count | Source | 107 | 1.17M | bool try_read_int_text(T& x, const StringRef& buf) { | 108 | 1.17M | StringParser::ParseResult result; | 109 | 1.17M | x = StringParser::string_to_int<T, enable_strict_mode>(buf.data, buf.size, &result); | 110 | | | 111 | 1.17M | return result == StringParser::PARSE_SUCCESS; | 112 | 1.17M | } |
_ZN5doris17try_read_int_textIiLb0EEEbRT_RKNS_9StringRefE Line | Count | Source | 107 | 55.5M | bool try_read_int_text(T& x, const StringRef& buf) { | 108 | 55.5M | StringParser::ParseResult result; | 109 | 55.5M | x = StringParser::string_to_int<T, enable_strict_mode>(buf.data, buf.size, &result); | 110 | | | 111 | 55.5M | return result == StringParser::PARSE_SUCCESS; | 112 | 55.5M | } |
_ZN5doris17try_read_int_textIlLb0EEEbRT_RKNS_9StringRefE Line | Count | Source | 107 | 66.9M | bool try_read_int_text(T& x, const StringRef& buf) { | 108 | 66.9M | StringParser::ParseResult result; | 109 | 66.9M | x = StringParser::string_to_int<T, enable_strict_mode>(buf.data, buf.size, &result); | 110 | | | 111 | 66.9M | return result == StringParser::PARSE_SUCCESS; | 112 | 66.9M | } |
Unexecuted instantiation: _ZN5doris17try_read_int_textIjLb0EEEbRT_RKNS_9StringRefE _ZN5doris17try_read_int_textImLb0EEEbRT_RKNS_9StringRefE Line | Count | Source | 107 | 3.79k | bool try_read_int_text(T& x, const StringRef& buf) { | 108 | 3.79k | StringParser::ParseResult result; | 109 | 3.79k | x = StringParser::string_to_int<T, enable_strict_mode>(buf.data, buf.size, &result); | 110 | | | 111 | 3.79k | return result == StringParser::PARSE_SUCCESS; | 112 | 3.79k | } |
|
113 | | |
114 | | bool read_date_text_impl(VecDateTimeValue& x, const StringRef& buf); |
115 | | |
116 | | bool read_date_text_impl(Int64& x, const StringRef& buf, const cctz::time_zone& local_time_zone); |
117 | | |
118 | | template <typename T> |
119 | 82.9k | bool read_ipv4_text_impl(T& x, const StringRef& buf) { |
120 | 82.9k | static_assert(std::is_same_v<IPv4, T>); |
121 | 82.9k | bool res = IPv4Value::from_string(x, buf.data, buf.size); |
122 | 82.9k | return res; |
123 | 82.9k | } |
124 | | |
125 | | template <typename T> |
126 | 59.7k | bool read_ipv6_text_impl(T& x, const StringRef& buf) { |
127 | 59.7k | static_assert(std::is_same_v<IPv6, T>); |
128 | 59.7k | bool res = IPv6Value::from_string(x, buf.data, buf.size); |
129 | 59.7k | return res; |
130 | 59.7k | } |
131 | | |
132 | | bool read_datetime_text_impl(VecDateTimeValue& x, const StringRef& buf); |
133 | | |
134 | | bool read_datetime_text_impl(Int64& x, const StringRef& buf, |
135 | | const cctz::time_zone& local_time_zone); |
136 | | |
137 | | bool read_date_v2_text_impl(DateV2Value<DateV2ValueType>& x, const StringRef& buf); |
138 | | |
139 | | bool read_date_v2_text_impl(DateV2Value<DateV2ValueType>& x, const StringRef& buf, |
140 | | const cctz::time_zone& local_time_zone); |
141 | | |
142 | | bool read_datetime_v2_text_impl(DateV2Value<DateTimeV2ValueType>& x, const StringRef& buf, |
143 | | UInt32 scale = -1); |
144 | | |
145 | | bool read_datetime_v2_text_impl(DateV2Value<DateTimeV2ValueType>& x, const StringRef& buf, |
146 | | const cctz::time_zone& local_time_zone, UInt32 scale = -1); |
147 | | |
148 | | template <PrimitiveType P, typename T> |
149 | | StringParser::ParseResult read_decimal_text_impl(T& x, const StringRef& buf, UInt32 precision, |
150 | 21.0M | UInt32 scale) { |
151 | 21.0M | static_assert(IsDecimalNumber<T>); |
152 | 21.0M | if constexpr (!std::is_same_v<DecimalV2Value, T>) { |
153 | | // DecimalV3: uses the caller-supplied precision and scale. |
154 | | // When called from from_olap_string with ignore_scale=true, scale=0 means the |
155 | | // string is treated as an unscaled integer (e.g. "12345" → internal int 12345). |
156 | 21.0M | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; |
157 | 21.0M | x.value = StringParser::string_to_decimal<P>(buf.data, (int)buf.size, precision, scale, |
158 | 21.0M | &result); |
159 | 21.0M | return result; |
160 | 21.0M | } else { |
161 | | // DecimalV2: IGNORES the caller-supplied precision/scale and hardcodes |
162 | | // DecimalV2Value::PRECISION (27) and DecimalV2Value::SCALE (9). |
163 | | // This means from_olap_string's ignore_scale flag has no actual effect on DecimalV2 |
164 | | // parsing today — the string "123.456000000" is always parsed with scale=9. |
165 | | // Callers should still set ignore_scale=false for DecimalV2 for semantic correctness. |
166 | 12.1k | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; |
167 | 12.1k | x = DecimalV2Value(StringParser::string_to_decimal<TYPE_DECIMALV2>( |
168 | 12.1k | buf.data, (int)buf.size, DecimalV2Value::PRECISION, DecimalV2Value::SCALE, |
169 | 12.1k | &result)); |
170 | 12.1k | return result; |
171 | 12.1k | } |
172 | 21.0M | } _ZN5doris22read_decimal_text_implILNS_13PrimitiveTypeE28ENS_7DecimalIiEEEENS_12StringParser11ParseResultERT0_RKNS_9StringRefEjj Line | Count | Source | 150 | 2.04M | UInt32 scale) { | 151 | 2.04M | static_assert(IsDecimalNumber<T>); | 152 | 2.04M | if constexpr (!std::is_same_v<DecimalV2Value, T>) { | 153 | | // DecimalV3: uses the caller-supplied precision and scale. | 154 | | // When called from from_olap_string with ignore_scale=true, scale=0 means the | 155 | | // string is treated as an unscaled integer (e.g. "12345" → internal int 12345). | 156 | 2.04M | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 157 | 2.04M | x.value = StringParser::string_to_decimal<P>(buf.data, (int)buf.size, precision, scale, | 158 | 2.04M | &result); | 159 | 2.04M | return result; | 160 | | } else { | 161 | | // DecimalV2: IGNORES the caller-supplied precision/scale and hardcodes | 162 | | // DecimalV2Value::PRECISION (27) and DecimalV2Value::SCALE (9). | 163 | | // This means from_olap_string's ignore_scale flag has no actual effect on DecimalV2 | 164 | | // parsing today — the string "123.456000000" is always parsed with scale=9. | 165 | | // Callers should still set ignore_scale=false for DecimalV2 for semantic correctness. | 166 | | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 167 | | x = DecimalV2Value(StringParser::string_to_decimal<TYPE_DECIMALV2>( | 168 | | buf.data, (int)buf.size, DecimalV2Value::PRECISION, DecimalV2Value::SCALE, | 169 | | &result)); | 170 | | return result; | 171 | | } | 172 | 2.04M | } |
_ZN5doris22read_decimal_text_implILNS_13PrimitiveTypeE29ENS_7DecimalIlEEEENS_12StringParser11ParseResultERT0_RKNS_9StringRefEjj Line | Count | Source | 150 | 16.1M | UInt32 scale) { | 151 | 16.1M | static_assert(IsDecimalNumber<T>); | 152 | 16.1M | if constexpr (!std::is_same_v<DecimalV2Value, T>) { | 153 | | // DecimalV3: uses the caller-supplied precision and scale. | 154 | | // When called from from_olap_string with ignore_scale=true, scale=0 means the | 155 | | // string is treated as an unscaled integer (e.g. "12345" → internal int 12345). | 156 | 16.1M | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 157 | 16.1M | x.value = StringParser::string_to_decimal<P>(buf.data, (int)buf.size, precision, scale, | 158 | 16.1M | &result); | 159 | 16.1M | return result; | 160 | | } else { | 161 | | // DecimalV2: IGNORES the caller-supplied precision/scale and hardcodes | 162 | | // DecimalV2Value::PRECISION (27) and DecimalV2Value::SCALE (9). | 163 | | // This means from_olap_string's ignore_scale flag has no actual effect on DecimalV2 | 164 | | // parsing today — the string "123.456000000" is always parsed with scale=9. | 165 | | // Callers should still set ignore_scale=false for DecimalV2 for semantic correctness. | 166 | | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 167 | | x = DecimalV2Value(StringParser::string_to_decimal<TYPE_DECIMALV2>( | 168 | | buf.data, (int)buf.size, DecimalV2Value::PRECISION, DecimalV2Value::SCALE, | 169 | | &result)); | 170 | | return result; | 171 | | } | 172 | 16.1M | } |
_ZN5doris22read_decimal_text_implILNS_13PrimitiveTypeE30ENS_12Decimal128V3EEENS_12StringParser11ParseResultERT0_RKNS_9StringRefEjj Line | Count | Source | 150 | 2.69M | UInt32 scale) { | 151 | 2.69M | static_assert(IsDecimalNumber<T>); | 152 | 2.69M | if constexpr (!std::is_same_v<DecimalV2Value, T>) { | 153 | | // DecimalV3: uses the caller-supplied precision and scale. | 154 | | // When called from from_olap_string with ignore_scale=true, scale=0 means the | 155 | | // string is treated as an unscaled integer (e.g. "12345" → internal int 12345). | 156 | 2.69M | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 157 | 2.69M | x.value = StringParser::string_to_decimal<P>(buf.data, (int)buf.size, precision, scale, | 158 | 2.69M | &result); | 159 | 2.69M | return result; | 160 | | } else { | 161 | | // DecimalV2: IGNORES the caller-supplied precision/scale and hardcodes | 162 | | // DecimalV2Value::PRECISION (27) and DecimalV2Value::SCALE (9). | 163 | | // This means from_olap_string's ignore_scale flag has no actual effect on DecimalV2 | 164 | | // parsing today — the string "123.456000000" is always parsed with scale=9. | 165 | | // Callers should still set ignore_scale=false for DecimalV2 for semantic correctness. | 166 | | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 167 | | x = DecimalV2Value(StringParser::string_to_decimal<TYPE_DECIMALV2>( | 168 | | buf.data, (int)buf.size, DecimalV2Value::PRECISION, DecimalV2Value::SCALE, | 169 | | &result)); | 170 | | return result; | 171 | | } | 172 | 2.69M | } |
_ZN5doris22read_decimal_text_implILNS_13PrimitiveTypeE20ENS_14DecimalV2ValueEEENS_12StringParser11ParseResultERT0_RKNS_9StringRefEjj Line | Count | Source | 150 | 12.1k | UInt32 scale) { | 151 | 12.1k | static_assert(IsDecimalNumber<T>); | 152 | | if constexpr (!std::is_same_v<DecimalV2Value, T>) { | 153 | | // DecimalV3: uses the caller-supplied precision and scale. | 154 | | // When called from from_olap_string with ignore_scale=true, scale=0 means the | 155 | | // string is treated as an unscaled integer (e.g. "12345" → internal int 12345). | 156 | | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 157 | | x.value = StringParser::string_to_decimal<P>(buf.data, (int)buf.size, precision, scale, | 158 | | &result); | 159 | | return result; | 160 | 12.1k | } else { | 161 | | // DecimalV2: IGNORES the caller-supplied precision/scale and hardcodes | 162 | | // DecimalV2Value::PRECISION (27) and DecimalV2Value::SCALE (9). | 163 | | // This means from_olap_string's ignore_scale flag has no actual effect on DecimalV2 | 164 | | // parsing today — the string "123.456000000" is always parsed with scale=9. | 165 | | // Callers should still set ignore_scale=false for DecimalV2 for semantic correctness. | 166 | 12.1k | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 167 | 12.1k | x = DecimalV2Value(StringParser::string_to_decimal<TYPE_DECIMALV2>( | 168 | 12.1k | buf.data, (int)buf.size, DecimalV2Value::PRECISION, DecimalV2Value::SCALE, | 169 | 12.1k | &result)); | 170 | 12.1k | return result; | 171 | 12.1k | } | 172 | 12.1k | } |
_ZN5doris22read_decimal_text_implILNS_13PrimitiveTypeE35ENS_7DecimalIN4wide7integerILm256EiEEEEEENS_12StringParser11ParseResultERT0_RKNS_9StringRefEjj Line | Count | Source | 150 | 129k | UInt32 scale) { | 151 | 129k | static_assert(IsDecimalNumber<T>); | 152 | 129k | if constexpr (!std::is_same_v<DecimalV2Value, T>) { | 153 | | // DecimalV3: uses the caller-supplied precision and scale. | 154 | | // When called from from_olap_string with ignore_scale=true, scale=0 means the | 155 | | // string is treated as an unscaled integer (e.g. "12345" → internal int 12345). | 156 | 129k | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 157 | 129k | x.value = StringParser::string_to_decimal<P>(buf.data, (int)buf.size, precision, scale, | 158 | 129k | &result); | 159 | 129k | return result; | 160 | | } else { | 161 | | // DecimalV2: IGNORES the caller-supplied precision/scale and hardcodes | 162 | | // DecimalV2Value::PRECISION (27) and DecimalV2Value::SCALE (9). | 163 | | // This means from_olap_string's ignore_scale flag has no actual effect on DecimalV2 | 164 | | // parsing today — the string "123.456000000" is always parsed with scale=9. | 165 | | // Callers should still set ignore_scale=false for DecimalV2 for semantic correctness. | 166 | | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 167 | | x = DecimalV2Value(StringParser::string_to_decimal<TYPE_DECIMALV2>( | 168 | | buf.data, (int)buf.size, DecimalV2Value::PRECISION, DecimalV2Value::SCALE, | 169 | | &result)); | 170 | | return result; | 171 | | } | 172 | 129k | } |
|
173 | | |
174 | | template <typename T> |
175 | 3.79k | const char* try_read_first_int_text(T& x, const char* pos, const char* end) { |
176 | 3.79k | const int64_t len = end - pos; |
177 | 3.79k | int64_t i = 0; |
178 | 7.74k | while (i < len) { |
179 | 7.74k | if (pos[i] >= '0' && pos[i] <= '9') { |
180 | 3.94k | i++; |
181 | 3.94k | } else { |
182 | 3.79k | break; |
183 | 3.79k | } |
184 | 7.74k | } |
185 | 3.79k | const char* int_end = pos + i; |
186 | 3.79k | StringRef in((char*)pos, int_end - pos); |
187 | 3.79k | const size_t count = in.size; |
188 | 3.79k | try_read_int_text(x, in); |
189 | 3.79k | return pos + count; |
190 | 3.79k | } _ZN5doris23try_read_first_int_textImEEPKcRT_S2_S2_ Line | Count | Source | 175 | 3.79k | const char* try_read_first_int_text(T& x, const char* pos, const char* end) { | 176 | 3.79k | const int64_t len = end - pos; | 177 | 3.79k | int64_t i = 0; | 178 | 7.74k | while (i < len) { | 179 | 7.74k | if (pos[i] >= '0' && pos[i] <= '9') { | 180 | 3.94k | i++; | 181 | 3.94k | } else { | 182 | 3.79k | break; | 183 | 3.79k | } | 184 | 7.74k | } | 185 | 3.79k | const char* int_end = pos + i; | 186 | 3.79k | StringRef in((char*)pos, int_end - pos); | 187 | 3.79k | const size_t count = in.size; | 188 | 3.79k | try_read_int_text(x, in); | 189 | 3.79k | return pos + count; | 190 | 3.79k | } |
Unexecuted instantiation: _ZN5doris23try_read_first_int_textIjEEPKcRT_S2_S2_ |
191 | | |
192 | | template <PrimitiveType P, typename T> |
193 | | StringParser::ParseResult try_read_decimal_text(T& x, const StringRef& in, UInt32 precision, |
194 | 17.3M | UInt32 scale) { |
195 | 17.3M | return read_decimal_text_impl<P, T>(x, in, precision, scale); |
196 | 17.3M | } _ZN5doris21try_read_decimal_textILNS_13PrimitiveTypeE28ENS_7DecimalIiEEEENS_12StringParser11ParseResultERT0_RKNS_9StringRefEjj Line | Count | Source | 194 | 306k | UInt32 scale) { | 195 | 306k | return read_decimal_text_impl<P, T>(x, in, precision, scale); | 196 | 306k | } |
_ZN5doris21try_read_decimal_textILNS_13PrimitiveTypeE29ENS_7DecimalIlEEEENS_12StringParser11ParseResultERT0_RKNS_9StringRefEjj Line | Count | Source | 194 | 15.0M | UInt32 scale) { | 195 | 15.0M | return read_decimal_text_impl<P, T>(x, in, precision, scale); | 196 | 15.0M | } |
_ZN5doris21try_read_decimal_textILNS_13PrimitiveTypeE30ENS_12Decimal128V3EEENS_12StringParser11ParseResultERT0_RKNS_9StringRefEjj Line | Count | Source | 194 | 2.02M | UInt32 scale) { | 195 | 2.02M | return read_decimal_text_impl<P, T>(x, in, precision, scale); | 196 | 2.02M | } |
_ZN5doris21try_read_decimal_textILNS_13PrimitiveTypeE20ENS_14DecimalV2ValueEEENS_12StringParser11ParseResultERT0_RKNS_9StringRefEjj Line | Count | Source | 194 | 47 | UInt32 scale) { | 195 | 47 | return read_decimal_text_impl<P, T>(x, in, precision, scale); | 196 | 47 | } |
_ZN5doris21try_read_decimal_textILNS_13PrimitiveTypeE35ENS_7DecimalIN4wide7integerILm256EiEEEEEENS_12StringParser11ParseResultERT0_RKNS_9StringRefEjj Line | Count | Source | 194 | 41.9k | UInt32 scale) { | 195 | 41.9k | return read_decimal_text_impl<P, T>(x, in, precision, scale); | 196 | 41.9k | } |
|
197 | | |
198 | | template <typename T> |
199 | | bool try_read_ipv4_text(T& x, const StringRef& in) { |
200 | | return read_ipv4_text_impl<T>(x, in); |
201 | | } |
202 | | |
203 | | template <typename T> |
204 | | bool try_read_ipv6_text(T& x, const StringRef& in) { |
205 | | return read_ipv6_text_impl<T>(x, in); |
206 | | } |
207 | | |
208 | | template <typename T> |
209 | | bool try_read_datetime_text(T& x, const StringRef& in, const cctz::time_zone& local_time_zone) { |
210 | | return read_datetime_text_impl<T>(x, in, local_time_zone); |
211 | | } |
212 | | |
213 | | template <typename T> |
214 | | bool try_read_date_text(T& x, const StringRef& in, const cctz::time_zone& local_time_zone) { |
215 | | return read_date_text_impl<T>(x, in, local_time_zone); |
216 | | } |
217 | | |
218 | | template <typename T> |
219 | | bool try_read_date_v2_text(T& x, const StringRef& in, const cctz::time_zone& local_time_zone) { |
220 | | return read_date_v2_text_impl<T>(x, in, local_time_zone); |
221 | | } |
222 | | |
223 | | template <typename T> |
224 | | bool try_read_datetime_v2_text(T& x, const StringRef& in, const cctz::time_zone& local_time_zone, |
225 | | UInt32 scale) { |
226 | | return read_datetime_v2_text_impl<T>(x, in, local_time_zone, scale); |
227 | | } |
228 | | |
229 | 1.26M | bool inline try_read_bool_text(UInt8& x, const StringRef& buf) { |
230 | 1.26M | StringParser::ParseResult result; |
231 | 1.26M | x = StringParser::string_to_bool(buf.data, buf.size, &result); |
232 | 1.26M | return result == StringParser::PARSE_SUCCESS; |
233 | 1.26M | } |
234 | | |
235 | | #include "common/compile_check_end.h" |
236 | | |
237 | | } // namespace doris |