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 | 320 | inline std::string int128_to_string(int128_t value) { |
43 | 320 | return fmt::format(FMT_COMPILE("{}"), value); |
44 | 320 | } |
45 | | |
46 | 0 | inline std::string int128_to_string(uint128_t value) { |
47 | 0 | return fmt::format(FMT_COMPILE("{}"), value); |
48 | 0 | } |
49 | | |
50 | 0 | inline std::string int128_to_string(UInt128 value) { |
51 | 0 | return value.to_hex_string(); |
52 | 0 | } |
53 | | |
54 | | template <typename T> |
55 | | void write_text(Decimal<T> value, UInt32 scale, std::ostream& ostr) { |
56 | | if (value < Decimal<T>(0)) { |
57 | | value *= Decimal<T>(-1); |
58 | | if (value > Decimal<T>(0)) { |
59 | | ostr << '-'; |
60 | | } |
61 | | } |
62 | | |
63 | | T whole_part = value; |
64 | | |
65 | | if (scale) { |
66 | | whole_part = value / decimal_scale_multiplier<T>(scale); |
67 | | } |
68 | | if constexpr (std::is_same_v<T, __int128_t>) { |
69 | | ostr << int128_to_string(whole_part); |
70 | | } else { |
71 | | ostr << whole_part; |
72 | | } |
73 | | if (scale) { |
74 | | ostr << '.'; |
75 | | String str_fractional(scale, '0'); |
76 | | Int32 pos = scale - 1; |
77 | | if (value < Decimal<T>(0) && pos >= 0) { |
78 | | // Reach here iff this value is a min value of a signed numeric type. It means min<int>() |
79 | | // which is -2147483648 multiply -1 is still -2147483648. |
80 | | str_fractional[pos] += (value / 10 * 10) - value; |
81 | | pos--; |
82 | | value /= 10; |
83 | | value *= Decimal<T>(-1); |
84 | | } |
85 | | for (; pos >= 0; --pos, value /= 10) { |
86 | | str_fractional[pos] += value % 10; |
87 | | } |
88 | | ostr.write(str_fractional.data(), scale); |
89 | | } |
90 | | } |
91 | | |
92 | | template <typename T> |
93 | 4.55M | bool try_read_float_text(T& x, const StringRef& in) { |
94 | 4.55M | static_assert(std::is_same_v<T, double> || std::is_same_v<T, float>, |
95 | 4.55M | "Argument for readFloatTextImpl must be float or double"); |
96 | 4.55M | static_assert('a' > '.' && 'A' > '.' && '\n' < '.' && '\t' < '.' && '\'' < '.' && '"' < '.', |
97 | 4.55M | "Layout of char is not like ASCII"); //-V590 |
98 | | |
99 | 4.55M | StringParser::ParseResult result; |
100 | 4.55M | x = StringParser::string_to_float<T>(in.data, in.size, &result); |
101 | | |
102 | 4.55M | return result == StringParser::PARSE_SUCCESS; |
103 | 4.55M | } _ZN5doris19try_read_float_textIfEEbRT_RKNS_9StringRefE Line | Count | Source | 93 | 1.55M | bool try_read_float_text(T& x, const StringRef& in) { | 94 | 1.55M | static_assert(std::is_same_v<T, double> || std::is_same_v<T, float>, | 95 | 1.55M | "Argument for readFloatTextImpl must be float or double"); | 96 | 1.55M | static_assert('a' > '.' && 'A' > '.' && '\n' < '.' && '\t' < '.' && '\'' < '.' && '"' < '.', | 97 | 1.55M | "Layout of char is not like ASCII"); //-V590 | 98 | | | 99 | 1.55M | StringParser::ParseResult result; | 100 | 1.55M | x = StringParser::string_to_float<T>(in.data, in.size, &result); | 101 | | | 102 | 1.55M | return result == StringParser::PARSE_SUCCESS; | 103 | 1.55M | } |
_ZN5doris19try_read_float_textIdEEbRT_RKNS_9StringRefE Line | Count | Source | 93 | 2.99M | bool try_read_float_text(T& x, const StringRef& in) { | 94 | 2.99M | static_assert(std::is_same_v<T, double> || std::is_same_v<T, float>, | 95 | 2.99M | "Argument for readFloatTextImpl must be float or double"); | 96 | 2.99M | static_assert('a' > '.' && 'A' > '.' && '\n' < '.' && '\t' < '.' && '\'' < '.' && '"' < '.', | 97 | 2.99M | "Layout of char is not like ASCII"); //-V590 | 98 | | | 99 | 2.99M | StringParser::ParseResult result; | 100 | 2.99M | x = StringParser::string_to_float<T>(in.data, in.size, &result); | 101 | | | 102 | 2.99M | return result == StringParser::PARSE_SUCCESS; | 103 | 2.99M | } |
|
104 | | |
105 | | template <typename T, bool enable_strict_mode = false> |
106 | 137M | bool try_read_int_text(T& x, const StringRef& buf) { |
107 | 137M | StringParser::ParseResult result; |
108 | 137M | x = StringParser::string_to_int<T, enable_strict_mode>(buf.data, buf.size, &result); |
109 | | |
110 | 137M | return result == StringParser::PARSE_SUCCESS; |
111 | 137M | } _ZN5doris17try_read_int_textInLb0EEEbRT_RKNS_9StringRefE Line | Count | Source | 106 | 1.04M | bool try_read_int_text(T& x, const StringRef& buf) { | 107 | 1.04M | StringParser::ParseResult result; | 108 | 1.04M | x = StringParser::string_to_int<T, enable_strict_mode>(buf.data, buf.size, &result); | 109 | | | 110 | 1.04M | return result == StringParser::PARSE_SUCCESS; | 111 | 1.04M | } |
_ZN5doris17try_read_int_textIaLb1EEEbRT_RKNS_9StringRefE Line | Count | Source | 106 | 2.04k | bool try_read_int_text(T& x, const StringRef& buf) { | 107 | 2.04k | StringParser::ParseResult result; | 108 | 2.04k | x = StringParser::string_to_int<T, enable_strict_mode>(buf.data, buf.size, &result); | 109 | | | 110 | 2.04k | return result == StringParser::PARSE_SUCCESS; | 111 | 2.04k | } |
_ZN5doris17try_read_int_textIsLb1EEEbRT_RKNS_9StringRefE Line | Count | Source | 106 | 2.09k | bool try_read_int_text(T& x, const StringRef& buf) { | 107 | 2.09k | StringParser::ParseResult result; | 108 | 2.09k | x = StringParser::string_to_int<T, enable_strict_mode>(buf.data, buf.size, &result); | 109 | | | 110 | 2.09k | return result == StringParser::PARSE_SUCCESS; | 111 | 2.09k | } |
_ZN5doris17try_read_int_textIiLb1EEEbRT_RKNS_9StringRefE Line | Count | Source | 106 | 3.90k | bool try_read_int_text(T& x, const StringRef& buf) { | 107 | 3.90k | StringParser::ParseResult result; | 108 | 3.90k | x = StringParser::string_to_int<T, enable_strict_mode>(buf.data, buf.size, &result); | 109 | | | 110 | 3.90k | return result == StringParser::PARSE_SUCCESS; | 111 | 3.90k | } |
_ZN5doris17try_read_int_textIlLb1EEEbRT_RKNS_9StringRefE Line | Count | Source | 106 | 2.59k | bool try_read_int_text(T& x, const StringRef& buf) { | 107 | 2.59k | StringParser::ParseResult result; | 108 | 2.59k | x = StringParser::string_to_int<T, enable_strict_mode>(buf.data, buf.size, &result); | 109 | | | 110 | 2.59k | return result == StringParser::PARSE_SUCCESS; | 111 | 2.59k | } |
_ZN5doris17try_read_int_textInLb1EEEbRT_RKNS_9StringRefE Line | Count | Source | 106 | 1.85k | bool try_read_int_text(T& x, const StringRef& buf) { | 107 | 1.85k | StringParser::ParseResult result; | 108 | 1.85k | x = StringParser::string_to_int<T, enable_strict_mode>(buf.data, buf.size, &result); | 109 | | | 110 | 1.85k | return result == StringParser::PARSE_SUCCESS; | 111 | 1.85k | } |
_ZN5doris17try_read_int_textIaLb0EEEbRT_RKNS_9StringRefE Line | Count | Source | 106 | 9.01M | bool try_read_int_text(T& x, const StringRef& buf) { | 107 | 9.01M | StringParser::ParseResult result; | 108 | 9.01M | x = StringParser::string_to_int<T, enable_strict_mode>(buf.data, buf.size, &result); | 109 | | | 110 | 9.01M | return result == StringParser::PARSE_SUCCESS; | 111 | 9.01M | } |
_ZN5doris17try_read_int_textIsLb0EEEbRT_RKNS_9StringRefE Line | Count | Source | 106 | 1.17M | bool try_read_int_text(T& x, const StringRef& buf) { | 107 | 1.17M | StringParser::ParseResult result; | 108 | 1.17M | x = StringParser::string_to_int<T, enable_strict_mode>(buf.data, buf.size, &result); | 109 | | | 110 | 1.17M | return result == StringParser::PARSE_SUCCESS; | 111 | 1.17M | } |
_ZN5doris17try_read_int_textIiLb0EEEbRT_RKNS_9StringRefE Line | Count | Source | 106 | 55.5M | bool try_read_int_text(T& x, const StringRef& buf) { | 107 | 55.5M | StringParser::ParseResult result; | 108 | 55.5M | x = StringParser::string_to_int<T, enable_strict_mode>(buf.data, buf.size, &result); | 109 | | | 110 | 55.5M | return result == StringParser::PARSE_SUCCESS; | 111 | 55.5M | } |
_ZN5doris17try_read_int_textIlLb0EEEbRT_RKNS_9StringRefE Line | Count | Source | 106 | 70.4M | bool try_read_int_text(T& x, const StringRef& buf) { | 107 | 70.4M | StringParser::ParseResult result; | 108 | 70.4M | x = StringParser::string_to_int<T, enable_strict_mode>(buf.data, buf.size, &result); | 109 | | | 110 | 70.4M | return result == StringParser::PARSE_SUCCESS; | 111 | 70.4M | } |
Unexecuted instantiation: _ZN5doris17try_read_int_textIjLb0EEEbRT_RKNS_9StringRefE _ZN5doris17try_read_int_textImLb0EEEbRT_RKNS_9StringRefE Line | Count | Source | 106 | 3.49k | bool try_read_int_text(T& x, const StringRef& buf) { | 107 | 3.49k | StringParser::ParseResult result; | 108 | 3.49k | x = StringParser::string_to_int<T, enable_strict_mode>(buf.data, buf.size, &result); | 109 | | | 110 | 3.49k | return result == StringParser::PARSE_SUCCESS; | 111 | 3.49k | } |
|
112 | | |
113 | | bool read_date_text_impl(VecDateTimeValue& x, const StringRef& buf); |
114 | | |
115 | | bool read_date_text_impl(Int64& x, const StringRef& buf, const cctz::time_zone& local_time_zone); |
116 | | |
117 | | template <typename T> |
118 | 82.9k | bool read_ipv4_text_impl(T& x, const StringRef& buf) { |
119 | 82.9k | static_assert(std::is_same_v<IPv4, T>); |
120 | 82.9k | bool res = IPv4Value::from_string(x, buf.data, buf.size); |
121 | 82.9k | return res; |
122 | 82.9k | } |
123 | | |
124 | | template <typename T> |
125 | 59.7k | bool read_ipv6_text_impl(T& x, const StringRef& buf) { |
126 | 59.7k | static_assert(std::is_same_v<IPv6, T>); |
127 | 59.7k | bool res = IPv6Value::from_string(x, buf.data, buf.size); |
128 | 59.7k | return res; |
129 | 59.7k | } |
130 | | |
131 | | bool read_datetime_text_impl(VecDateTimeValue& x, const StringRef& buf); |
132 | | |
133 | | bool read_datetime_text_impl(Int64& x, const StringRef& buf, |
134 | | const cctz::time_zone& local_time_zone); |
135 | | |
136 | | bool read_date_v2_text_impl(DateV2Value<DateV2ValueType>& x, const StringRef& buf); |
137 | | |
138 | | bool read_date_v2_text_impl(DateV2Value<DateV2ValueType>& x, const StringRef& buf, |
139 | | const cctz::time_zone& local_time_zone); |
140 | | |
141 | | bool read_datetime_v2_text_impl(DateV2Value<DateTimeV2ValueType>& x, const StringRef& buf, |
142 | | UInt32 scale = -1); |
143 | | |
144 | | bool read_datetime_v2_text_impl(DateV2Value<DateTimeV2ValueType>& x, const StringRef& buf, |
145 | | const cctz::time_zone& local_time_zone, UInt32 scale = -1); |
146 | | |
147 | | template <PrimitiveType P, typename T> |
148 | | StringParser::ParseResult read_decimal_text_impl(T& x, const StringRef& buf, UInt32 precision, |
149 | 21.0M | UInt32 scale) { |
150 | 21.0M | static_assert(IsDecimalNumber<T>); |
151 | 21.0M | if constexpr (!std::is_same_v<DecimalV2Value, T>) { |
152 | | // DecimalV3: uses the caller-supplied precision and scale. |
153 | | // When called from from_olap_string with ignore_scale=true, scale=0 means the |
154 | | // string is treated as an unscaled integer (e.g. "12345" → internal int 12345). |
155 | 20.9M | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; |
156 | 20.9M | x.value = StringParser::string_to_decimal<P>(buf.data, (int)buf.size, precision, scale, |
157 | 20.9M | &result); |
158 | 20.9M | return result; |
159 | 20.9M | } else { |
160 | | // DecimalV2: IGNORES the caller-supplied precision/scale and hardcodes |
161 | | // DecimalV2Value::PRECISION (27) and DecimalV2Value::SCALE (9). |
162 | | // This means from_olap_string's ignore_scale flag has no actual effect on DecimalV2 |
163 | | // parsing today — the string "123.456000000" is always parsed with scale=9. |
164 | | // Callers should still set ignore_scale=false for DecimalV2 for semantic correctness. |
165 | 12.2k | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; |
166 | 12.2k | x = DecimalV2Value(StringParser::string_to_decimal<TYPE_DECIMALV2>( |
167 | 12.2k | buf.data, (int)buf.size, DecimalV2Value::PRECISION, DecimalV2Value::SCALE, |
168 | 12.2k | &result)); |
169 | 12.2k | return result; |
170 | 12.2k | } |
171 | 21.0M | } _ZN5doris22read_decimal_text_implILNS_13PrimitiveTypeE28ENS_7DecimalIiEEEENS_12StringParser11ParseResultERT0_RKNS_9StringRefEjj Line | Count | Source | 149 | 2.02M | UInt32 scale) { | 150 | 2.02M | static_assert(IsDecimalNumber<T>); | 151 | 2.02M | if constexpr (!std::is_same_v<DecimalV2Value, T>) { | 152 | | // DecimalV3: uses the caller-supplied precision and scale. | 153 | | // When called from from_olap_string with ignore_scale=true, scale=0 means the | 154 | | // string is treated as an unscaled integer (e.g. "12345" → internal int 12345). | 155 | 2.02M | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 156 | 2.02M | x.value = StringParser::string_to_decimal<P>(buf.data, (int)buf.size, precision, scale, | 157 | 2.02M | &result); | 158 | 2.02M | return result; | 159 | | } else { | 160 | | // DecimalV2: IGNORES the caller-supplied precision/scale and hardcodes | 161 | | // DecimalV2Value::PRECISION (27) and DecimalV2Value::SCALE (9). | 162 | | // This means from_olap_string's ignore_scale flag has no actual effect on DecimalV2 | 163 | | // parsing today — the string "123.456000000" is always parsed with scale=9. | 164 | | // Callers should still set ignore_scale=false for DecimalV2 for semantic correctness. | 165 | | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 166 | | x = DecimalV2Value(StringParser::string_to_decimal<TYPE_DECIMALV2>( | 167 | | buf.data, (int)buf.size, DecimalV2Value::PRECISION, DecimalV2Value::SCALE, | 168 | | &result)); | 169 | | return result; | 170 | | } | 171 | 2.02M | } |
_ZN5doris22read_decimal_text_implILNS_13PrimitiveTypeE29ENS_7DecimalIlEEEENS_12StringParser11ParseResultERT0_RKNS_9StringRefEjj Line | Count | Source | 149 | 16.1M | UInt32 scale) { | 150 | 16.1M | static_assert(IsDecimalNumber<T>); | 151 | 16.1M | if constexpr (!std::is_same_v<DecimalV2Value, T>) { | 152 | | // DecimalV3: uses the caller-supplied precision and scale. | 153 | | // When called from from_olap_string with ignore_scale=true, scale=0 means the | 154 | | // string is treated as an unscaled integer (e.g. "12345" → internal int 12345). | 155 | 16.1M | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 156 | 16.1M | x.value = StringParser::string_to_decimal<P>(buf.data, (int)buf.size, precision, scale, | 157 | 16.1M | &result); | 158 | 16.1M | return result; | 159 | | } else { | 160 | | // DecimalV2: IGNORES the caller-supplied precision/scale and hardcodes | 161 | | // DecimalV2Value::PRECISION (27) and DecimalV2Value::SCALE (9). | 162 | | // This means from_olap_string's ignore_scale flag has no actual effect on DecimalV2 | 163 | | // parsing today — the string "123.456000000" is always parsed with scale=9. | 164 | | // Callers should still set ignore_scale=false for DecimalV2 for semantic correctness. | 165 | | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 166 | | x = DecimalV2Value(StringParser::string_to_decimal<TYPE_DECIMALV2>( | 167 | | buf.data, (int)buf.size, DecimalV2Value::PRECISION, DecimalV2Value::SCALE, | 168 | | &result)); | 169 | | return result; | 170 | | } | 171 | 16.1M | } |
_ZN5doris22read_decimal_text_implILNS_13PrimitiveTypeE30ENS_12Decimal128V3EEENS_12StringParser11ParseResultERT0_RKNS_9StringRefEjj Line | Count | Source | 149 | 2.68M | UInt32 scale) { | 150 | 2.68M | static_assert(IsDecimalNumber<T>); | 151 | 2.68M | if constexpr (!std::is_same_v<DecimalV2Value, T>) { | 152 | | // DecimalV3: uses the caller-supplied precision and scale. | 153 | | // When called from from_olap_string with ignore_scale=true, scale=0 means the | 154 | | // string is treated as an unscaled integer (e.g. "12345" → internal int 12345). | 155 | 2.68M | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 156 | 2.68M | x.value = StringParser::string_to_decimal<P>(buf.data, (int)buf.size, precision, scale, | 157 | 2.68M | &result); | 158 | 2.68M | return result; | 159 | | } else { | 160 | | // DecimalV2: IGNORES the caller-supplied precision/scale and hardcodes | 161 | | // DecimalV2Value::PRECISION (27) and DecimalV2Value::SCALE (9). | 162 | | // This means from_olap_string's ignore_scale flag has no actual effect on DecimalV2 | 163 | | // parsing today — the string "123.456000000" is always parsed with scale=9. | 164 | | // Callers should still set ignore_scale=false for DecimalV2 for semantic correctness. | 165 | | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 166 | | x = DecimalV2Value(StringParser::string_to_decimal<TYPE_DECIMALV2>( | 167 | | buf.data, (int)buf.size, DecimalV2Value::PRECISION, DecimalV2Value::SCALE, | 168 | | &result)); | 169 | | return result; | 170 | | } | 171 | 2.68M | } |
_ZN5doris22read_decimal_text_implILNS_13PrimitiveTypeE20ENS_14DecimalV2ValueEEENS_12StringParser11ParseResultERT0_RKNS_9StringRefEjj Line | Count | Source | 149 | 12.2k | UInt32 scale) { | 150 | 12.2k | static_assert(IsDecimalNumber<T>); | 151 | | if constexpr (!std::is_same_v<DecimalV2Value, T>) { | 152 | | // DecimalV3: uses the caller-supplied precision and scale. | 153 | | // When called from from_olap_string with ignore_scale=true, scale=0 means the | 154 | | // string is treated as an unscaled integer (e.g. "12345" → internal int 12345). | 155 | | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 156 | | x.value = StringParser::string_to_decimal<P>(buf.data, (int)buf.size, precision, scale, | 157 | | &result); | 158 | | return result; | 159 | 12.2k | } else { | 160 | | // DecimalV2: IGNORES the caller-supplied precision/scale and hardcodes | 161 | | // DecimalV2Value::PRECISION (27) and DecimalV2Value::SCALE (9). | 162 | | // This means from_olap_string's ignore_scale flag has no actual effect on DecimalV2 | 163 | | // parsing today — the string "123.456000000" is always parsed with scale=9. | 164 | | // Callers should still set ignore_scale=false for DecimalV2 for semantic correctness. | 165 | 12.2k | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 166 | 12.2k | x = DecimalV2Value(StringParser::string_to_decimal<TYPE_DECIMALV2>( | 167 | 12.2k | buf.data, (int)buf.size, DecimalV2Value::PRECISION, DecimalV2Value::SCALE, | 168 | 12.2k | &result)); | 169 | 12.2k | return result; | 170 | 12.2k | } | 171 | 12.2k | } |
_ZN5doris22read_decimal_text_implILNS_13PrimitiveTypeE35ENS_7DecimalIN4wide7integerILm256EiEEEEEENS_12StringParser11ParseResultERT0_RKNS_9StringRefEjj Line | Count | Source | 149 | 129k | UInt32 scale) { | 150 | 129k | static_assert(IsDecimalNumber<T>); | 151 | 129k | if constexpr (!std::is_same_v<DecimalV2Value, T>) { | 152 | | // DecimalV3: uses the caller-supplied precision and scale. | 153 | | // When called from from_olap_string with ignore_scale=true, scale=0 means the | 154 | | // string is treated as an unscaled integer (e.g. "12345" → internal int 12345). | 155 | 129k | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 156 | 129k | x.value = StringParser::string_to_decimal<P>(buf.data, (int)buf.size, precision, scale, | 157 | 129k | &result); | 158 | 129k | return result; | 159 | | } else { | 160 | | // DecimalV2: IGNORES the caller-supplied precision/scale and hardcodes | 161 | | // DecimalV2Value::PRECISION (27) and DecimalV2Value::SCALE (9). | 162 | | // This means from_olap_string's ignore_scale flag has no actual effect on DecimalV2 | 163 | | // parsing today — the string "123.456000000" is always parsed with scale=9. | 164 | | // Callers should still set ignore_scale=false for DecimalV2 for semantic correctness. | 165 | | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 166 | | x = DecimalV2Value(StringParser::string_to_decimal<TYPE_DECIMALV2>( | 167 | | buf.data, (int)buf.size, DecimalV2Value::PRECISION, DecimalV2Value::SCALE, | 168 | | &result)); | 169 | | return result; | 170 | | } | 171 | 129k | } |
|
172 | | |
173 | | template <typename T> |
174 | 3.50k | const char* try_read_first_int_text(T& x, const char* pos, const char* end) { |
175 | 3.50k | const int64_t len = end - pos; |
176 | 3.50k | int64_t i = 0; |
177 | 7.10k | while (i < len) { |
178 | 7.10k | if (pos[i] >= '0' && pos[i] <= '9') { |
179 | 3.60k | i++; |
180 | 3.60k | } else { |
181 | 3.50k | break; |
182 | 3.50k | } |
183 | 7.10k | } |
184 | 3.50k | const char* int_end = pos + i; |
185 | 3.50k | StringRef in((char*)pos, int_end - pos); |
186 | 3.50k | const size_t count = in.size; |
187 | 3.50k | try_read_int_text(x, in); |
188 | 3.50k | return pos + count; |
189 | 3.50k | } _ZN5doris23try_read_first_int_textImEEPKcRT_S2_S2_ Line | Count | Source | 174 | 3.50k | const char* try_read_first_int_text(T& x, const char* pos, const char* end) { | 175 | 3.50k | const int64_t len = end - pos; | 176 | 3.50k | int64_t i = 0; | 177 | 7.10k | while (i < len) { | 178 | 7.10k | if (pos[i] >= '0' && pos[i] <= '9') { | 179 | 3.60k | i++; | 180 | 3.60k | } else { | 181 | 3.50k | break; | 182 | 3.50k | } | 183 | 7.10k | } | 184 | 3.50k | const char* int_end = pos + i; | 185 | 3.50k | StringRef in((char*)pos, int_end - pos); | 186 | 3.50k | const size_t count = in.size; | 187 | 3.50k | try_read_int_text(x, in); | 188 | 3.50k | return pos + count; | 189 | 3.50k | } |
Unexecuted instantiation: _ZN5doris23try_read_first_int_textIjEEPKcRT_S2_S2_ |
190 | | |
191 | | template <PrimitiveType P, typename T> |
192 | | StringParser::ParseResult try_read_decimal_text(T& x, const StringRef& in, UInt32 precision, |
193 | 17.3M | UInt32 scale) { |
194 | 17.3M | return read_decimal_text_impl<P, T>(x, in, precision, scale); |
195 | 17.3M | } _ZN5doris21try_read_decimal_textILNS_13PrimitiveTypeE28ENS_7DecimalIiEEEENS_12StringParser11ParseResultERT0_RKNS_9StringRefEjj Line | Count | Source | 193 | 283k | UInt32 scale) { | 194 | 283k | return read_decimal_text_impl<P, T>(x, in, precision, scale); | 195 | 283k | } |
_ZN5doris21try_read_decimal_textILNS_13PrimitiveTypeE29ENS_7DecimalIlEEEENS_12StringParser11ParseResultERT0_RKNS_9StringRefEjj Line | Count | Source | 193 | 14.9M | UInt32 scale) { | 194 | 14.9M | return read_decimal_text_impl<P, T>(x, in, precision, scale); | 195 | 14.9M | } |
_ZN5doris21try_read_decimal_textILNS_13PrimitiveTypeE30ENS_12Decimal128V3EEENS_12StringParser11ParseResultERT0_RKNS_9StringRefEjj Line | Count | Source | 193 | 2.01M | UInt32 scale) { | 194 | 2.01M | return read_decimal_text_impl<P, T>(x, in, precision, scale); | 195 | 2.01M | } |
_ZN5doris21try_read_decimal_textILNS_13PrimitiveTypeE20ENS_14DecimalV2ValueEEENS_12StringParser11ParseResultERT0_RKNS_9StringRefEjj Line | Count | Source | 193 | 143 | UInt32 scale) { | 194 | 143 | return read_decimal_text_impl<P, T>(x, in, precision, scale); | 195 | 143 | } |
_ZN5doris21try_read_decimal_textILNS_13PrimitiveTypeE35ENS_7DecimalIN4wide7integerILm256EiEEEEEENS_12StringParser11ParseResultERT0_RKNS_9StringRefEjj Line | Count | Source | 193 | 41.9k | UInt32 scale) { | 194 | 41.9k | return read_decimal_text_impl<P, T>(x, in, precision, scale); | 195 | 41.9k | } |
|
196 | | |
197 | | template <typename T> |
198 | | bool try_read_ipv4_text(T& x, const StringRef& in) { |
199 | | return read_ipv4_text_impl<T>(x, in); |
200 | | } |
201 | | |
202 | | template <typename T> |
203 | | bool try_read_ipv6_text(T& x, const StringRef& in) { |
204 | | return read_ipv6_text_impl<T>(x, in); |
205 | | } |
206 | | |
207 | | template <typename T> |
208 | | bool try_read_datetime_text(T& x, const StringRef& in, const cctz::time_zone& local_time_zone) { |
209 | | return read_datetime_text_impl<T>(x, in, local_time_zone); |
210 | | } |
211 | | |
212 | | template <typename T> |
213 | | bool try_read_date_text(T& x, const StringRef& in, const cctz::time_zone& local_time_zone) { |
214 | | return read_date_text_impl<T>(x, in, local_time_zone); |
215 | | } |
216 | | |
217 | | template <typename T> |
218 | | bool try_read_date_v2_text(T& x, const StringRef& in, const cctz::time_zone& local_time_zone) { |
219 | | return read_date_v2_text_impl<T>(x, in, local_time_zone); |
220 | | } |
221 | | |
222 | | template <typename T> |
223 | | bool try_read_datetime_v2_text(T& x, const StringRef& in, const cctz::time_zone& local_time_zone, |
224 | | UInt32 scale) { |
225 | | return read_datetime_v2_text_impl<T>(x, in, local_time_zone, scale); |
226 | | } |
227 | | |
228 | 1.26M | bool inline try_read_bool_text(UInt8& x, const StringRef& buf) { |
229 | 1.26M | StringParser::ParseResult result; |
230 | 1.26M | x = StringParser::string_to_bool(buf.data, buf.size, &result); |
231 | 1.26M | return result == StringParser::PARSE_SUCCESS; |
232 | 1.26M | } |
233 | | |
234 | | } // namespace doris |