Coverage Report

Created: 2026-07-21 21:51

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/exprs/function/parse/variant_string_parse.h
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 <array>
21
#include <cmath>
22
#include <cstddef>
23
#include <cstdint>
24
#include <memory>
25
#include <string>
26
27
#include "common/status.h"
28
#include "core/value/variant/variant_batch_builder.h"
29
#include "core/value/variant/variant_value.h"
30
31
namespace cctz {
32
class time_zone;
33
}
34
35
namespace doris {
36
37
// Formatting state supplied by the column adapter. A null time zone means UTC.
38
struct VariantJsonFormatOptions {
39
    const cctz::time_zone* timezone = nullptr;
40
};
41
42
struct JsonToVariantOptions {
43
    uint32_t max_json_key_length = 255;
44
    bool throw_on_invalid_json = false;
45
    bool check_duplicate_json_path = false;
46
47
    // Takes a value snapshot. Later changes to mutable config do not affect an encoder.
48
    static JsonToVariantOptions current_config();
49
};
50
51
// Reuses one JSON parser and one batch builder. Each add_json() collects into a stack-only row;
52
// finish_batch() performs pass 2. A failed add_json() is terminal, as is a successful
53
// finish_batch(). try_add_json() rolls back invalid input rows and keeps collecting.
54
class JsonStringToVariantEncoder {
55
public:
56
    JsonStringToVariantEncoder();
57
    explicit JsonStringToVariantEncoder(JsonToVariantOptions options);
58
    ~JsonStringToVariantEncoder();
59
60
    JsonStringToVariantEncoder(const JsonStringToVariantEncoder&) = delete;
61
    JsonStringToVariantEncoder& operator=(const JsonStringToVariantEncoder&) = delete;
62
    JsonStringToVariantEncoder(JsonStringToVariantEncoder&&) noexcept;
63
    JsonStringToVariantEncoder& operator=(JsonStringToVariantEncoder&&) noexcept;
64
65
    void add_json(StringRef json);
66
    Status try_add_json(StringRef json);
67
    VariantBatchBuilder finish_batch();
68
69
private:
70
    struct Impl;
71
    std::unique_ptr<Impl> _impl;
72
};
73
74
namespace variant_json_detail {
75
76
struct FormattedScalar {
77
    std::array<char, 128> bytes {};
78
    size_t size = 0;
79
};
80
81
void require_json_depth(uint32_t depth);
82
void require_exact_json_value(VariantRef value);
83
void require_valid_json_utf8(StringRef value, const char* description);
84
void require_json_object_key(StringRef key, StringRef previous_key, uint32_t field_index);
85
[[noreturn]] void throw_unsupported_json_primitive(VariantPrimitiveId id);
86
87
FormattedScalar format_json_int(int64_t value);
88
FormattedScalar format_json_float(float value);
89
FormattedScalar format_json_double(double value);
90
FormattedScalar format_json_decimal(VariantDecimal value);
91
FormattedScalar format_json_date(int32_t days_since_epoch);
92
FormattedScalar format_json_timestamp(int64_t value, uint8_t fractional_digits, bool utc_adjusted,
93
                                      const cctz::time_zone* timezone);
94
FormattedScalar format_json_time_micros(int64_t value);
95
FormattedScalar format_json_uuid(const std::array<uint8_t, 16>& value);
96
97
template <typename Writer, size_t N>
98
1.87k
void write_literal(Writer& out, const char (&value)[N]) {
99
1.87k
    out.write(value, N - 1);
100
1.87k
}
column_variant_v2_test.cpp:_ZN5doris19variant_json_detail13write_literalINS_12_GLOBAL__N_110JsonWriterELm2EEEvRT_RAT0__Kc
Line
Count
Source
98
547
void write_literal(Writer& out, const char (&value)[N]) {
99
547
    out.write(value, N - 1);
100
547
}
Unexecuted instantiation: column_variant_v2_test.cpp:_ZN5doris19variant_json_detail13write_literalINS_12_GLOBAL__N_110JsonWriterELm5EEEvRT_RAT0__Kc
Unexecuted instantiation: column_variant_v2_test.cpp:_ZN5doris19variant_json_detail13write_literalINS_12_GLOBAL__N_110JsonWriterELm6EEEvRT_RAT0__Kc
Unexecuted instantiation: column_variant_v2_test.cpp:_ZN5doris19variant_json_detail13write_literalINS_12_GLOBAL__N_110JsonWriterELm11EEEvRT_RAT0__Kc
Unexecuted instantiation: column_variant_v2_test.cpp:_ZN5doris19variant_json_detail13write_literalINS_12_GLOBAL__N_110JsonWriterELm12EEEvRT_RAT0__Kc
function_variant_parse_test.cpp:_ZN5doris19variant_json_detail13write_literalINS_12_GLOBAL__N_112StringWriterELm2EEEvRT_RAT0__Kc
Line
Count
Source
98
35
void write_literal(Writer& out, const char (&value)[N]) {
99
35
    out.write(value, N - 1);
100
35
}
function_variant_parse_test.cpp:_ZN5doris19variant_json_detail13write_literalINS_12_GLOBAL__N_112StringWriterELm5EEEvRT_RAT0__Kc
Line
Count
Source
98
4
void write_literal(Writer& out, const char (&value)[N]) {
99
4
    out.write(value, N - 1);
100
4
}
Unexecuted instantiation: function_variant_parse_test.cpp:_ZN5doris19variant_json_detail13write_literalINS_12_GLOBAL__N_112StringWriterELm6EEEvRT_RAT0__Kc
Unexecuted instantiation: function_variant_parse_test.cpp:_ZN5doris19variant_json_detail13write_literalINS_12_GLOBAL__N_112StringWriterELm11EEEvRT_RAT0__Kc
Unexecuted instantiation: function_variant_parse_test.cpp:_ZN5doris19variant_json_detail13write_literalINS_12_GLOBAL__N_112StringWriterELm12EEEvRT_RAT0__Kc
variant_string_parse_test.cpp:_ZN5doris19variant_json_detail13write_literalINS_12_GLOBAL__N_112StringWriterELm2EEEvRT_RAT0__Kc
Line
Count
Source
98
575
void write_literal(Writer& out, const char (&value)[N]) {
99
575
    out.write(value, N - 1);
100
575
}
variant_string_parse_test.cpp:_ZN5doris19variant_json_detail13write_literalINS_12_GLOBAL__N_112StringWriterELm5EEEvRT_RAT0__Kc
Line
Count
Source
98
9
void write_literal(Writer& out, const char (&value)[N]) {
99
9
    out.write(value, N - 1);
100
9
}
variant_string_parse_test.cpp:_ZN5doris19variant_json_detail13write_literalINS_12_GLOBAL__N_112StringWriterELm6EEEvRT_RAT0__Kc
Line
Count
Source
98
3
void write_literal(Writer& out, const char (&value)[N]) {
99
3
    out.write(value, N - 1);
100
3
}
variant_string_parse_test.cpp:_ZN5doris19variant_json_detail13write_literalINS_12_GLOBAL__N_112StringWriterELm11EEEvRT_RAT0__Kc
Line
Count
Source
98
1
void write_literal(Writer& out, const char (&value)[N]) {
99
1
    out.write(value, N - 1);
100
1
}
variant_string_parse_test.cpp:_ZN5doris19variant_json_detail13write_literalINS_12_GLOBAL__N_112StringWriterELm12EEEvRT_RAT0__Kc
Line
Count
Source
98
1
void write_literal(Writer& out, const char (&value)[N]) {
99
1
    out.write(value, N - 1);
100
1
}
_ZN5doris19variant_json_detail13write_literalINS_14BufferWritableELm2EEEvRT_RAT0__Kc
Line
Count
Source
98
170
void write_literal(Writer& out, const char (&value)[N]) {
99
170
    out.write(value, N - 1);
100
170
}
_ZN5doris19variant_json_detail13write_literalINS_14BufferWritableELm5EEEvRT_RAT0__Kc
Line
Count
Source
98
18
void write_literal(Writer& out, const char (&value)[N]) {
99
18
    out.write(value, N - 1);
100
18
}
_ZN5doris19variant_json_detail13write_literalINS_14BufferWritableELm6EEEvRT_RAT0__Kc
Line
Count
Source
98
6
void write_literal(Writer& out, const char (&value)[N]) {
99
6
    out.write(value, N - 1);
100
6
}
_ZN5doris19variant_json_detail13write_literalINS_14BufferWritableELm11EEEvRT_RAT0__Kc
Line
Count
Source
98
6
void write_literal(Writer& out, const char (&value)[N]) {
99
6
    out.write(value, N - 1);
100
6
}
_ZN5doris19variant_json_detail13write_literalINS_14BufferWritableELm12EEEvRT_RAT0__Kc
Line
Count
Source
98
6
void write_literal(Writer& out, const char (&value)[N]) {
99
6
    out.write(value, N - 1);
100
6
}
_ZN5doris19variant_json_detail13write_literalINS_35data_type_variant_v2_serde_internal14CountingWriterELm2EEEvRT_RAT0__Kc
Line
Count
Source
98
261
void write_literal(Writer& out, const char (&value)[N]) {
99
261
    out.write(value, N - 1);
100
261
}
_ZN5doris19variant_json_detail13write_literalINS_35data_type_variant_v2_serde_internal14CountingWriterELm5EEEvRT_RAT0__Kc
Line
Count
Source
98
31
void write_literal(Writer& out, const char (&value)[N]) {
99
31
    out.write(value, N - 1);
100
31
}
_ZN5doris19variant_json_detail13write_literalINS_35data_type_variant_v2_serde_internal14CountingWriterELm6EEEvRT_RAT0__Kc
Line
Count
Source
98
14
void write_literal(Writer& out, const char (&value)[N]) {
99
14
    out.write(value, N - 1);
100
14
}
_ZN5doris19variant_json_detail13write_literalINS_35data_type_variant_v2_serde_internal14CountingWriterELm11EEEvRT_RAT0__Kc
Line
Count
Source
98
14
void write_literal(Writer& out, const char (&value)[N]) {
99
14
    out.write(value, N - 1);
100
14
}
_ZN5doris19variant_json_detail13write_literalINS_35data_type_variant_v2_serde_internal14CountingWriterELm12EEEvRT_RAT0__Kc
Line
Count
Source
98
14
void write_literal(Writer& out, const char (&value)[N]) {
99
14
    out.write(value, N - 1);
100
14
}
_ZN5doris19variant_json_detail13write_literalINS_35data_type_variant_v2_serde_internal11FixedWriterELm2EEEvRT_RAT0__Kc
Line
Count
Source
98
121
void write_literal(Writer& out, const char (&value)[N]) {
99
121
    out.write(value, N - 1);
100
121
}
_ZN5doris19variant_json_detail13write_literalINS_35data_type_variant_v2_serde_internal11FixedWriterELm5EEEvRT_RAT0__Kc
Line
Count
Source
98
14
void write_literal(Writer& out, const char (&value)[N]) {
99
14
    out.write(value, N - 1);
100
14
}
_ZN5doris19variant_json_detail13write_literalINS_35data_type_variant_v2_serde_internal11FixedWriterELm6EEEvRT_RAT0__Kc
Line
Count
Source
98
8
void write_literal(Writer& out, const char (&value)[N]) {
99
8
    out.write(value, N - 1);
100
8
}
_ZN5doris19variant_json_detail13write_literalINS_35data_type_variant_v2_serde_internal11FixedWriterELm11EEEvRT_RAT0__Kc
Line
Count
Source
98
8
void write_literal(Writer& out, const char (&value)[N]) {
99
8
    out.write(value, N - 1);
100
8
}
_ZN5doris19variant_json_detail13write_literalINS_35data_type_variant_v2_serde_internal11FixedWriterELm12EEEvRT_RAT0__Kc
Line
Count
Source
98
8
void write_literal(Writer& out, const char (&value)[N]) {
99
8
    out.write(value, N - 1);
100
8
}
101
102
template <typename Writer>
103
316
void write_scalar(Writer& out, const FormattedScalar& value) {
104
316
    out.write(value.bytes.data(), value.size);
105
316
}
column_variant_v2_test.cpp:_ZN5doris19variant_json_detail12write_scalarINS_12_GLOBAL__N_110JsonWriterEEEvRT_RKNS0_15FormattedScalarE
Line
Count
Source
103
115
void write_scalar(Writer& out, const FormattedScalar& value) {
104
115
    out.write(value.bytes.data(), value.size);
105
115
}
function_variant_parse_test.cpp:_ZN5doris19variant_json_detail12write_scalarINS_12_GLOBAL__N_112StringWriterEEEvRT_RKNS0_15FormattedScalarE
Line
Count
Source
103
9
void write_scalar(Writer& out, const FormattedScalar& value) {
104
9
    out.write(value.bytes.data(), value.size);
105
9
}
variant_string_parse_test.cpp:_ZN5doris19variant_json_detail12write_scalarINS_12_GLOBAL__N_112StringWriterEEEvRT_RKNS0_15FormattedScalarE
Line
Count
Source
103
41
void write_scalar(Writer& out, const FormattedScalar& value) {
104
41
    out.write(value.bytes.data(), value.size);
105
41
}
_ZN5doris19variant_json_detail12write_scalarINS_14BufferWritableEEEvRT_RKNS0_15FormattedScalarE
Line
Count
Source
103
41
void write_scalar(Writer& out, const FormattedScalar& value) {
104
41
    out.write(value.bytes.data(), value.size);
105
41
}
_ZN5doris19variant_json_detail12write_scalarINS_35data_type_variant_v2_serde_internal14CountingWriterEEEvRT_RKNS0_15FormattedScalarE
Line
Count
Source
103
73
void write_scalar(Writer& out, const FormattedScalar& value) {
104
73
    out.write(value.bytes.data(), value.size);
105
73
}
_ZN5doris19variant_json_detail12write_scalarINS_35data_type_variant_v2_serde_internal11FixedWriterEEEvRT_RKNS0_15FormattedScalarE
Line
Count
Source
103
37
void write_scalar(Writer& out, const FormattedScalar& value) {
104
37
    out.write(value.bytes.data(), value.size);
105
37
}
106
107
template <typename Writer>
108
75
void write_quoted_scalar(Writer& out, const FormattedScalar& value) {
109
75
    write_literal(out, "\"");
110
75
    write_scalar(out, value);
111
75
    write_literal(out, "\"");
112
75
}
Unexecuted instantiation: column_variant_v2_test.cpp:_ZN5doris19variant_json_detail19write_quoted_scalarINS_12_GLOBAL__N_110JsonWriterEEEvRT_RKNS0_15FormattedScalarE
Unexecuted instantiation: function_variant_parse_test.cpp:_ZN5doris19variant_json_detail19write_quoted_scalarINS_12_GLOBAL__N_112StringWriterEEEvRT_RKNS0_15FormattedScalarE
variant_string_parse_test.cpp:_ZN5doris19variant_json_detail19write_quoted_scalarINS_12_GLOBAL__N_112StringWriterEEEvRT_RKNS0_15FormattedScalarE
Line
Count
Source
108
13
void write_quoted_scalar(Writer& out, const FormattedScalar& value) {
109
13
    write_literal(out, "\"");
110
13
    write_scalar(out, value);
111
13
    write_literal(out, "\"");
112
13
}
_ZN5doris19variant_json_detail19write_quoted_scalarINS_14BufferWritableEEEvRT_RKNS0_15FormattedScalarE
Line
Count
Source
108
14
void write_quoted_scalar(Writer& out, const FormattedScalar& value) {
109
14
    write_literal(out, "\"");
110
14
    write_scalar(out, value);
111
14
    write_literal(out, "\"");
112
14
}
_ZN5doris19variant_json_detail19write_quoted_scalarINS_35data_type_variant_v2_serde_internal14CountingWriterEEEvRT_RKNS0_15FormattedScalarE
Line
Count
Source
108
30
void write_quoted_scalar(Writer& out, const FormattedScalar& value) {
109
30
    write_literal(out, "\"");
110
30
    write_scalar(out, value);
111
30
    write_literal(out, "\"");
112
30
}
_ZN5doris19variant_json_detail19write_quoted_scalarINS_35data_type_variant_v2_serde_internal11FixedWriterEEEvRT_RKNS0_15FormattedScalarE
Line
Count
Source
108
18
void write_quoted_scalar(Writer& out, const FormattedScalar& value) {
109
18
    write_literal(out, "\"");
110
18
    write_scalar(out, value);
111
18
    write_literal(out, "\"");
112
18
}
113
114
template <typename Writer>
115
258
void write_escaped_json_string(Writer& out, StringRef value) {
116
258
    write_literal(out, "\"");
117
258
    size_t plain_begin = 0;
118
258
    size_t index = 0;
119
1.07k
    while (index < value.size) {
120
820
        const auto byte = static_cast<uint8_t>(value.data[index]);
121
820
        const char* escaped = nullptr;
122
820
        size_t escaped_size = 0;
123
820
        size_t consumed = 1;
124
820
        switch (byte) {
125
91
        case '"':
126
91
            escaped = "\\\"";
127
91
            escaped_size = 2;
128
91
            break;
129
3
        case '\\':
130
3
            escaped = "\\\\";
131
3
            escaped_size = 2;
132
3
            break;
133
0
        case '\b':
134
0
            escaped = "\\b";
135
0
            escaped_size = 2;
136
0
            break;
137
0
        case '\f':
138
0
            escaped = "\\f";
139
0
            escaped_size = 2;
140
0
            break;
141
31
        case '\n':
142
31
            escaped = "\\n";
143
31
            escaped_size = 2;
144
31
            break;
145
0
        case '\r':
146
0
            escaped = "\\r";
147
0
            escaped_size = 2;
148
0
            break;
149
1
        case '\t':
150
1
            escaped = "\\t";
151
1
            escaped_size = 2;
152
1
            break;
153
694
        default:
154
694
            if (byte < 0x20) {
155
0
                static constexpr char HEX[] = "0123456789ABCDEF";
156
0
                char unicode_escape[] = {'\\', 'u', '0', '0', HEX[byte >> 4], HEX[byte & 0x0F]};
157
0
                if (index != plain_begin) {
158
0
                    out.write(value.data + plain_begin, index - plain_begin);
159
0
                }
160
0
                out.write(unicode_escape, sizeof(unicode_escape));
161
0
                ++index;
162
0
                plain_begin = index;
163
0
                continue;
164
0
            }
165
694
            if (index + 2 < value.size && byte == 0xE2 &&
166
694
                static_cast<uint8_t>(value.data[index + 1]) == 0x80 &&
167
694
                (static_cast<uint8_t>(value.data[index + 2]) == 0xA8 ||
168
1
                 static_cast<uint8_t>(value.data[index + 2]) == 0xA9)) {
169
1
                escaped =
170
1
                        static_cast<uint8_t>(value.data[index + 2]) == 0xA8 ? "\\u2028" : "\\u2029";
171
1
                escaped_size = 6;
172
1
                consumed = 3;
173
1
            }
174
694
            break;
175
820
        }
176
820
        if (escaped == nullptr) {
177
693
            ++index;
178
693
            continue;
179
693
        }
180
127
        if (index != plain_begin) {
181
96
            out.write(value.data + plain_begin, index - plain_begin);
182
96
        }
183
127
        out.write(escaped, escaped_size);
184
127
        index += consumed;
185
127
        plain_begin = index;
186
127
    }
187
258
    if (plain_begin != value.size) {
188
229
        out.write(value.data + plain_begin, value.size - plain_begin);
189
229
    }
190
258
    write_literal(out, "\"");
191
258
}
column_variant_v2_test.cpp:_ZN5doris19variant_json_detail25write_escaped_json_stringINS_12_GLOBAL__N_110JsonWriterEEEvRT_NS_9StringRefE
Line
Count
Source
115
93
void write_escaped_json_string(Writer& out, StringRef value) {
116
93
    write_literal(out, "\"");
117
93
    size_t plain_begin = 0;
118
93
    size_t index = 0;
119
186
    while (index < value.size) {
120
93
        const auto byte = static_cast<uint8_t>(value.data[index]);
121
93
        const char* escaped = nullptr;
122
93
        size_t escaped_size = 0;
123
93
        size_t consumed = 1;
124
93
        switch (byte) {
125
0
        case '"':
126
0
            escaped = "\\\"";
127
0
            escaped_size = 2;
128
0
            break;
129
0
        case '\\':
130
0
            escaped = "\\\\";
131
0
            escaped_size = 2;
132
0
            break;
133
0
        case '\b':
134
0
            escaped = "\\b";
135
0
            escaped_size = 2;
136
0
            break;
137
0
        case '\f':
138
0
            escaped = "\\f";
139
0
            escaped_size = 2;
140
0
            break;
141
0
        case '\n':
142
0
            escaped = "\\n";
143
0
            escaped_size = 2;
144
0
            break;
145
0
        case '\r':
146
0
            escaped = "\\r";
147
0
            escaped_size = 2;
148
0
            break;
149
0
        case '\t':
150
0
            escaped = "\\t";
151
0
            escaped_size = 2;
152
0
            break;
153
93
        default:
154
93
            if (byte < 0x20) {
155
0
                static constexpr char HEX[] = "0123456789ABCDEF";
156
0
                char unicode_escape[] = {'\\', 'u', '0', '0', HEX[byte >> 4], HEX[byte & 0x0F]};
157
0
                if (index != plain_begin) {
158
0
                    out.write(value.data + plain_begin, index - plain_begin);
159
0
                }
160
0
                out.write(unicode_escape, sizeof(unicode_escape));
161
0
                ++index;
162
0
                plain_begin = index;
163
0
                continue;
164
0
            }
165
93
            if (index + 2 < value.size && byte == 0xE2 &&
166
93
                static_cast<uint8_t>(value.data[index + 1]) == 0x80 &&
167
93
                (static_cast<uint8_t>(value.data[index + 2]) == 0xA8 ||
168
0
                 static_cast<uint8_t>(value.data[index + 2]) == 0xA9)) {
169
0
                escaped =
170
0
                        static_cast<uint8_t>(value.data[index + 2]) == 0xA8 ? "\\u2028" : "\\u2029";
171
0
                escaped_size = 6;
172
0
                consumed = 3;
173
0
            }
174
93
            break;
175
93
        }
176
93
        if (escaped == nullptr) {
177
93
            ++index;
178
93
            continue;
179
93
        }
180
0
        if (index != plain_begin) {
181
0
            out.write(value.data + plain_begin, index - plain_begin);
182
0
        }
183
0
        out.write(escaped, escaped_size);
184
0
        index += consumed;
185
0
        plain_begin = index;
186
0
    }
187
93
    if (plain_begin != value.size) {
188
93
        out.write(value.data + plain_begin, value.size - plain_begin);
189
93
    }
190
93
    write_literal(out, "\"");
191
93
}
function_variant_parse_test.cpp:_ZN5doris19variant_json_detail25write_escaped_json_stringINS_12_GLOBAL__N_112StringWriterEEEvRT_NS_9StringRefE
Line
Count
Source
115
6
void write_escaped_json_string(Writer& out, StringRef value) {
116
6
    write_literal(out, "\"");
117
6
    size_t plain_begin = 0;
118
6
    size_t index = 0;
119
16
    while (index < value.size) {
120
10
        const auto byte = static_cast<uint8_t>(value.data[index]);
121
10
        const char* escaped = nullptr;
122
10
        size_t escaped_size = 0;
123
10
        size_t consumed = 1;
124
10
        switch (byte) {
125
0
        case '"':
126
0
            escaped = "\\\"";
127
0
            escaped_size = 2;
128
0
            break;
129
0
        case '\\':
130
0
            escaped = "\\\\";
131
0
            escaped_size = 2;
132
0
            break;
133
0
        case '\b':
134
0
            escaped = "\\b";
135
0
            escaped_size = 2;
136
0
            break;
137
0
        case '\f':
138
0
            escaped = "\\f";
139
0
            escaped_size = 2;
140
0
            break;
141
0
        case '\n':
142
0
            escaped = "\\n";
143
0
            escaped_size = 2;
144
0
            break;
145
0
        case '\r':
146
0
            escaped = "\\r";
147
0
            escaped_size = 2;
148
0
            break;
149
0
        case '\t':
150
0
            escaped = "\\t";
151
0
            escaped_size = 2;
152
0
            break;
153
10
        default:
154
10
            if (byte < 0x20) {
155
0
                static constexpr char HEX[] = "0123456789ABCDEF";
156
0
                char unicode_escape[] = {'\\', 'u', '0', '0', HEX[byte >> 4], HEX[byte & 0x0F]};
157
0
                if (index != plain_begin) {
158
0
                    out.write(value.data + plain_begin, index - plain_begin);
159
0
                }
160
0
                out.write(unicode_escape, sizeof(unicode_escape));
161
0
                ++index;
162
0
                plain_begin = index;
163
0
                continue;
164
0
            }
165
10
            if (index + 2 < value.size && byte == 0xE2 &&
166
10
                static_cast<uint8_t>(value.data[index + 1]) == 0x80 &&
167
10
                (static_cast<uint8_t>(value.data[index + 2]) == 0xA8 ||
168
0
                 static_cast<uint8_t>(value.data[index + 2]) == 0xA9)) {
169
0
                escaped =
170
0
                        static_cast<uint8_t>(value.data[index + 2]) == 0xA8 ? "\\u2028" : "\\u2029";
171
0
                escaped_size = 6;
172
0
                consumed = 3;
173
0
            }
174
10
            break;
175
10
        }
176
10
        if (escaped == nullptr) {
177
10
            ++index;
178
10
            continue;
179
10
        }
180
0
        if (index != plain_begin) {
181
0
            out.write(value.data + plain_begin, index - plain_begin);
182
0
        }
183
0
        out.write(escaped, escaped_size);
184
0
        index += consumed;
185
0
        plain_begin = index;
186
0
    }
187
6
    if (plain_begin != value.size) {
188
6
        out.write(value.data + plain_begin, value.size - plain_begin);
189
6
    }
190
6
    write_literal(out, "\"");
191
6
}
variant_string_parse_test.cpp:_ZN5doris19variant_json_detail25write_escaped_json_stringINS_12_GLOBAL__N_112StringWriterEEEvRT_NS_9StringRefE
Line
Count
Source
115
32
void write_escaped_json_string(Writer& out, StringRef value) {
116
32
    write_literal(out, "\"");
117
32
    size_t plain_begin = 0;
118
32
    size_t index = 0;
119
154
    while (index < value.size) {
120
122
        const auto byte = static_cast<uint8_t>(value.data[index]);
121
122
        const char* escaped = nullptr;
122
122
        size_t escaped_size = 0;
123
122
        size_t consumed = 1;
124
122
        switch (byte) {
125
1
        case '"':
126
1
            escaped = "\\\"";
127
1
            escaped_size = 2;
128
1
            break;
129
1
        case '\\':
130
1
            escaped = "\\\\";
131
1
            escaped_size = 2;
132
1
            break;
133
0
        case '\b':
134
0
            escaped = "\\b";
135
0
            escaped_size = 2;
136
0
            break;
137
0
        case '\f':
138
0
            escaped = "\\f";
139
0
            escaped_size = 2;
140
0
            break;
141
1
        case '\n':
142
1
            escaped = "\\n";
143
1
            escaped_size = 2;
144
1
            break;
145
0
        case '\r':
146
0
            escaped = "\\r";
147
0
            escaped_size = 2;
148
0
            break;
149
1
        case '\t':
150
1
            escaped = "\\t";
151
1
            escaped_size = 2;
152
1
            break;
153
118
        default:
154
118
            if (byte < 0x20) {
155
0
                static constexpr char HEX[] = "0123456789ABCDEF";
156
0
                char unicode_escape[] = {'\\', 'u', '0', '0', HEX[byte >> 4], HEX[byte & 0x0F]};
157
0
                if (index != plain_begin) {
158
0
                    out.write(value.data + plain_begin, index - plain_begin);
159
0
                }
160
0
                out.write(unicode_escape, sizeof(unicode_escape));
161
0
                ++index;
162
0
                plain_begin = index;
163
0
                continue;
164
0
            }
165
118
            if (index + 2 < value.size && byte == 0xE2 &&
166
118
                static_cast<uint8_t>(value.data[index + 1]) == 0x80 &&
167
118
                (static_cast<uint8_t>(value.data[index + 2]) == 0xA8 ||
168
1
                 static_cast<uint8_t>(value.data[index + 2]) == 0xA9)) {
169
1
                escaped =
170
1
                        static_cast<uint8_t>(value.data[index + 2]) == 0xA8 ? "\\u2028" : "\\u2029";
171
1
                escaped_size = 6;
172
1
                consumed = 3;
173
1
            }
174
118
            break;
175
122
        }
176
122
        if (escaped == nullptr) {
177
117
            ++index;
178
117
            continue;
179
117
        }
180
5
        if (index != plain_begin) {
181
2
            out.write(value.data + plain_begin, index - plain_begin);
182
2
        }
183
5
        out.write(escaped, escaped_size);
184
5
        index += consumed;
185
5
        plain_begin = index;
186
5
    }
187
32
    if (plain_begin != value.size) {
188
31
        out.write(value.data + plain_begin, value.size - plain_begin);
189
31
    }
190
32
    write_literal(out, "\"");
191
32
}
_ZN5doris19variant_json_detail25write_escaped_json_stringINS_14BufferWritableEEEvRT_NS_9StringRefE
Line
Count
Source
115
37
void write_escaped_json_string(Writer& out, StringRef value) {
116
37
    write_literal(out, "\"");
117
37
    size_t plain_begin = 0;
118
37
    size_t index = 0;
119
195
    while (index < value.size) {
120
158
        const auto byte = static_cast<uint8_t>(value.data[index]);
121
158
        const char* escaped = nullptr;
122
158
        size_t escaped_size = 0;
123
158
        size_t consumed = 1;
124
158
        switch (byte) {
125
21
        case '"':
126
21
            escaped = "\\\"";
127
21
            escaped_size = 2;
128
21
            break;
129
1
        case '\\':
130
1
            escaped = "\\\\";
131
1
            escaped_size = 2;
132
1
            break;
133
0
        case '\b':
134
0
            escaped = "\\b";
135
0
            escaped_size = 2;
136
0
            break;
137
0
        case '\f':
138
0
            escaped = "\\f";
139
0
            escaped_size = 2;
140
0
            break;
141
7
        case '\n':
142
7
            escaped = "\\n";
143
7
            escaped_size = 2;
144
7
            break;
145
0
        case '\r':
146
0
            escaped = "\\r";
147
0
            escaped_size = 2;
148
0
            break;
149
0
        case '\t':
150
0
            escaped = "\\t";
151
0
            escaped_size = 2;
152
0
            break;
153
129
        default:
154
129
            if (byte < 0x20) {
155
0
                static constexpr char HEX[] = "0123456789ABCDEF";
156
0
                char unicode_escape[] = {'\\', 'u', '0', '0', HEX[byte >> 4], HEX[byte & 0x0F]};
157
0
                if (index != plain_begin) {
158
0
                    out.write(value.data + plain_begin, index - plain_begin);
159
0
                }
160
0
                out.write(unicode_escape, sizeof(unicode_escape));
161
0
                ++index;
162
0
                plain_begin = index;
163
0
                continue;
164
0
            }
165
129
            if (index + 2 < value.size && byte == 0xE2 &&
166
129
                static_cast<uint8_t>(value.data[index + 1]) == 0x80 &&
167
129
                (static_cast<uint8_t>(value.data[index + 2]) == 0xA8 ||
168
0
                 static_cast<uint8_t>(value.data[index + 2]) == 0xA9)) {
169
0
                escaped =
170
0
                        static_cast<uint8_t>(value.data[index + 2]) == 0xA8 ? "\\u2028" : "\\u2029";
171
0
                escaped_size = 6;
172
0
                consumed = 3;
173
0
            }
174
129
            break;
175
158
        }
176
158
        if (escaped == nullptr) {
177
129
            ++index;
178
129
            continue;
179
129
        }
180
29
        if (index != plain_begin) {
181
23
            out.write(value.data + plain_begin, index - plain_begin);
182
23
        }
183
29
        out.write(escaped, escaped_size);
184
29
        index += consumed;
185
29
        plain_begin = index;
186
29
    }
187
37
    if (plain_begin != value.size) {
188
31
        out.write(value.data + plain_begin, value.size - plain_begin);
189
31
    }
190
37
    write_literal(out, "\"");
191
37
}
_ZN5doris19variant_json_detail25write_escaped_json_stringINS_35data_type_variant_v2_serde_internal14CountingWriterEEEvRT_NS_9StringRefE
Line
Count
Source
115
61
void write_escaped_json_string(Writer& out, StringRef value) {
116
61
    write_literal(out, "\"");
117
61
    size_t plain_begin = 0;
118
61
    size_t index = 0;
119
356
    while (index < value.size) {
120
295
        const auto byte = static_cast<uint8_t>(value.data[index]);
121
295
        const char* escaped = nullptr;
122
295
        size_t escaped_size = 0;
123
295
        size_t consumed = 1;
124
295
        switch (byte) {
125
45
        case '"':
126
45
            escaped = "\\\"";
127
45
            escaped_size = 2;
128
45
            break;
129
1
        case '\\':
130
1
            escaped = "\\\\";
131
1
            escaped_size = 2;
132
1
            break;
133
0
        case '\b':
134
0
            escaped = "\\b";
135
0
            escaped_size = 2;
136
0
            break;
137
0
        case '\f':
138
0
            escaped = "\\f";
139
0
            escaped_size = 2;
140
0
            break;
141
15
        case '\n':
142
15
            escaped = "\\n";
143
15
            escaped_size = 2;
144
15
            break;
145
0
        case '\r':
146
0
            escaped = "\\r";
147
0
            escaped_size = 2;
148
0
            break;
149
0
        case '\t':
150
0
            escaped = "\\t";
151
0
            escaped_size = 2;
152
0
            break;
153
234
        default:
154
234
            if (byte < 0x20) {
155
0
                static constexpr char HEX[] = "0123456789ABCDEF";
156
0
                char unicode_escape[] = {'\\', 'u', '0', '0', HEX[byte >> 4], HEX[byte & 0x0F]};
157
0
                if (index != plain_begin) {
158
0
                    out.write(value.data + plain_begin, index - plain_begin);
159
0
                }
160
0
                out.write(unicode_escape, sizeof(unicode_escape));
161
0
                ++index;
162
0
                plain_begin = index;
163
0
                continue;
164
0
            }
165
234
            if (index + 2 < value.size && byte == 0xE2 &&
166
234
                static_cast<uint8_t>(value.data[index + 1]) == 0x80 &&
167
234
                (static_cast<uint8_t>(value.data[index + 2]) == 0xA8 ||
168
0
                 static_cast<uint8_t>(value.data[index + 2]) == 0xA9)) {
169
0
                escaped =
170
0
                        static_cast<uint8_t>(value.data[index + 2]) == 0xA8 ? "\\u2028" : "\\u2029";
171
0
                escaped_size = 6;
172
0
                consumed = 3;
173
0
            }
174
234
            break;
175
295
        }
176
295
        if (escaped == nullptr) {
177
234
            ++index;
178
234
            continue;
179
234
        }
180
61
        if (index != plain_begin) {
181
47
            out.write(value.data + plain_begin, index - plain_begin);
182
47
        }
183
61
        out.write(escaped, escaped_size);
184
61
        index += consumed;
185
61
        plain_begin = index;
186
61
    }
187
61
    if (plain_begin != value.size) {
188
47
        out.write(value.data + plain_begin, value.size - plain_begin);
189
47
    }
190
61
    write_literal(out, "\"");
191
61
}
_ZN5doris19variant_json_detail25write_escaped_json_stringINS_35data_type_variant_v2_serde_internal11FixedWriterEEEvRT_NS_9StringRefE
Line
Count
Source
115
29
void write_escaped_json_string(Writer& out, StringRef value) {
116
29
    write_literal(out, "\"");
117
29
    size_t plain_begin = 0;
118
29
    size_t index = 0;
119
171
    while (index < value.size) {
120
142
        const auto byte = static_cast<uint8_t>(value.data[index]);
121
142
        const char* escaped = nullptr;
122
142
        size_t escaped_size = 0;
123
142
        size_t consumed = 1;
124
142
        switch (byte) {
125
24
        case '"':
126
24
            escaped = "\\\"";
127
24
            escaped_size = 2;
128
24
            break;
129
0
        case '\\':
130
0
            escaped = "\\\\";
131
0
            escaped_size = 2;
132
0
            break;
133
0
        case '\b':
134
0
            escaped = "\\b";
135
0
            escaped_size = 2;
136
0
            break;
137
0
        case '\f':
138
0
            escaped = "\\f";
139
0
            escaped_size = 2;
140
0
            break;
141
8
        case '\n':
142
8
            escaped = "\\n";
143
8
            escaped_size = 2;
144
8
            break;
145
0
        case '\r':
146
0
            escaped = "\\r";
147
0
            escaped_size = 2;
148
0
            break;
149
0
        case '\t':
150
0
            escaped = "\\t";
151
0
            escaped_size = 2;
152
0
            break;
153
110
        default:
154
110
            if (byte < 0x20) {
155
0
                static constexpr char HEX[] = "0123456789ABCDEF";
156
0
                char unicode_escape[] = {'\\', 'u', '0', '0', HEX[byte >> 4], HEX[byte & 0x0F]};
157
0
                if (index != plain_begin) {
158
0
                    out.write(value.data + plain_begin, index - plain_begin);
159
0
                }
160
0
                out.write(unicode_escape, sizeof(unicode_escape));
161
0
                ++index;
162
0
                plain_begin = index;
163
0
                continue;
164
0
            }
165
110
            if (index + 2 < value.size && byte == 0xE2 &&
166
110
                static_cast<uint8_t>(value.data[index + 1]) == 0x80 &&
167
110
                (static_cast<uint8_t>(value.data[index + 2]) == 0xA8 ||
168
0
                 static_cast<uint8_t>(value.data[index + 2]) == 0xA9)) {
169
0
                escaped =
170
0
                        static_cast<uint8_t>(value.data[index + 2]) == 0xA8 ? "\\u2028" : "\\u2029";
171
0
                escaped_size = 6;
172
0
                consumed = 3;
173
0
            }
174
110
            break;
175
142
        }
176
142
        if (escaped == nullptr) {
177
110
            ++index;
178
110
            continue;
179
110
        }
180
32
        if (index != plain_begin) {
181
24
            out.write(value.data + plain_begin, index - plain_begin);
182
24
        }
183
32
        out.write(escaped, escaped_size);
184
32
        index += consumed;
185
32
        plain_begin = index;
186
32
    }
187
29
    if (plain_begin != value.size) {
188
21
        out.write(value.data + plain_begin, value.size - plain_begin);
189
21
    }
190
29
    write_literal(out, "\"");
191
29
}
192
193
template <typename Writer>
194
111
void write_json_string(Writer& out, StringRef value, const char* description) {
195
111
    require_valid_json_utf8(value, description);
196
111
    write_escaped_json_string(out, value);
197
111
}
Unexecuted instantiation: column_variant_v2_test.cpp:_ZN5doris19variant_json_detail17write_json_stringINS_12_GLOBAL__N_110JsonWriterEEEvRT_NS_9StringRefEPKc
function_variant_parse_test.cpp:_ZN5doris19variant_json_detail17write_json_stringINS_12_GLOBAL__N_112StringWriterEEEvRT_NS_9StringRefEPKc
Line
Count
Source
194
1
void write_json_string(Writer& out, StringRef value, const char* description) {
195
1
    require_valid_json_utf8(value, description);
196
1
    write_escaped_json_string(out, value);
197
1
}
variant_string_parse_test.cpp:_ZN5doris19variant_json_detail17write_json_stringINS_12_GLOBAL__N_112StringWriterEEEvRT_NS_9StringRefEPKc
Line
Count
Source
194
7
void write_json_string(Writer& out, StringRef value, const char* description) {
195
7
    require_valid_json_utf8(value, description);
196
7
    write_escaped_json_string(out, value);
197
7
}
_ZN5doris19variant_json_detail17write_json_stringINS_14BufferWritableEEEvRT_NS_9StringRefEPKc
Line
Count
Source
194
26
void write_json_string(Writer& out, StringRef value, const char* description) {
195
26
    require_valid_json_utf8(value, description);
196
26
    write_escaped_json_string(out, value);
197
26
}
_ZN5doris19variant_json_detail17write_json_stringINS_35data_type_variant_v2_serde_internal14CountingWriterEEEvRT_NS_9StringRefEPKc
Line
Count
Source
194
51
void write_json_string(Writer& out, StringRef value, const char* description) {
195
51
    require_valid_json_utf8(value, description);
196
51
    write_escaped_json_string(out, value);
197
51
}
_ZN5doris19variant_json_detail17write_json_stringINS_35data_type_variant_v2_serde_internal11FixedWriterEEEvRT_NS_9StringRefEPKc
Line
Count
Source
194
26
void write_json_string(Writer& out, StringRef value, const char* description) {
195
26
    require_valid_json_utf8(value, description);
196
26
    write_escaped_json_string(out, value);
197
26
}
198
199
template <typename Writer>
200
2
void write_json_binary(Writer& out, StringRef value) {
201
2
    static constexpr char BASE64[] =
202
2
            "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
203
2
    write_literal(out, "\"");
204
2
    std::array<char, 1024> encoded {};
205
2
    size_t encoded_size = 0;
206
2
    size_t index = 0;
207
2
    const auto flush = [&]() {
208
2
        if (encoded_size != 0) {
209
2
            out.write(encoded.data(), encoded_size);
210
2
            encoded_size = 0;
211
2
        }
212
2
    };
Unexecuted instantiation: column_variant_v2_test.cpp:_ZZN5doris19variant_json_detail17write_json_binaryINS_12_GLOBAL__N_110JsonWriterEEEvRT_NS_9StringRefEENKUlvE_clEv
Unexecuted instantiation: function_variant_parse_test.cpp:_ZZN5doris19variant_json_detail17write_json_binaryINS_12_GLOBAL__N_112StringWriterEEEvRT_NS_9StringRefEENKUlvE_clEv
variant_string_parse_test.cpp:_ZZN5doris19variant_json_detail17write_json_binaryINS_12_GLOBAL__N_112StringWriterEEEvRT_NS_9StringRefEENKUlvE_clEv
Line
Count
Source
207
1
    const auto flush = [&]() {
208
1
        if (encoded_size != 0) {
209
1
            out.write(encoded.data(), encoded_size);
210
1
            encoded_size = 0;
211
1
        }
212
1
    };
_ZZN5doris19variant_json_detail17write_json_binaryINS_14BufferWritableEEEvRT_NS_9StringRefEENKUlvE_clEv
Line
Count
Source
207
1
    const auto flush = [&]() {
208
1
        if (encoded_size != 0) {
209
1
            out.write(encoded.data(), encoded_size);
210
1
            encoded_size = 0;
211
1
        }
212
1
    };
Unexecuted instantiation: _ZZN5doris19variant_json_detail17write_json_binaryINS_35data_type_variant_v2_serde_internal14CountingWriterEEEvRT_NS_9StringRefEENKUlvE_clEv
Unexecuted instantiation: _ZZN5doris19variant_json_detail17write_json_binaryINS_35data_type_variant_v2_serde_internal11FixedWriterEEEvRT_NS_9StringRefEENKUlvE_clEv
213
3
    while (index + 3 <= value.size) {
214
1
        if (encoded.size() - encoded_size < 4) {
215
0
            flush();
216
0
        }
217
1
        const auto first = static_cast<uint8_t>(value.data[index]);
218
1
        const auto second = static_cast<uint8_t>(value.data[index + 1]);
219
1
        const auto third = static_cast<uint8_t>(value.data[index + 2]);
220
1
        encoded[encoded_size++] = BASE64[first >> 2];
221
1
        encoded[encoded_size++] = BASE64[((first & 0x03) << 4) | (second >> 4)];
222
1
        encoded[encoded_size++] = BASE64[((second & 0x0F) << 2) | (third >> 6)];
223
1
        encoded[encoded_size++] = BASE64[third & 0x3F];
224
1
        index += 3;
225
1
    }
226
2
    if (index != value.size) {
227
2
        if (encoded.size() - encoded_size < 4) {
228
0
            flush();
229
0
        }
230
2
        const auto first = static_cast<uint8_t>(value.data[index]);
231
2
        encoded[encoded_size++] = BASE64[first >> 2];
232
2
        if (index + 1 == value.size) {
233
1
            encoded[encoded_size++] = BASE64[(first & 0x03) << 4];
234
1
            encoded[encoded_size++] = '=';
235
1
            encoded[encoded_size++] = '=';
236
1
        } else {
237
1
            const auto second = static_cast<uint8_t>(value.data[index + 1]);
238
1
            encoded[encoded_size++] = BASE64[((first & 0x03) << 4) | (second >> 4)];
239
1
            encoded[encoded_size++] = BASE64[(second & 0x0F) << 2];
240
1
            encoded[encoded_size++] = '=';
241
1
        }
242
2
    }
243
2
    flush();
244
2
    write_literal(out, "\"");
245
2
}
Unexecuted instantiation: column_variant_v2_test.cpp:_ZN5doris19variant_json_detail17write_json_binaryINS_12_GLOBAL__N_110JsonWriterEEEvRT_NS_9StringRefE
Unexecuted instantiation: function_variant_parse_test.cpp:_ZN5doris19variant_json_detail17write_json_binaryINS_12_GLOBAL__N_112StringWriterEEEvRT_NS_9StringRefE
variant_string_parse_test.cpp:_ZN5doris19variant_json_detail17write_json_binaryINS_12_GLOBAL__N_112StringWriterEEEvRT_NS_9StringRefE
Line
Count
Source
200
1
void write_json_binary(Writer& out, StringRef value) {
201
1
    static constexpr char BASE64[] =
202
1
            "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
203
1
    write_literal(out, "\"");
204
1
    std::array<char, 1024> encoded {};
205
1
    size_t encoded_size = 0;
206
1
    size_t index = 0;
207
1
    const auto flush = [&]() {
208
1
        if (encoded_size != 0) {
209
1
            out.write(encoded.data(), encoded_size);
210
1
            encoded_size = 0;
211
1
        }
212
1
    };
213
2
    while (index + 3 <= value.size) {
214
1
        if (encoded.size() - encoded_size < 4) {
215
0
            flush();
216
0
        }
217
1
        const auto first = static_cast<uint8_t>(value.data[index]);
218
1
        const auto second = static_cast<uint8_t>(value.data[index + 1]);
219
1
        const auto third = static_cast<uint8_t>(value.data[index + 2]);
220
1
        encoded[encoded_size++] = BASE64[first >> 2];
221
1
        encoded[encoded_size++] = BASE64[((first & 0x03) << 4) | (second >> 4)];
222
1
        encoded[encoded_size++] = BASE64[((second & 0x0F) << 2) | (third >> 6)];
223
1
        encoded[encoded_size++] = BASE64[third & 0x3F];
224
1
        index += 3;
225
1
    }
226
1
    if (index != value.size) {
227
1
        if (encoded.size() - encoded_size < 4) {
228
0
            flush();
229
0
        }
230
1
        const auto first = static_cast<uint8_t>(value.data[index]);
231
1
        encoded[encoded_size++] = BASE64[first >> 2];
232
1
        if (index + 1 == value.size) {
233
1
            encoded[encoded_size++] = BASE64[(first & 0x03) << 4];
234
1
            encoded[encoded_size++] = '=';
235
1
            encoded[encoded_size++] = '=';
236
1
        } else {
237
0
            const auto second = static_cast<uint8_t>(value.data[index + 1]);
238
0
            encoded[encoded_size++] = BASE64[((first & 0x03) << 4) | (second >> 4)];
239
0
            encoded[encoded_size++] = BASE64[(second & 0x0F) << 2];
240
0
            encoded[encoded_size++] = '=';
241
0
        }
242
1
    }
243
1
    flush();
244
1
    write_literal(out, "\"");
245
1
}
_ZN5doris19variant_json_detail17write_json_binaryINS_14BufferWritableEEEvRT_NS_9StringRefE
Line
Count
Source
200
1
void write_json_binary(Writer& out, StringRef value) {
201
1
    static constexpr char BASE64[] =
202
1
            "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
203
1
    write_literal(out, "\"");
204
1
    std::array<char, 1024> encoded {};
205
1
    size_t encoded_size = 0;
206
1
    size_t index = 0;
207
1
    const auto flush = [&]() {
208
1
        if (encoded_size != 0) {
209
1
            out.write(encoded.data(), encoded_size);
210
1
            encoded_size = 0;
211
1
        }
212
1
    };
213
1
    while (index + 3 <= value.size) {
214
0
        if (encoded.size() - encoded_size < 4) {
215
0
            flush();
216
0
        }
217
0
        const auto first = static_cast<uint8_t>(value.data[index]);
218
0
        const auto second = static_cast<uint8_t>(value.data[index + 1]);
219
0
        const auto third = static_cast<uint8_t>(value.data[index + 2]);
220
0
        encoded[encoded_size++] = BASE64[first >> 2];
221
0
        encoded[encoded_size++] = BASE64[((first & 0x03) << 4) | (second >> 4)];
222
0
        encoded[encoded_size++] = BASE64[((second & 0x0F) << 2) | (third >> 6)];
223
0
        encoded[encoded_size++] = BASE64[third & 0x3F];
224
0
        index += 3;
225
0
    }
226
1
    if (index != value.size) {
227
1
        if (encoded.size() - encoded_size < 4) {
228
0
            flush();
229
0
        }
230
1
        const auto first = static_cast<uint8_t>(value.data[index]);
231
1
        encoded[encoded_size++] = BASE64[first >> 2];
232
1
        if (index + 1 == value.size) {
233
0
            encoded[encoded_size++] = BASE64[(first & 0x03) << 4];
234
0
            encoded[encoded_size++] = '=';
235
0
            encoded[encoded_size++] = '=';
236
1
        } else {
237
1
            const auto second = static_cast<uint8_t>(value.data[index + 1]);
238
1
            encoded[encoded_size++] = BASE64[((first & 0x03) << 4) | (second >> 4)];
239
1
            encoded[encoded_size++] = BASE64[(second & 0x0F) << 2];
240
1
            encoded[encoded_size++] = '=';
241
1
        }
242
1
    }
243
1
    flush();
244
1
    write_literal(out, "\"");
245
1
}
Unexecuted instantiation: _ZN5doris19variant_json_detail17write_json_binaryINS_35data_type_variant_v2_serde_internal14CountingWriterEEEvRT_NS_9StringRefE
Unexecuted instantiation: _ZN5doris19variant_json_detail17write_json_binaryINS_35data_type_variant_v2_serde_internal11FixedWriterEEEvRT_NS_9StringRefE
246
247
template <typename Writer>
248
class Printer {
249
public:
250
585
    Printer(Writer& out, const VariantJsonFormatOptions& options) : _out(out), _options(options) {}
column_variant_v2_test.cpp:_ZN5doris19variant_json_detail7PrinterINS_12_GLOBAL__N_110JsonWriterEEC2ERS3_RKNS_24VariantJsonFormatOptionsE
Line
Count
Source
250
137
    Printer(Writer& out, const VariantJsonFormatOptions& options) : _out(out), _options(options) {}
function_variant_parse_test.cpp:_ZN5doris19variant_json_detail7PrinterINS_12_GLOBAL__N_112StringWriterEEC2ERS3_RKNS_24VariantJsonFormatOptionsE
Line
Count
Source
250
13
    Printer(Writer& out, const VariantJsonFormatOptions& options) : _out(out), _options(options) {}
variant_string_parse_test.cpp:_ZN5doris19variant_json_detail7PrinterINS_12_GLOBAL__N_112StringWriterEEC2ERS3_RKNS_24VariantJsonFormatOptionsE
Line
Count
Source
250
47
    Printer(Writer& out, const VariantJsonFormatOptions& options) : _out(out), _options(options) {}
_ZN5doris19variant_json_detail7PrinterINS_14BufferWritableEEC2ERS2_RKNS_24VariantJsonFormatOptionsE
Line
Count
Source
250
99
    Printer(Writer& out, const VariantJsonFormatOptions& options) : _out(out), _options(options) {}
_ZN5doris19variant_json_detail7PrinterINS_35data_type_variant_v2_serde_internal14CountingWriterEEC2ERS3_RKNS_24VariantJsonFormatOptionsE
Line
Count
Source
250
191
    Printer(Writer& out, const VariantJsonFormatOptions& options) : _out(out), _options(options) {}
_ZN5doris19variant_json_detail7PrinterINS_35data_type_variant_v2_serde_internal11FixedWriterEEC2ERS3_RKNS_24VariantJsonFormatOptionsE
Line
Count
Source
250
98
    Printer(Writer& out, const VariantJsonFormatOptions& options) : _out(out), _options(options) {}
251
252
1.07k
    void write(VariantRef value, uint32_t depth) {
253
1.07k
        require_json_depth(depth);
254
1.07k
        switch (value.basic_type()) {
255
110
        case VariantBasicType::SHORT_STRING:
256
110
            write_json_string(_out, value.get_string(), "string");
257
110
            return;
258
484
        case VariantBasicType::PRIMITIVE:
259
484
            write_primitive(value);
260
484
            return;
261
169
        case VariantBasicType::OBJECT:
262
169
            write_object(value, depth);
263
169
            return;
264
315
        case VariantBasicType::ARRAY:
265
315
            write_array(value, depth);
266
315
            return;
267
1.07k
        }
268
1.07k
    }
column_variant_v2_test.cpp:_ZN5doris19variant_json_detail7PrinterINS_12_GLOBAL__N_110JsonWriterEE5writeENS_10VariantRefEj
Line
Count
Source
252
249
    void write(VariantRef value, uint32_t depth) {
253
249
        require_json_depth(depth);
254
249
        switch (value.basic_type()) {
255
0
        case VariantBasicType::SHORT_STRING:
256
0
            write_json_string(_out, value.get_string(), "string");
257
0
            return;
258
115
        case VariantBasicType::PRIMITIVE:
259
115
            write_primitive(value);
260
115
            return;
261
115
        case VariantBasicType::OBJECT:
262
115
            write_object(value, depth);
263
115
            return;
264
19
        case VariantBasicType::ARRAY:
265
19
            write_array(value, depth);
266
19
            return;
267
249
        }
268
249
    }
function_variant_parse_test.cpp:_ZN5doris19variant_json_detail7PrinterINS_12_GLOBAL__N_112StringWriterEE5writeENS_10VariantRefEj
Line
Count
Source
252
22
    void write(VariantRef value, uint32_t depth) {
253
22
        require_json_depth(depth);
254
22
        switch (value.basic_type()) {
255
1
        case VariantBasicType::SHORT_STRING:
256
1
            write_json_string(_out, value.get_string(), "string");
257
1
            return;
258
13
        case VariantBasicType::PRIMITIVE:
259
13
            write_primitive(value);
260
13
            return;
261
6
        case VariantBasicType::OBJECT:
262
6
            write_object(value, depth);
263
6
            return;
264
2
        case VariantBasicType::ARRAY:
265
2
            write_array(value, depth);
266
2
            return;
267
22
        }
268
22
    }
variant_string_parse_test.cpp:_ZN5doris19variant_json_detail7PrinterINS_12_GLOBAL__N_112StringWriterEE5writeENS_10VariantRefEj
Line
Count
Source
252
348
    void write(VariantRef value, uint32_t depth) {
253
348
        require_json_depth(depth);
254
348
        switch (value.basic_type()) {
255
6
        case VariantBasicType::SHORT_STRING:
256
6
            write_json_string(_out, value.get_string(), "string");
257
6
            return;
258
57
        case VariantBasicType::PRIMITIVE:
259
57
            write_primitive(value);
260
57
            return;
261
21
        case VariantBasicType::OBJECT:
262
21
            write_object(value, depth);
263
21
            return;
264
263
        case VariantBasicType::ARRAY:
265
263
            write_array(value, depth);
266
263
            return;
267
348
        }
268
348
    }
_ZN5doris19variant_json_detail7PrinterINS_14BufferWritableEE5writeENS_10VariantRefEj
Line
Count
Source
252
126
    void write(VariantRef value, uint32_t depth) {
253
126
        require_json_depth(depth);
254
126
        switch (value.basic_type()) {
255
26
        case VariantBasicType::SHORT_STRING:
256
26
            write_json_string(_out, value.get_string(), "string");
257
26
            return;
258
78
        case VariantBasicType::PRIMITIVE:
259
78
            write_primitive(value);
260
78
            return;
261
12
        case VariantBasicType::OBJECT:
262
12
            write_object(value, depth);
263
12
            return;
264
10
        case VariantBasicType::ARRAY:
265
10
            write_array(value, depth);
266
10
            return;
267
126
        }
268
126
    }
_ZN5doris19variant_json_detail7PrinterINS_35data_type_variant_v2_serde_internal14CountingWriterEE5writeENS_10VariantRefEj
Line
Count
Source
252
224
    void write(VariantRef value, uint32_t depth) {
253
224
        require_json_depth(depth);
254
224
        switch (value.basic_type()) {
255
51
        case VariantBasicType::SHORT_STRING:
256
51
            write_json_string(_out, value.get_string(), "string");
257
51
            return;
258
146
        case VariantBasicType::PRIMITIVE:
259
146
            write_primitive(value);
260
146
            return;
261
12
        case VariantBasicType::OBJECT:
262
12
            write_object(value, depth);
263
12
            return;
264
15
        case VariantBasicType::ARRAY:
265
15
            write_array(value, depth);
266
15
            return;
267
224
        }
268
224
    }
_ZN5doris19variant_json_detail7PrinterINS_35data_type_variant_v2_serde_internal11FixedWriterEE5writeENS_10VariantRefEj
Line
Count
Source
252
110
    void write(VariantRef value, uint32_t depth) {
253
110
        require_json_depth(depth);
254
110
        switch (value.basic_type()) {
255
26
        case VariantBasicType::SHORT_STRING:
256
26
            write_json_string(_out, value.get_string(), "string");
257
26
            return;
258
75
        case VariantBasicType::PRIMITIVE:
259
75
            write_primitive(value);
260
75
            return;
261
3
        case VariantBasicType::OBJECT:
262
3
            write_object(value, depth);
263
3
            return;
264
6
        case VariantBasicType::ARRAY:
265
6
            write_array(value, depth);
266
6
            return;
267
110
        }
268
110
    }
269
270
private:
271
484
    void write_primitive(VariantRef value) {
272
484
        const VariantPrimitiveId id = value.primitive_id();
273
484
        switch (id) {
274
70
        case VariantPrimitiveId::NULL_VALUE:
275
70
            write_literal(_out, "null");
276
70
            return;
277
6
        case VariantPrimitiveId::TRUE_VALUE:
278
6
            write_literal(_out, "true");
279
6
            return;
280
2
        case VariantPrimitiveId::FALSE_VALUE:
281
2
            write_literal(_out, "false");
282
2
            return;
283
176
        case VariantPrimitiveId::INT8:
284
177
        case VariantPrimitiveId::INT16:
285
178
        case VariantPrimitiveId::INT32:
286
179
        case VariantPrimitiveId::INT64:
287
179
            write_scalar(_out, format_json_int(value.get_int()));
288
179
            return;
289
142
        case VariantPrimitiveId::DOUBLE: {
290
142
            const double number = value.get_double();
291
142
            if (!std::isfinite(number)) {
292
85
                write_non_finite(number);
293
85
                return;
294
85
            }
295
57
            write_scalar(_out, format_json_double(number));
296
57
            return;
297
142
        }
298
1
        case VariantPrimitiveId::DECIMAL4:
299
2
        case VariantPrimitiveId::DECIMAL8:
300
4
        case VariantPrimitiveId::DECIMAL16:
301
4
            write_scalar(_out, format_json_decimal(value.get_decimal()));
302
4
            return;
303
33
        case VariantPrimitiveId::DATE:
304
33
            write_quoted_scalar(_out, format_json_date(value.get_date()));
305
33
            return;
306
3
        case VariantPrimitiveId::TIMESTAMP_MICROS:
307
3
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_micros(), 6, true,
308
3
                                                            _options.timezone));
309
3
            return;
310
30
        case VariantPrimitiveId::TIMESTAMP_NTZ_MICROS:
311
30
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_ntz_micros(), 6,
312
30
                                                            false, nullptr));
313
30
            return;
314
3
        case VariantPrimitiveId::FLOAT: {
315
3
            const float number = value.get_float();
316
3
            if (!std::isfinite(number)) {
317
2
                write_non_finite(number);
318
2
                return;
319
2
            }
320
1
            write_scalar(_out, format_json_float(number));
321
1
            return;
322
3
        }
323
2
        case VariantPrimitiveId::BINARY:
324
2
            write_json_binary(_out, value.get_binary());
325
2
            return;
326
1
        case VariantPrimitiveId::STRING:
327
1
            write_json_string(_out, value.get_string(), "string");
328
1
            return;
329
2
        case VariantPrimitiveId::TIME_NTZ_MICROS:
330
2
            write_quoted_scalar(_out, format_json_time_micros(value.get_time_ntz_micros()));
331
2
            return;
332
3
        case VariantPrimitiveId::TIMESTAMP_NANOS:
333
3
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_nanos(), 9, true,
334
3
                                                            _options.timezone));
335
3
            return;
336
2
        case VariantPrimitiveId::TIMESTAMP_NTZ_NANOS:
337
2
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_ntz_nanos(), 9,
338
2
                                                            false, nullptr));
339
2
            return;
340
2
        case VariantPrimitiveId::UUID:
341
2
            write_quoted_scalar(_out, format_json_uuid(value.get_uuid()));
342
2
            return;
343
484
        }
344
0
        throw_unsupported_json_primitive(id);
345
0
    }
column_variant_v2_test.cpp:_ZN5doris19variant_json_detail7PrinterINS_12_GLOBAL__N_110JsonWriterEE15write_primitiveENS_10VariantRefE
Line
Count
Source
271
115
    void write_primitive(VariantRef value) {
272
115
        const VariantPrimitiveId id = value.primitive_id();
273
115
        switch (id) {
274
0
        case VariantPrimitiveId::NULL_VALUE:
275
0
            write_literal(_out, "null");
276
0
            return;
277
0
        case VariantPrimitiveId::TRUE_VALUE:
278
0
            write_literal(_out, "true");
279
0
            return;
280
0
        case VariantPrimitiveId::FALSE_VALUE:
281
0
            write_literal(_out, "false");
282
0
            return;
283
115
        case VariantPrimitiveId::INT8:
284
115
        case VariantPrimitiveId::INT16:
285
115
        case VariantPrimitiveId::INT32:
286
115
        case VariantPrimitiveId::INT64:
287
115
            write_scalar(_out, format_json_int(value.get_int()));
288
115
            return;
289
0
        case VariantPrimitiveId::DOUBLE: {
290
0
            const double number = value.get_double();
291
0
            if (!std::isfinite(number)) {
292
0
                write_non_finite(number);
293
0
                return;
294
0
            }
295
0
            write_scalar(_out, format_json_double(number));
296
0
            return;
297
0
        }
298
0
        case VariantPrimitiveId::DECIMAL4:
299
0
        case VariantPrimitiveId::DECIMAL8:
300
0
        case VariantPrimitiveId::DECIMAL16:
301
0
            write_scalar(_out, format_json_decimal(value.get_decimal()));
302
0
            return;
303
0
        case VariantPrimitiveId::DATE:
304
0
            write_quoted_scalar(_out, format_json_date(value.get_date()));
305
0
            return;
306
0
        case VariantPrimitiveId::TIMESTAMP_MICROS:
307
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_micros(), 6, true,
308
0
                                                            _options.timezone));
309
0
            return;
310
0
        case VariantPrimitiveId::TIMESTAMP_NTZ_MICROS:
311
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_ntz_micros(), 6,
312
0
                                                            false, nullptr));
313
0
            return;
314
0
        case VariantPrimitiveId::FLOAT: {
315
0
            const float number = value.get_float();
316
0
            if (!std::isfinite(number)) {
317
0
                write_non_finite(number);
318
0
                return;
319
0
            }
320
0
            write_scalar(_out, format_json_float(number));
321
0
            return;
322
0
        }
323
0
        case VariantPrimitiveId::BINARY:
324
0
            write_json_binary(_out, value.get_binary());
325
0
            return;
326
0
        case VariantPrimitiveId::STRING:
327
0
            write_json_string(_out, value.get_string(), "string");
328
0
            return;
329
0
        case VariantPrimitiveId::TIME_NTZ_MICROS:
330
0
            write_quoted_scalar(_out, format_json_time_micros(value.get_time_ntz_micros()));
331
0
            return;
332
0
        case VariantPrimitiveId::TIMESTAMP_NANOS:
333
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_nanos(), 9, true,
334
0
                                                            _options.timezone));
335
0
            return;
336
0
        case VariantPrimitiveId::TIMESTAMP_NTZ_NANOS:
337
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_ntz_nanos(), 9,
338
0
                                                            false, nullptr));
339
0
            return;
340
0
        case VariantPrimitiveId::UUID:
341
0
            write_quoted_scalar(_out, format_json_uuid(value.get_uuid()));
342
0
            return;
343
115
        }
344
0
        throw_unsupported_json_primitive(id);
345
0
    }
function_variant_parse_test.cpp:_ZN5doris19variant_json_detail7PrinterINS_12_GLOBAL__N_112StringWriterEE15write_primitiveENS_10VariantRefE
Line
Count
Source
271
13
    void write_primitive(VariantRef value) {
272
13
        const VariantPrimitiveId id = value.primitive_id();
273
13
        switch (id) {
274
3
        case VariantPrimitiveId::NULL_VALUE:
275
3
            write_literal(_out, "null");
276
3
            return;
277
1
        case VariantPrimitiveId::TRUE_VALUE:
278
1
            write_literal(_out, "true");
279
1
            return;
280
0
        case VariantPrimitiveId::FALSE_VALUE:
281
0
            write_literal(_out, "false");
282
0
            return;
283
9
        case VariantPrimitiveId::INT8:
284
9
        case VariantPrimitiveId::INT16:
285
9
        case VariantPrimitiveId::INT32:
286
9
        case VariantPrimitiveId::INT64:
287
9
            write_scalar(_out, format_json_int(value.get_int()));
288
9
            return;
289
0
        case VariantPrimitiveId::DOUBLE: {
290
0
            const double number = value.get_double();
291
0
            if (!std::isfinite(number)) {
292
0
                write_non_finite(number);
293
0
                return;
294
0
            }
295
0
            write_scalar(_out, format_json_double(number));
296
0
            return;
297
0
        }
298
0
        case VariantPrimitiveId::DECIMAL4:
299
0
        case VariantPrimitiveId::DECIMAL8:
300
0
        case VariantPrimitiveId::DECIMAL16:
301
0
            write_scalar(_out, format_json_decimal(value.get_decimal()));
302
0
            return;
303
0
        case VariantPrimitiveId::DATE:
304
0
            write_quoted_scalar(_out, format_json_date(value.get_date()));
305
0
            return;
306
0
        case VariantPrimitiveId::TIMESTAMP_MICROS:
307
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_micros(), 6, true,
308
0
                                                            _options.timezone));
309
0
            return;
310
0
        case VariantPrimitiveId::TIMESTAMP_NTZ_MICROS:
311
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_ntz_micros(), 6,
312
0
                                                            false, nullptr));
313
0
            return;
314
0
        case VariantPrimitiveId::FLOAT: {
315
0
            const float number = value.get_float();
316
0
            if (!std::isfinite(number)) {
317
0
                write_non_finite(number);
318
0
                return;
319
0
            }
320
0
            write_scalar(_out, format_json_float(number));
321
0
            return;
322
0
        }
323
0
        case VariantPrimitiveId::BINARY:
324
0
            write_json_binary(_out, value.get_binary());
325
0
            return;
326
0
        case VariantPrimitiveId::STRING:
327
0
            write_json_string(_out, value.get_string(), "string");
328
0
            return;
329
0
        case VariantPrimitiveId::TIME_NTZ_MICROS:
330
0
            write_quoted_scalar(_out, format_json_time_micros(value.get_time_ntz_micros()));
331
0
            return;
332
0
        case VariantPrimitiveId::TIMESTAMP_NANOS:
333
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_nanos(), 9, true,
334
0
                                                            _options.timezone));
335
0
            return;
336
0
        case VariantPrimitiveId::TIMESTAMP_NTZ_NANOS:
337
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_ntz_nanos(), 9,
338
0
                                                            false, nullptr));
339
0
            return;
340
0
        case VariantPrimitiveId::UUID:
341
0
            write_quoted_scalar(_out, format_json_uuid(value.get_uuid()));
342
0
            return;
343
13
        }
344
0
        throw_unsupported_json_primitive(id);
345
0
    }
variant_string_parse_test.cpp:_ZN5doris19variant_json_detail7PrinterINS_12_GLOBAL__N_112StringWriterEE15write_primitiveENS_10VariantRefE
Line
Count
Source
271
57
    void write_primitive(VariantRef value) {
272
57
        const VariantPrimitiveId id = value.primitive_id();
273
57
        switch (id) {
274
5
        case VariantPrimitiveId::NULL_VALUE:
275
5
            write_literal(_out, "null");
276
5
            return;
277
4
        case VariantPrimitiveId::TRUE_VALUE:
278
4
            write_literal(_out, "true");
279
4
            return;
280
2
        case VariantPrimitiveId::FALSE_VALUE:
281
2
            write_literal(_out, "false");
282
2
            return;
283
19
        case VariantPrimitiveId::INT8:
284
20
        case VariantPrimitiveId::INT16:
285
21
        case VariantPrimitiveId::INT32:
286
22
        case VariantPrimitiveId::INT64:
287
22
            write_scalar(_out, format_json_int(value.get_int()));
288
22
            return;
289
2
        case VariantPrimitiveId::DOUBLE: {
290
2
            const double number = value.get_double();
291
2
            if (!std::isfinite(number)) {
292
1
                write_non_finite(number);
293
1
                return;
294
1
            }
295
1
            write_scalar(_out, format_json_double(number));
296
1
            return;
297
2
        }
298
1
        case VariantPrimitiveId::DECIMAL4:
299
2
        case VariantPrimitiveId::DECIMAL8:
300
4
        case VariantPrimitiveId::DECIMAL16:
301
4
            write_scalar(_out, format_json_decimal(value.get_decimal()));
302
4
            return;
303
1
        case VariantPrimitiveId::DATE:
304
1
            write_quoted_scalar(_out, format_json_date(value.get_date()));
305
1
            return;
306
3
        case VariantPrimitiveId::TIMESTAMP_MICROS:
307
3
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_micros(), 6, true,
308
3
                                                            _options.timezone));
309
3
            return;
310
2
        case VariantPrimitiveId::TIMESTAMP_NTZ_MICROS:
311
2
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_ntz_micros(), 6,
312
2
                                                            false, nullptr));
313
2
            return;
314
3
        case VariantPrimitiveId::FLOAT: {
315
3
            const float number = value.get_float();
316
3
            if (!std::isfinite(number)) {
317
2
                write_non_finite(number);
318
2
                return;
319
2
            }
320
1
            write_scalar(_out, format_json_float(number));
321
1
            return;
322
3
        }
323
1
        case VariantPrimitiveId::BINARY:
324
1
            write_json_binary(_out, value.get_binary());
325
1
            return;
326
1
        case VariantPrimitiveId::STRING:
327
1
            write_json_string(_out, value.get_string(), "string");
328
1
            return;
329
1
        case VariantPrimitiveId::TIME_NTZ_MICROS:
330
1
            write_quoted_scalar(_out, format_json_time_micros(value.get_time_ntz_micros()));
331
1
            return;
332
3
        case VariantPrimitiveId::TIMESTAMP_NANOS:
333
3
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_nanos(), 9, true,
334
3
                                                            _options.timezone));
335
3
            return;
336
2
        case VariantPrimitiveId::TIMESTAMP_NTZ_NANOS:
337
2
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_ntz_nanos(), 9,
338
2
                                                            false, nullptr));
339
2
            return;
340
1
        case VariantPrimitiveId::UUID:
341
1
            write_quoted_scalar(_out, format_json_uuid(value.get_uuid()));
342
1
            return;
343
57
        }
344
0
        throw_unsupported_json_primitive(id);
345
0
    }
_ZN5doris19variant_json_detail7PrinterINS_14BufferWritableEE15write_primitiveENS_10VariantRefE
Line
Count
Source
271
78
    void write_primitive(VariantRef value) {
272
78
        const VariantPrimitiveId id = value.primitive_id();
273
78
        switch (id) {
274
17
        case VariantPrimitiveId::NULL_VALUE:
275
17
            write_literal(_out, "null");
276
17
            return;
277
1
        case VariantPrimitiveId::TRUE_VALUE:
278
1
            write_literal(_out, "true");
279
1
            return;
280
0
        case VariantPrimitiveId::FALSE_VALUE:
281
0
            write_literal(_out, "false");
282
0
            return;
283
15
        case VariantPrimitiveId::INT8:
284
15
        case VariantPrimitiveId::INT16:
285
15
        case VariantPrimitiveId::INT32:
286
15
        case VariantPrimitiveId::INT64:
287
15
            write_scalar(_out, format_json_int(value.get_int()));
288
15
            return;
289
30
        case VariantPrimitiveId::DOUBLE: {
290
30
            const double number = value.get_double();
291
30
            if (!std::isfinite(number)) {
292
18
                write_non_finite(number);
293
18
                return;
294
18
            }
295
12
            write_scalar(_out, format_json_double(number));
296
12
            return;
297
30
        }
298
0
        case VariantPrimitiveId::DECIMAL4:
299
0
        case VariantPrimitiveId::DECIMAL8:
300
0
        case VariantPrimitiveId::DECIMAL16:
301
0
            write_scalar(_out, format_json_decimal(value.get_decimal()));
302
0
            return;
303
6
        case VariantPrimitiveId::DATE:
304
6
            write_quoted_scalar(_out, format_json_date(value.get_date()));
305
6
            return;
306
0
        case VariantPrimitiveId::TIMESTAMP_MICROS:
307
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_micros(), 6, true,
308
0
                                                            _options.timezone));
309
0
            return;
310
6
        case VariantPrimitiveId::TIMESTAMP_NTZ_MICROS:
311
6
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_ntz_micros(), 6,
312
6
                                                            false, nullptr));
313
6
            return;
314
0
        case VariantPrimitiveId::FLOAT: {
315
0
            const float number = value.get_float();
316
0
            if (!std::isfinite(number)) {
317
0
                write_non_finite(number);
318
0
                return;
319
0
            }
320
0
            write_scalar(_out, format_json_float(number));
321
0
            return;
322
0
        }
323
1
        case VariantPrimitiveId::BINARY:
324
1
            write_json_binary(_out, value.get_binary());
325
1
            return;
326
0
        case VariantPrimitiveId::STRING:
327
0
            write_json_string(_out, value.get_string(), "string");
328
0
            return;
329
1
        case VariantPrimitiveId::TIME_NTZ_MICROS:
330
1
            write_quoted_scalar(_out, format_json_time_micros(value.get_time_ntz_micros()));
331
1
            return;
332
0
        case VariantPrimitiveId::TIMESTAMP_NANOS:
333
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_nanos(), 9, true,
334
0
                                                            _options.timezone));
335
0
            return;
336
0
        case VariantPrimitiveId::TIMESTAMP_NTZ_NANOS:
337
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_ntz_nanos(), 9,
338
0
                                                            false, nullptr));
339
0
            return;
340
1
        case VariantPrimitiveId::UUID:
341
1
            write_quoted_scalar(_out, format_json_uuid(value.get_uuid()));
342
1
            return;
343
78
        }
344
0
        throw_unsupported_json_primitive(id);
345
0
    }
_ZN5doris19variant_json_detail7PrinterINS_35data_type_variant_v2_serde_internal14CountingWriterEE15write_primitiveENS_10VariantRefE
Line
Count
Source
271
146
    void write_primitive(VariantRef value) {
272
146
        const VariantPrimitiveId id = value.primitive_id();
273
146
        switch (id) {
274
31
        case VariantPrimitiveId::NULL_VALUE:
275
31
            write_literal(_out, "null");
276
31
            return;
277
0
        case VariantPrimitiveId::TRUE_VALUE:
278
0
            write_literal(_out, "true");
279
0
            return;
280
0
        case VariantPrimitiveId::FALSE_VALUE:
281
0
            write_literal(_out, "false");
282
0
            return;
283
15
        case VariantPrimitiveId::INT8:
284
15
        case VariantPrimitiveId::INT16:
285
15
        case VariantPrimitiveId::INT32:
286
15
        case VariantPrimitiveId::INT64:
287
15
            write_scalar(_out, format_json_int(value.get_int()));
288
15
            return;
289
70
        case VariantPrimitiveId::DOUBLE: {
290
70
            const double number = value.get_double();
291
70
            if (!std::isfinite(number)) {
292
42
                write_non_finite(number);
293
42
                return;
294
42
            }
295
28
            write_scalar(_out, format_json_double(number));
296
28
            return;
297
70
        }
298
0
        case VariantPrimitiveId::DECIMAL4:
299
0
        case VariantPrimitiveId::DECIMAL8:
300
0
        case VariantPrimitiveId::DECIMAL16:
301
0
            write_scalar(_out, format_json_decimal(value.get_decimal()));
302
0
            return;
303
16
        case VariantPrimitiveId::DATE:
304
16
            write_quoted_scalar(_out, format_json_date(value.get_date()));
305
16
            return;
306
0
        case VariantPrimitiveId::TIMESTAMP_MICROS:
307
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_micros(), 6, true,
308
0
                                                            _options.timezone));
309
0
            return;
310
14
        case VariantPrimitiveId::TIMESTAMP_NTZ_MICROS:
311
14
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_ntz_micros(), 6,
312
14
                                                            false, nullptr));
313
14
            return;
314
0
        case VariantPrimitiveId::FLOAT: {
315
0
            const float number = value.get_float();
316
0
            if (!std::isfinite(number)) {
317
0
                write_non_finite(number);
318
0
                return;
319
0
            }
320
0
            write_scalar(_out, format_json_float(number));
321
0
            return;
322
0
        }
323
0
        case VariantPrimitiveId::BINARY:
324
0
            write_json_binary(_out, value.get_binary());
325
0
            return;
326
0
        case VariantPrimitiveId::STRING:
327
0
            write_json_string(_out, value.get_string(), "string");
328
0
            return;
329
0
        case VariantPrimitiveId::TIME_NTZ_MICROS:
330
0
            write_quoted_scalar(_out, format_json_time_micros(value.get_time_ntz_micros()));
331
0
            return;
332
0
        case VariantPrimitiveId::TIMESTAMP_NANOS:
333
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_nanos(), 9, true,
334
0
                                                            _options.timezone));
335
0
            return;
336
0
        case VariantPrimitiveId::TIMESTAMP_NTZ_NANOS:
337
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_ntz_nanos(), 9,
338
0
                                                            false, nullptr));
339
0
            return;
340
0
        case VariantPrimitiveId::UUID:
341
0
            write_quoted_scalar(_out, format_json_uuid(value.get_uuid()));
342
0
            return;
343
146
        }
344
0
        throw_unsupported_json_primitive(id);
345
0
    }
_ZN5doris19variant_json_detail7PrinterINS_35data_type_variant_v2_serde_internal11FixedWriterEE15write_primitiveENS_10VariantRefE
Line
Count
Source
271
75
    void write_primitive(VariantRef value) {
272
75
        const VariantPrimitiveId id = value.primitive_id();
273
75
        switch (id) {
274
14
        case VariantPrimitiveId::NULL_VALUE:
275
14
            write_literal(_out, "null");
276
14
            return;
277
0
        case VariantPrimitiveId::TRUE_VALUE:
278
0
            write_literal(_out, "true");
279
0
            return;
280
0
        case VariantPrimitiveId::FALSE_VALUE:
281
0
            write_literal(_out, "false");
282
0
            return;
283
3
        case VariantPrimitiveId::INT8:
284
3
        case VariantPrimitiveId::INT16:
285
3
        case VariantPrimitiveId::INT32:
286
3
        case VariantPrimitiveId::INT64:
287
3
            write_scalar(_out, format_json_int(value.get_int()));
288
3
            return;
289
40
        case VariantPrimitiveId::DOUBLE: {
290
40
            const double number = value.get_double();
291
40
            if (!std::isfinite(number)) {
292
24
                write_non_finite(number);
293
24
                return;
294
24
            }
295
16
            write_scalar(_out, format_json_double(number));
296
16
            return;
297
40
        }
298
0
        case VariantPrimitiveId::DECIMAL4:
299
0
        case VariantPrimitiveId::DECIMAL8:
300
0
        case VariantPrimitiveId::DECIMAL16:
301
0
            write_scalar(_out, format_json_decimal(value.get_decimal()));
302
0
            return;
303
10
        case VariantPrimitiveId::DATE:
304
10
            write_quoted_scalar(_out, format_json_date(value.get_date()));
305
10
            return;
306
0
        case VariantPrimitiveId::TIMESTAMP_MICROS:
307
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_micros(), 6, true,
308
0
                                                            _options.timezone));
309
0
            return;
310
8
        case VariantPrimitiveId::TIMESTAMP_NTZ_MICROS:
311
8
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_ntz_micros(), 6,
312
8
                                                            false, nullptr));
313
8
            return;
314
0
        case VariantPrimitiveId::FLOAT: {
315
0
            const float number = value.get_float();
316
0
            if (!std::isfinite(number)) {
317
0
                write_non_finite(number);
318
0
                return;
319
0
            }
320
0
            write_scalar(_out, format_json_float(number));
321
0
            return;
322
0
        }
323
0
        case VariantPrimitiveId::BINARY:
324
0
            write_json_binary(_out, value.get_binary());
325
0
            return;
326
0
        case VariantPrimitiveId::STRING:
327
0
            write_json_string(_out, value.get_string(), "string");
328
0
            return;
329
0
        case VariantPrimitiveId::TIME_NTZ_MICROS:
330
0
            write_quoted_scalar(_out, format_json_time_micros(value.get_time_ntz_micros()));
331
0
            return;
332
0
        case VariantPrimitiveId::TIMESTAMP_NANOS:
333
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_nanos(), 9, true,
334
0
                                                            _options.timezone));
335
0
            return;
336
0
        case VariantPrimitiveId::TIMESTAMP_NTZ_NANOS:
337
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_ntz_nanos(), 9,
338
0
                                                            false, nullptr));
339
0
            return;
340
0
        case VariantPrimitiveId::UUID:
341
0
            write_quoted_scalar(_out, format_json_uuid(value.get_uuid()));
342
0
            return;
343
75
        }
344
0
        throw_unsupported_json_primitive(id);
345
0
    }
346
347
    template <typename Number>
348
87
    void write_non_finite(Number value) {
349
87
        if (std::isnan(value)) {
350
29
            write_literal(_out, "\"NaN\"");
351
58
        } else if (value > 0) {
352
29
            write_literal(_out, "\"Infinity\"");
353
29
        } else {
354
29
            write_literal(_out, "\"-Infinity\"");
355
29
        }
356
87
    }
Unexecuted instantiation: column_variant_v2_test.cpp:_ZN5doris19variant_json_detail7PrinterINS_12_GLOBAL__N_110JsonWriterEE16write_non_finiteIdEEvT_
Unexecuted instantiation: column_variant_v2_test.cpp:_ZN5doris19variant_json_detail7PrinterINS_12_GLOBAL__N_110JsonWriterEE16write_non_finiteIfEEvT_
Unexecuted instantiation: function_variant_parse_test.cpp:_ZN5doris19variant_json_detail7PrinterINS_12_GLOBAL__N_112StringWriterEE16write_non_finiteIdEEvT_
Unexecuted instantiation: function_variant_parse_test.cpp:_ZN5doris19variant_json_detail7PrinterINS_12_GLOBAL__N_112StringWriterEE16write_non_finiteIfEEvT_
variant_string_parse_test.cpp:_ZN5doris19variant_json_detail7PrinterINS_12_GLOBAL__N_112StringWriterEE16write_non_finiteIdEEvT_
Line
Count
Source
348
1
    void write_non_finite(Number value) {
349
1
        if (std::isnan(value)) {
350
0
            write_literal(_out, "\"NaN\"");
351
1
        } else if (value > 0) {
352
0
            write_literal(_out, "\"Infinity\"");
353
1
        } else {
354
1
            write_literal(_out, "\"-Infinity\"");
355
1
        }
356
1
    }
variant_string_parse_test.cpp:_ZN5doris19variant_json_detail7PrinterINS_12_GLOBAL__N_112StringWriterEE16write_non_finiteIfEEvT_
Line
Count
Source
348
2
    void write_non_finite(Number value) {
349
2
        if (std::isnan(value)) {
350
1
            write_literal(_out, "\"NaN\"");
351
1
        } else if (value > 0) {
352
1
            write_literal(_out, "\"Infinity\"");
353
1
        } else {
354
0
            write_literal(_out, "\"-Infinity\"");
355
0
        }
356
2
    }
_ZN5doris19variant_json_detail7PrinterINS_14BufferWritableEE16write_non_finiteIdEEvT_
Line
Count
Source
348
18
    void write_non_finite(Number value) {
349
18
        if (std::isnan(value)) {
350
6
            write_literal(_out, "\"NaN\"");
351
12
        } else if (value > 0) {
352
6
            write_literal(_out, "\"Infinity\"");
353
6
        } else {
354
6
            write_literal(_out, "\"-Infinity\"");
355
6
        }
356
18
    }
Unexecuted instantiation: _ZN5doris19variant_json_detail7PrinterINS_14BufferWritableEE16write_non_finiteIfEEvT_
_ZN5doris19variant_json_detail7PrinterINS_35data_type_variant_v2_serde_internal14CountingWriterEE16write_non_finiteIdEEvT_
Line
Count
Source
348
42
    void write_non_finite(Number value) {
349
42
        if (std::isnan(value)) {
350
14
            write_literal(_out, "\"NaN\"");
351
28
        } else if (value > 0) {
352
14
            write_literal(_out, "\"Infinity\"");
353
14
        } else {
354
14
            write_literal(_out, "\"-Infinity\"");
355
14
        }
356
42
    }
Unexecuted instantiation: _ZN5doris19variant_json_detail7PrinterINS_35data_type_variant_v2_serde_internal14CountingWriterEE16write_non_finiteIfEEvT_
_ZN5doris19variant_json_detail7PrinterINS_35data_type_variant_v2_serde_internal11FixedWriterEE16write_non_finiteIdEEvT_
Line
Count
Source
348
24
    void write_non_finite(Number value) {
349
24
        if (std::isnan(value)) {
350
8
            write_literal(_out, "\"NaN\"");
351
16
        } else if (value > 0) {
352
8
            write_literal(_out, "\"Infinity\"");
353
8
        } else {
354
8
            write_literal(_out, "\"-Infinity\"");
355
8
        }
356
24
    }
Unexecuted instantiation: _ZN5doris19variant_json_detail7PrinterINS_35data_type_variant_v2_serde_internal11FixedWriterEE16write_non_finiteIfEEvT_
357
358
169
    void write_object(VariantRef value, uint32_t depth) {
359
169
        write_literal(_out, "{");
360
169
        const uint32_t count = value.num_elements();
361
169
        StringRef previous_key;
362
319
        for (uint32_t index = 0; index < count; ++index) {
363
150
            if (index != 0) {
364
9
                write_literal(_out, ",");
365
9
            }
366
150
            uint32_t field_id = 0;
367
150
            VariantRef child = value.object_value_at(index, &field_id);
368
150
            const StringRef key = value.metadata.key_at(field_id);
369
150
            require_json_object_key(key, previous_key, index);
370
150
            write_escaped_json_string(_out, key);
371
150
            write_literal(_out, ":");
372
150
            write(child, depth + 1);
373
150
            previous_key = key;
374
150
        }
375
169
        write_literal(_out, "}");
376
169
    }
column_variant_v2_test.cpp:_ZN5doris19variant_json_detail7PrinterINS_12_GLOBAL__N_110JsonWriterEE12write_objectENS_10VariantRefEj
Line
Count
Source
358
115
    void write_object(VariantRef value, uint32_t depth) {
359
115
        write_literal(_out, "{");
360
115
        const uint32_t count = value.num_elements();
361
115
        StringRef previous_key;
362
208
        for (uint32_t index = 0; index < count; ++index) {
363
93
            if (index != 0) {
364
0
                write_literal(_out, ",");
365
0
            }
366
93
            uint32_t field_id = 0;
367
93
            VariantRef child = value.object_value_at(index, &field_id);
368
93
            const StringRef key = value.metadata.key_at(field_id);
369
93
            require_json_object_key(key, previous_key, index);
370
93
            write_escaped_json_string(_out, key);
371
93
            write_literal(_out, ":");
372
93
            write(child, depth + 1);
373
93
            previous_key = key;
374
93
        }
375
115
        write_literal(_out, "}");
376
115
    }
function_variant_parse_test.cpp:_ZN5doris19variant_json_detail7PrinterINS_12_GLOBAL__N_112StringWriterEE12write_objectENS_10VariantRefEj
Line
Count
Source
358
6
    void write_object(VariantRef value, uint32_t depth) {
359
6
        write_literal(_out, "{");
360
6
        const uint32_t count = value.num_elements();
361
6
        StringRef previous_key;
362
11
        for (uint32_t index = 0; index < count; ++index) {
363
5
            if (index != 0) {
364
0
                write_literal(_out, ",");
365
0
            }
366
5
            uint32_t field_id = 0;
367
5
            VariantRef child = value.object_value_at(index, &field_id);
368
5
            const StringRef key = value.metadata.key_at(field_id);
369
5
            require_json_object_key(key, previous_key, index);
370
5
            write_escaped_json_string(_out, key);
371
5
            write_literal(_out, ":");
372
5
            write(child, depth + 1);
373
5
            previous_key = key;
374
5
        }
375
6
        write_literal(_out, "}");
376
6
    }
variant_string_parse_test.cpp:_ZN5doris19variant_json_detail7PrinterINS_12_GLOBAL__N_112StringWriterEE12write_objectENS_10VariantRefEj
Line
Count
Source
358
21
    void write_object(VariantRef value, uint32_t depth) {
359
21
        write_literal(_out, "{");
360
21
        const uint32_t count = value.num_elements();
361
21
        StringRef previous_key;
362
49
        for (uint32_t index = 0; index < count; ++index) {
363
28
            if (index != 0) {
364
8
                write_literal(_out, ",");
365
8
            }
366
28
            uint32_t field_id = 0;
367
28
            VariantRef child = value.object_value_at(index, &field_id);
368
28
            const StringRef key = value.metadata.key_at(field_id);
369
28
            require_json_object_key(key, previous_key, index);
370
28
            write_escaped_json_string(_out, key);
371
28
            write_literal(_out, ":");
372
28
            write(child, depth + 1);
373
28
            previous_key = key;
374
28
        }
375
21
        write_literal(_out, "}");
376
21
    }
_ZN5doris19variant_json_detail7PrinterINS_14BufferWritableEE12write_objectENS_10VariantRefEj
Line
Count
Source
358
12
    void write_object(VariantRef value, uint32_t depth) {
359
12
        write_literal(_out, "{");
360
12
        const uint32_t count = value.num_elements();
361
12
        StringRef previous_key;
362
23
        for (uint32_t index = 0; index < count; ++index) {
363
11
            if (index != 0) {
364
1
                write_literal(_out, ",");
365
1
            }
366
11
            uint32_t field_id = 0;
367
11
            VariantRef child = value.object_value_at(index, &field_id);
368
11
            const StringRef key = value.metadata.key_at(field_id);
369
11
            require_json_object_key(key, previous_key, index);
370
11
            write_escaped_json_string(_out, key);
371
11
            write_literal(_out, ":");
372
11
            write(child, depth + 1);
373
11
            previous_key = key;
374
11
        }
375
12
        write_literal(_out, "}");
376
12
    }
_ZN5doris19variant_json_detail7PrinterINS_35data_type_variant_v2_serde_internal14CountingWriterEE12write_objectENS_10VariantRefEj
Line
Count
Source
358
12
    void write_object(VariantRef value, uint32_t depth) {
359
12
        write_literal(_out, "{");
360
12
        const uint32_t count = value.num_elements();
361
12
        StringRef previous_key;
362
22
        for (uint32_t index = 0; index < count; ++index) {
363
10
            if (index != 0) {
364
0
                write_literal(_out, ",");
365
0
            }
366
10
            uint32_t field_id = 0;
367
10
            VariantRef child = value.object_value_at(index, &field_id);
368
10
            const StringRef key = value.metadata.key_at(field_id);
369
10
            require_json_object_key(key, previous_key, index);
370
10
            write_escaped_json_string(_out, key);
371
10
            write_literal(_out, ":");
372
10
            write(child, depth + 1);
373
10
            previous_key = key;
374
10
        }
375
12
        write_literal(_out, "}");
376
12
    }
_ZN5doris19variant_json_detail7PrinterINS_35data_type_variant_v2_serde_internal11FixedWriterEE12write_objectENS_10VariantRefEj
Line
Count
Source
358
3
    void write_object(VariantRef value, uint32_t depth) {
359
3
        write_literal(_out, "{");
360
3
        const uint32_t count = value.num_elements();
361
3
        StringRef previous_key;
362
6
        for (uint32_t index = 0; index < count; ++index) {
363
3
            if (index != 0) {
364
0
                write_literal(_out, ",");
365
0
            }
366
3
            uint32_t field_id = 0;
367
3
            VariantRef child = value.object_value_at(index, &field_id);
368
3
            const StringRef key = value.metadata.key_at(field_id);
369
3
            require_json_object_key(key, previous_key, index);
370
3
            write_escaped_json_string(_out, key);
371
3
            write_literal(_out, ":");
372
3
            write(child, depth + 1);
373
3
            previous_key = key;
374
3
        }
375
3
        write_literal(_out, "}");
376
3
    }
377
378
315
    void write_array(VariantRef value, uint32_t depth) {
379
315
        write_literal(_out, "[");
380
315
        const uint32_t count = value.num_elements();
381
661
        for (uint32_t index = 0; index < count; ++index) {
382
346
            if (index != 0) {
383
45
                write_literal(_out, ",");
384
45
            }
385
346
            write(value.array_at(index), depth + 1);
386
346
        }
387
315
        write_literal(_out, "]");
388
315
    }
column_variant_v2_test.cpp:_ZN5doris19variant_json_detail7PrinterINS_12_GLOBAL__N_110JsonWriterEE11write_arrayENS_10VariantRefEj
Line
Count
Source
378
19
    void write_array(VariantRef value, uint32_t depth) {
379
19
        write_literal(_out, "[");
380
19
        const uint32_t count = value.num_elements();
381
38
        for (uint32_t index = 0; index < count; ++index) {
382
19
            if (index != 0) {
383
0
                write_literal(_out, ",");
384
0
            }
385
19
            write(value.array_at(index), depth + 1);
386
19
        }
387
19
        write_literal(_out, "]");
388
19
    }
function_variant_parse_test.cpp:_ZN5doris19variant_json_detail7PrinterINS_12_GLOBAL__N_112StringWriterEE11write_arrayENS_10VariantRefEj
Line
Count
Source
378
2
    void write_array(VariantRef value, uint32_t depth) {
379
2
        write_literal(_out, "[");
380
2
        const uint32_t count = value.num_elements();
381
6
        for (uint32_t index = 0; index < count; ++index) {
382
4
            if (index != 0) {
383
2
                write_literal(_out, ",");
384
2
            }
385
4
            write(value.array_at(index), depth + 1);
386
4
        }
387
2
        write_literal(_out, "]");
388
2
    }
variant_string_parse_test.cpp:_ZN5doris19variant_json_detail7PrinterINS_12_GLOBAL__N_112StringWriterEE11write_arrayENS_10VariantRefEj
Line
Count
Source
378
263
    void write_array(VariantRef value, uint32_t depth) {
379
263
        write_literal(_out, "[");
380
263
        const uint32_t count = value.num_elements();
381
538
        for (uint32_t index = 0; index < count; ++index) {
382
275
            if (index != 0) {
383
12
                write_literal(_out, ",");
384
12
            }
385
275
            write(value.array_at(index), depth + 1);
386
275
        }
387
263
        write_literal(_out, "]");
388
263
    }
_ZN5doris19variant_json_detail7PrinterINS_14BufferWritableEE11write_arrayENS_10VariantRefEj
Line
Count
Source
378
10
    void write_array(VariantRef value, uint32_t depth) {
379
10
        write_literal(_out, "[");
380
10
        const uint32_t count = value.num_elements();
381
26
        for (uint32_t index = 0; index < count; ++index) {
382
16
            if (index != 0) {
383
10
                write_literal(_out, ",");
384
10
            }
385
16
            write(value.array_at(index), depth + 1);
386
16
        }
387
10
        write_literal(_out, "]");
388
10
    }
_ZN5doris19variant_json_detail7PrinterINS_35data_type_variant_v2_serde_internal14CountingWriterEE11write_arrayENS_10VariantRefEj
Line
Count
Source
378
15
    void write_array(VariantRef value, uint32_t depth) {
379
15
        write_literal(_out, "[");
380
15
        const uint32_t count = value.num_elements();
381
38
        for (uint32_t index = 0; index < count; ++index) {
382
23
            if (index != 0) {
383
15
                write_literal(_out, ",");
384
15
            }
385
23
            write(value.array_at(index), depth + 1);
386
23
        }
387
15
        write_literal(_out, "]");
388
15
    }
_ZN5doris19variant_json_detail7PrinterINS_35data_type_variant_v2_serde_internal11FixedWriterEE11write_arrayENS_10VariantRefEj
Line
Count
Source
378
6
    void write_array(VariantRef value, uint32_t depth) {
379
6
        write_literal(_out, "[");
380
6
        const uint32_t count = value.num_elements();
381
15
        for (uint32_t index = 0; index < count; ++index) {
382
9
            if (index != 0) {
383
6
                write_literal(_out, ",");
384
6
            }
385
9
            write(value.array_at(index), depth + 1);
386
9
        }
387
6
        write_literal(_out, "]");
388
6
    }
389
390
    Writer& _out;
391
    const VariantJsonFormatOptions& _options;
392
};
393
394
} // namespace variant_json_detail
395
396
// Writer is statically dispatched and only needs write(const char*, size_t).
397
template <typename Writer>
398
void to_json(VariantRef value, Writer& out,
399
586
             const VariantJsonFormatOptions& options = VariantJsonFormatOptions {}) {
400
586
    variant_json_detail::require_exact_json_value(value);
401
586
    variant_json_detail::Printer<Writer>(out, options).write(value, 0);
402
586
}
column_variant_v2_test.cpp:_ZN5doris7to_jsonINS_12_GLOBAL__N_110JsonWriterEEEvNS_10VariantRefERT_RKNS_24VariantJsonFormatOptionsE
Line
Count
Source
399
137
             const VariantJsonFormatOptions& options = VariantJsonFormatOptions {}) {
400
137
    variant_json_detail::require_exact_json_value(value);
401
137
    variant_json_detail::Printer<Writer>(out, options).write(value, 0);
402
137
}
function_variant_parse_test.cpp:_ZN5doris7to_jsonINS_12_GLOBAL__N_112StringWriterEEEvNS_10VariantRefERT_RKNS_24VariantJsonFormatOptionsE
Line
Count
Source
399
13
             const VariantJsonFormatOptions& options = VariantJsonFormatOptions {}) {
400
13
    variant_json_detail::require_exact_json_value(value);
401
13
    variant_json_detail::Printer<Writer>(out, options).write(value, 0);
402
13
}
variant_string_parse_test.cpp:_ZN5doris7to_jsonINS_12_GLOBAL__N_112StringWriterEEEvNS_10VariantRefERT_RKNS_24VariantJsonFormatOptionsE
Line
Count
Source
399
48
             const VariantJsonFormatOptions& options = VariantJsonFormatOptions {}) {
400
48
    variant_json_detail::require_exact_json_value(value);
401
48
    variant_json_detail::Printer<Writer>(out, options).write(value, 0);
402
48
}
_ZN5doris7to_jsonINS_14BufferWritableEEEvNS_10VariantRefERT_RKNS_24VariantJsonFormatOptionsE
Line
Count
Source
399
99
             const VariantJsonFormatOptions& options = VariantJsonFormatOptions {}) {
400
99
    variant_json_detail::require_exact_json_value(value);
401
99
    variant_json_detail::Printer<Writer>(out, options).write(value, 0);
402
99
}
_ZN5doris7to_jsonINS_35data_type_variant_v2_serde_internal14CountingWriterEEEvNS_10VariantRefERT_RKNS_24VariantJsonFormatOptionsE
Line
Count
Source
399
191
             const VariantJsonFormatOptions& options = VariantJsonFormatOptions {}) {
400
191
    variant_json_detail::require_exact_json_value(value);
401
191
    variant_json_detail::Printer<Writer>(out, options).write(value, 0);
402
191
}
_ZN5doris7to_jsonINS_35data_type_variant_v2_serde_internal11FixedWriterEEEvNS_10VariantRefERT_RKNS_24VariantJsonFormatOptionsE
Line
Count
Source
399
98
             const VariantJsonFormatOptions& options = VariantJsonFormatOptions {}) {
400
98
    variant_json_detail::require_exact_json_value(value);
401
98
    variant_json_detail::Printer<Writer>(out, options).write(value, 0);
402
98
}
403
404
} // namespace doris