Coverage Report

Created: 2026-09-15 15:37

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 {
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
407k
void write_literal(Writer& out, const char (&value)[N]) {
99
407k
    out.write(value, N - 1);
100
407k
}
column_variant_v2_test.cpp:_ZN5doris12variant_json13write_literalINS_12_GLOBAL__N_110JsonWriterELm2EEEvRT_RAT0__Kc
Line
Count
Source
98
571
void write_literal(Writer& out, const char (&value)[N]) {
99
571
    out.write(value, N - 1);
100
571
}
Unexecuted instantiation: column_variant_v2_test.cpp:_ZN5doris12variant_json13write_literalINS_12_GLOBAL__N_110JsonWriterELm5EEEvRT_RAT0__Kc
Unexecuted instantiation: column_variant_v2_test.cpp:_ZN5doris12variant_json13write_literalINS_12_GLOBAL__N_110JsonWriterELm6EEEvRT_RAT0__Kc
Unexecuted instantiation: column_variant_v2_test.cpp:_ZN5doris12variant_json13write_literalINS_12_GLOBAL__N_110JsonWriterELm11EEEvRT_RAT0__Kc
Unexecuted instantiation: column_variant_v2_test.cpp:_ZN5doris12variant_json13write_literalINS_12_GLOBAL__N_110JsonWriterELm12EEEvRT_RAT0__Kc
function_variant_parse_test.cpp:_ZN5doris12variant_json13write_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:_ZN5doris12variant_json13write_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:_ZN5doris12variant_json13write_literalINS_12_GLOBAL__N_112StringWriterELm6EEEvRT_RAT0__Kc
Unexecuted instantiation: function_variant_parse_test.cpp:_ZN5doris12variant_json13write_literalINS_12_GLOBAL__N_112StringWriterELm11EEEvRT_RAT0__Kc
Unexecuted instantiation: function_variant_parse_test.cpp:_ZN5doris12variant_json13write_literalINS_12_GLOBAL__N_112StringWriterELm12EEEvRT_RAT0__Kc
segment_flusher_format_test.cpp:_ZN5doris12variant_json13write_literalIZNS_12_GLOBAL__N_118variant_field_jsonB5cxx11ERKNS_12VariantFieldEE12StringWriterLm2EEEvRT_RAT0__Kc
Line
Count
Source
98
284
void write_literal(Writer& out, const char (&value)[N]) {
99
284
    out.write(value, N - 1);
100
284
}
segment_flusher_format_test.cpp:_ZN5doris12variant_json13write_literalIZNS_12_GLOBAL__N_118variant_field_jsonB5cxx11ERKNS_12VariantFieldEE12StringWriterLm5EEEvRT_RAT0__Kc
Line
Count
Source
98
15
void write_literal(Writer& out, const char (&value)[N]) {
99
15
    out.write(value, N - 1);
100
15
}
Unexecuted instantiation: segment_flusher_format_test.cpp:_ZN5doris12variant_json13write_literalIZNS_12_GLOBAL__N_118variant_field_jsonB5cxx11ERKNS_12VariantFieldEE12StringWriterLm6EEEvRT_RAT0__Kc
Unexecuted instantiation: segment_flusher_format_test.cpp:_ZN5doris12variant_json13write_literalIZNS_12_GLOBAL__N_118variant_field_jsonB5cxx11ERKNS_12VariantFieldEE12StringWriterLm11EEEvRT_RAT0__Kc
Unexecuted instantiation: segment_flusher_format_test.cpp:_ZN5doris12variant_json13write_literalIZNS_12_GLOBAL__N_118variant_field_jsonB5cxx11ERKNS_12VariantFieldEE12StringWriterLm12EEEvRT_RAT0__Kc
hierarchical_data_iterator_test.cpp:_ZN5doris12variant_json13write_literalINS_12_GLOBAL__N_117VariantJsonWriterELm2EEEvRT_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
}
hierarchical_data_iterator_test.cpp:_ZN5doris12variant_json13write_literalINS_12_GLOBAL__N_117VariantJsonWriterELm5EEEvRT_RAT0__Kc
Line
Count
Source
98
2
void write_literal(Writer& out, const char (&value)[N]) {
99
2
    out.write(value, N - 1);
100
2
}
Unexecuted instantiation: hierarchical_data_iterator_test.cpp:_ZN5doris12variant_json13write_literalINS_12_GLOBAL__N_117VariantJsonWriterELm6EEEvRT_RAT0__Kc
Unexecuted instantiation: hierarchical_data_iterator_test.cpp:_ZN5doris12variant_json13write_literalINS_12_GLOBAL__N_117VariantJsonWriterELm11EEEvRT_RAT0__Kc
Unexecuted instantiation: hierarchical_data_iterator_test.cpp:_ZN5doris12variant_json13write_literalINS_12_GLOBAL__N_117VariantJsonWriterELm12EEEvRT_RAT0__Kc
variant_assembler_legacy_test.cpp:_ZN5doris12variant_json13write_literalINS_10segment_v210variant_v212_GLOBAL__N_110JsonWriterELm2EEEvRT_RAT0__Kc
Line
Count
Source
98
524
void write_literal(Writer& out, const char (&value)[N]) {
99
524
    out.write(value, N - 1);
100
524
}
variant_assembler_legacy_test.cpp:_ZN5doris12variant_json13write_literalINS_10segment_v210variant_v212_GLOBAL__N_110JsonWriterELm5EEEvRT_RAT0__Kc
Line
Count
Source
98
48
void write_literal(Writer& out, const char (&value)[N]) {
99
48
    out.write(value, N - 1);
100
48
}
variant_assembler_legacy_test.cpp:_ZN5doris12variant_json13write_literalINS_10segment_v210variant_v212_GLOBAL__N_110JsonWriterELm6EEEvRT_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
}
Unexecuted instantiation: variant_assembler_legacy_test.cpp:_ZN5doris12variant_json13write_literalINS_10segment_v210variant_v212_GLOBAL__N_110JsonWriterELm11EEEvRT_RAT0__Kc
Unexecuted instantiation: variant_assembler_legacy_test.cpp:_ZN5doris12variant_json13write_literalINS_10segment_v210variant_v212_GLOBAL__N_110JsonWriterELm12EEEvRT_RAT0__Kc
variant_string_parse_test.cpp:_ZN5doris12variant_json13write_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:_ZN5doris12variant_json13write_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:_ZN5doris12variant_json13write_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:_ZN5doris12variant_json13write_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:_ZN5doris12variant_json13write_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
}
_ZN5doris12variant_json13write_literalINS_14BufferWritableELm2EEEvRT_RAT0__Kc
Line
Count
Source
98
202k
void write_literal(Writer& out, const char (&value)[N]) {
99
202k
    out.write(value, N - 1);
100
202k
}
_ZN5doris12variant_json13write_literalINS_14BufferWritableELm5EEEvRT_RAT0__Kc
Line
Count
Source
98
36
void write_literal(Writer& out, const char (&value)[N]) {
99
36
    out.write(value, N - 1);
100
36
}
_ZN5doris12variant_json13write_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
}
_ZN5doris12variant_json13write_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
}
_ZN5doris12variant_json13write_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
}
unity_5_cxx.cxx:_ZN5doris12variant_json13write_literalINS_12_GLOBAL__N_114CountingWriterELm2EEEvRT_RAT0__Kc
Line
Count
Source
98
202k
void write_literal(Writer& out, const char (&value)[N]) {
99
202k
    out.write(value, N - 1);
100
202k
}
unity_5_cxx.cxx:_ZN5doris12variant_json13write_literalINS_12_GLOBAL__N_114CountingWriterELm5EEEvRT_RAT0__Kc
Line
Count
Source
98
41
void write_literal(Writer& out, const char (&value)[N]) {
99
41
    out.write(value, N - 1);
100
41
}
unity_5_cxx.cxx:_ZN5doris12variant_json13write_literalINS_12_GLOBAL__N_114CountingWriterELm6EEEvRT_RAT0__Kc
Line
Count
Source
98
10
void write_literal(Writer& out, const char (&value)[N]) {
99
10
    out.write(value, N - 1);
100
10
}
unity_5_cxx.cxx:_ZN5doris12variant_json13write_literalINS_12_GLOBAL__N_114CountingWriterELm11EEEvRT_RAT0__Kc
Line
Count
Source
98
10
void write_literal(Writer& out, const char (&value)[N]) {
99
10
    out.write(value, N - 1);
100
10
}
unity_5_cxx.cxx:_ZN5doris12variant_json13write_literalINS_12_GLOBAL__N_114CountingWriterELm12EEEvRT_RAT0__Kc
Line
Count
Source
98
10
void write_literal(Writer& out, const char (&value)[N]) {
99
10
    out.write(value, N - 1);
100
10
}
unity_5_cxx.cxx:_ZN5doris12variant_json13write_literalINS_12_GLOBAL__N_111FixedWriterELm2EEEvRT_RAT0__Kc
Line
Count
Source
98
117
void write_literal(Writer& out, const char (&value)[N]) {
99
117
    out.write(value, N - 1);
100
117
}
unity_5_cxx.cxx:_ZN5doris12variant_json13write_literalINS_12_GLOBAL__N_111FixedWriterELm5EEEvRT_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
}
unity_5_cxx.cxx:_ZN5doris12variant_json13write_literalINS_12_GLOBAL__N_111FixedWriterELm6EEEvRT_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
}
unity_5_cxx.cxx:_ZN5doris12variant_json13write_literalINS_12_GLOBAL__N_111FixedWriterELm11EEEvRT_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
}
unity_5_cxx.cxx:_ZN5doris12variant_json13write_literalINS_12_GLOBAL__N_111FixedWriterELm12EEEvRT_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
42.7k
void write_scalar(Writer& out, const FormattedScalar& value) {
104
42.7k
    out.write(value.bytes.data(), value.size);
105
42.7k
}
column_variant_v2_test.cpp:_ZN5doris12variant_json12write_scalarINS_12_GLOBAL__N_110JsonWriterEEEvRT_RKNS0_15FormattedScalarE
Line
Count
Source
103
119
void write_scalar(Writer& out, const FormattedScalar& value) {
104
119
    out.write(value.bytes.data(), value.size);
105
119
}
function_variant_parse_test.cpp:_ZN5doris12variant_json12write_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
}
segment_flusher_format_test.cpp:_ZN5doris12variant_json12write_scalarIZNS_12_GLOBAL__N_118variant_field_jsonB5cxx11ERKNS_12VariantFieldEE12StringWriterEEvRT_RKNS0_15FormattedScalarE
Line
Count
Source
103
29
void write_scalar(Writer& out, const FormattedScalar& value) {
104
29
    out.write(value.bytes.data(), value.size);
105
29
}
hierarchical_data_iterator_test.cpp:_ZN5doris12variant_json12write_scalarINS_12_GLOBAL__N_117VariantJsonWriterEEEvRT_RKNS0_15FormattedScalarE
Line
Count
Source
103
2
void write_scalar(Writer& out, const FormattedScalar& value) {
104
2
    out.write(value.bytes.data(), value.size);
105
2
}
variant_assembler_legacy_test.cpp:_ZN5doris12variant_json12write_scalarINS_10segment_v210variant_v212_GLOBAL__N_110JsonWriterEEEvRT_RKNS0_15FormattedScalarE
Line
Count
Source
103
114
void write_scalar(Writer& out, const FormattedScalar& value) {
104
114
    out.write(value.bytes.data(), value.size);
105
114
}
variant_string_parse_test.cpp:_ZN5doris12variant_json12write_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
}
_ZN5doris12variant_json12write_scalarINS_14BufferWritableEEEvRT_RKNS0_15FormattedScalarE
Line
Count
Source
103
21.1k
void write_scalar(Writer& out, const FormattedScalar& value) {
104
21.1k
    out.write(value.bytes.data(), value.size);
105
21.1k
}
unity_5_cxx.cxx:_ZN5doris12variant_json12write_scalarINS_12_GLOBAL__N_114CountingWriterEEEvRT_RKNS0_15FormattedScalarE
Line
Count
Source
103
21.2k
void write_scalar(Writer& out, const FormattedScalar& value) {
104
21.2k
    out.write(value.bytes.data(), value.size);
105
21.2k
}
unity_5_cxx.cxx:_ZN5doris12variant_json12write_scalarINS_12_GLOBAL__N_111FixedWriterEEEvRT_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
103
void write_quoted_scalar(Writer& out, const FormattedScalar& value) {
109
103
    write_literal(out, "\"");
110
103
    write_scalar(out, value);
111
103
    write_literal(out, "\"");
112
103
}
Unexecuted instantiation: column_variant_v2_test.cpp:_ZN5doris12variant_json19write_quoted_scalarINS_12_GLOBAL__N_110JsonWriterEEEvRT_RKNS0_15FormattedScalarE
Unexecuted instantiation: function_variant_parse_test.cpp:_ZN5doris12variant_json19write_quoted_scalarINS_12_GLOBAL__N_112StringWriterEEEvRT_RKNS0_15FormattedScalarE
Unexecuted instantiation: segment_flusher_format_test.cpp:_ZN5doris12variant_json19write_quoted_scalarIZNS_12_GLOBAL__N_118variant_field_jsonB5cxx11ERKNS_12VariantFieldEE12StringWriterEEvRT_RKNS0_15FormattedScalarE
Unexecuted instantiation: hierarchical_data_iterator_test.cpp:_ZN5doris12variant_json19write_quoted_scalarINS_12_GLOBAL__N_117VariantJsonWriterEEEvRT_RKNS0_15FormattedScalarE
variant_assembler_legacy_test.cpp:_ZN5doris12variant_json19write_quoted_scalarINS_10segment_v210variant_v212_GLOBAL__N_110JsonWriterEEEvRT_RKNS0_15FormattedScalarE
Line
Count
Source
108
52
void write_quoted_scalar(Writer& out, const FormattedScalar& value) {
109
52
    write_literal(out, "\"");
110
52
    write_scalar(out, value);
111
52
    write_literal(out, "\"");
112
52
}
variant_string_parse_test.cpp:_ZN5doris12variant_json19write_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
}
_ZN5doris12variant_json19write_quoted_scalarINS_14BufferWritableEEEvRT_RKNS0_15FormattedScalarE
Line
Count
Source
108
6
void write_quoted_scalar(Writer& out, const FormattedScalar& value) {
109
6
    write_literal(out, "\"");
110
6
    write_scalar(out, value);
111
6
    write_literal(out, "\"");
112
6
}
unity_5_cxx.cxx:_ZN5doris12variant_json19write_quoted_scalarINS_12_GLOBAL__N_114CountingWriterEEEvRT_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
}
unity_5_cxx.cxx:_ZN5doris12variant_json19write_quoted_scalarINS_12_GLOBAL__N_111FixedWriterEEEvRT_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
}
113
114
template <typename Writer>
115
113k
void write_escaped_json_string(Writer& out, StringRef value) {
116
113k
    write_literal(out, "\"");
117
113k
    size_t plain_begin = 0;
118
113k
    size_t index = 0;
119
2.69M
    while (index < value.size) {
120
2.57M
        const auto byte = static_cast<uint8_t>(value.data[index]);
121
2.57M
        const char* escaped = nullptr;
122
2.57M
        size_t escaped_size = 0;
123
2.57M
        size_t consumed = 1;
124
2.57M
        switch (byte) {
125
57
        case '"':
126
57
            escaped = "\\\"";
127
57
            escaped_size = 2;
128
57
            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
21
        case '\n':
142
21
            escaped = "\\n";
143
21
            escaped_size = 2;
144
21
            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
2.57M
        default:
154
2.57M
            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
2.57M
            if (index + 2 < value.size && byte == 0xE2 &&
166
2.57M
                static_cast<uint8_t>(value.data[index + 1]) == 0x80 &&
167
2.57M
                (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
2.57M
            break;
175
2.57M
        }
176
2.57M
        if (escaped == nullptr) {
177
2.57M
            ++index;
178
2.57M
            continue;
179
2.57M
        }
180
83
        if (index != plain_begin) {
181
62
            out.write(value.data + plain_begin, index - plain_begin);
182
62
        }
183
83
        out.write(escaped, escaped_size);
184
83
        index += consumed;
185
83
        plain_begin = index;
186
83
    }
187
113k
    if (plain_begin != value.size) {
188
113k
        out.write(value.data + plain_begin, value.size - plain_begin);
189
113k
    }
190
113k
    write_literal(out, "\"");
191
113k
}
column_variant_v2_test.cpp:_ZN5doris12variant_json25write_escaped_json_stringINS_12_GLOBAL__N_110JsonWriterEEEvRT_NS_9StringRefE
Line
Count
Source
115
97
void write_escaped_json_string(Writer& out, StringRef value) {
116
97
    write_literal(out, "\"");
117
97
    size_t plain_begin = 0;
118
97
    size_t index = 0;
119
202
    while (index < value.size) {
120
105
        const auto byte = static_cast<uint8_t>(value.data[index]);
121
105
        const char* escaped = nullptr;
122
105
        size_t escaped_size = 0;
123
105
        size_t consumed = 1;
124
105
        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
105
        default:
154
105
            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
105
            if (index + 2 < value.size && byte == 0xE2 &&
166
105
                static_cast<uint8_t>(value.data[index + 1]) == 0x80 &&
167
105
                (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
105
            break;
175
105
        }
176
105
        if (escaped == nullptr) {
177
105
            ++index;
178
105
            continue;
179
105
        }
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
97
    if (plain_begin != value.size) {
188
97
        out.write(value.data + plain_begin, value.size - plain_begin);
189
97
    }
190
97
    write_literal(out, "\"");
191
97
}
function_variant_parse_test.cpp:_ZN5doris12variant_json25write_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
}
segment_flusher_format_test.cpp:_ZN5doris12variant_json25write_escaped_json_stringIZNS_12_GLOBAL__N_118variant_field_jsonB5cxx11ERKNS_12VariantFieldEE12StringWriterEEvRT_NS_9StringRefE
Line
Count
Source
115
64
void write_escaped_json_string(Writer& out, StringRef value) {
116
64
    write_literal(out, "\"");
117
64
    size_t plain_begin = 0;
118
64
    size_t index = 0;
119
336
    while (index < value.size) {
120
272
        const auto byte = static_cast<uint8_t>(value.data[index]);
121
272
        const char* escaped = nullptr;
122
272
        size_t escaped_size = 0;
123
272
        size_t consumed = 1;
124
272
        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
272
        default:
154
272
            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
272
            if (index + 2 < value.size && byte == 0xE2 &&
166
272
                static_cast<uint8_t>(value.data[index + 1]) == 0x80 &&
167
272
                (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
272
            break;
175
272
        }
176
272
        if (escaped == nullptr) {
177
272
            ++index;
178
272
            continue;
179
272
        }
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
64
    if (plain_begin != value.size) {
188
64
        out.write(value.data + plain_begin, value.size - plain_begin);
189
64
    }
190
64
    write_literal(out, "\"");
191
64
}
hierarchical_data_iterator_test.cpp:_ZN5doris12variant_json25write_escaped_json_stringINS_12_GLOBAL__N_117VariantJsonWriterEEEvRT_NS_9StringRefE
Line
Count
Source
115
8
void write_escaped_json_string(Writer& out, StringRef value) {
116
8
    write_literal(out, "\"");
117
8
    size_t plain_begin = 0;
118
8
    size_t index = 0;
119
33
    while (index < value.size) {
120
25
        const auto byte = static_cast<uint8_t>(value.data[index]);
121
25
        const char* escaped = nullptr;
122
25
        size_t escaped_size = 0;
123
25
        size_t consumed = 1;
124
25
        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
25
        default:
154
25
            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
25
            if (index + 2 < value.size && byte == 0xE2 &&
166
25
                static_cast<uint8_t>(value.data[index + 1]) == 0x80 &&
167
25
                (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
25
            break;
175
25
        }
176
25
        if (escaped == nullptr) {
177
25
            ++index;
178
25
            continue;
179
25
        }
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
8
    if (plain_begin != value.size) {
188
8
        out.write(value.data + plain_begin, value.size - plain_begin);
189
8
    }
190
8
    write_literal(out, "\"");
191
8
}
variant_assembler_legacy_test.cpp:_ZN5doris12variant_json25write_escaped_json_stringINS_10segment_v210variant_v212_GLOBAL__N_110JsonWriterEEEvRT_NS_9StringRefE
Line
Count
Source
115
84
void write_escaped_json_string(Writer& out, StringRef value) {
116
84
    write_literal(out, "\"");
117
84
    size_t plain_begin = 0;
118
84
    size_t index = 0;
119
268
    while (index < value.size) {
120
184
        const auto byte = static_cast<uint8_t>(value.data[index]);
121
184
        const char* escaped = nullptr;
122
184
        size_t escaped_size = 0;
123
184
        size_t consumed = 1;
124
184
        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
184
        default:
154
184
            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
184
            if (index + 2 < value.size && byte == 0xE2 &&
166
184
                static_cast<uint8_t>(value.data[index + 1]) == 0x80 &&
167
184
                (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
184
            break;
175
184
        }
176
184
        if (escaped == nullptr) {
177
184
            ++index;
178
184
            continue;
179
184
        }
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
84
    if (plain_begin != value.size) {
188
82
        out.write(value.data + plain_begin, value.size - plain_begin);
189
82
    }
190
84
    write_literal(out, "\"");
191
84
}
variant_string_parse_test.cpp:_ZN5doris12variant_json25write_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
}
_ZN5doris12variant_json25write_escaped_json_stringINS_14BufferWritableEEEvRT_NS_9StringRefE
Line
Count
Source
115
56.3k
void write_escaped_json_string(Writer& out, StringRef value) {
116
56.3k
    write_literal(out, "\"");
117
56.3k
    size_t plain_begin = 0;
118
56.3k
    size_t index = 0;
119
1.34M
    while (index < value.size) {
120
1.28M
        const auto byte = static_cast<uint8_t>(value.data[index]);
121
1.28M
        const char* escaped = nullptr;
122
1.28M
        size_t escaped_size = 0;
123
1.28M
        size_t consumed = 1;
124
1.28M
        switch (byte) {
125
11
        case '"':
126
11
            escaped = "\\\"";
127
11
            escaped_size = 2;
128
11
            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
5
        case '\n':
142
5
            escaped = "\\n";
143
5
            escaped_size = 2;
144
5
            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
1.28M
        default:
154
1.28M
            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
1.28M
            if (index + 2 < value.size && byte == 0xE2 &&
166
1.28M
                static_cast<uint8_t>(value.data[index + 1]) == 0x80 &&
167
1.28M
                (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
1.28M
            break;
175
1.28M
        }
176
1.28M
        if (escaped == nullptr) {
177
1.28M
            ++index;
178
1.28M
            continue;
179
1.28M
        }
180
17
        if (index != plain_begin) {
181
13
            out.write(value.data + plain_begin, index - plain_begin);
182
13
        }
183
17
        out.write(escaped, escaped_size);
184
17
        index += consumed;
185
17
        plain_begin = index;
186
17
    }
187
56.3k
    if (plain_begin != value.size) {
188
56.3k
        out.write(value.data + plain_begin, value.size - plain_begin);
189
56.3k
    }
190
56.3k
    write_literal(out, "\"");
191
56.3k
}
unity_5_cxx.cxx:_ZN5doris12variant_json25write_escaped_json_stringINS_12_GLOBAL__N_114CountingWriterEEEvRT_NS_9StringRefE
Line
Count
Source
115
56.3k
void write_escaped_json_string(Writer& out, StringRef value) {
116
56.3k
    write_literal(out, "\"");
117
56.3k
    size_t plain_begin = 0;
118
56.3k
    size_t index = 0;
119
1.34M
    while (index < value.size) {
120
1.28M
        const auto byte = static_cast<uint8_t>(value.data[index]);
121
1.28M
        const char* escaped = nullptr;
122
1.28M
        size_t escaped_size = 0;
123
1.28M
        size_t consumed = 1;
124
1.28M
        switch (byte) {
125
27
        case '"':
126
27
            escaped = "\\\"";
127
27
            escaped_size = 2;
128
27
            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
9
        case '\n':
142
9
            escaped = "\\n";
143
9
            escaped_size = 2;
144
9
            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
1.28M
        default:
154
1.28M
            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
1.28M
            if (index + 2 < value.size && byte == 0xE2 &&
166
1.28M
                static_cast<uint8_t>(value.data[index + 1]) == 0x80 &&
167
1.28M
                (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
1.28M
            break;
175
1.28M
        }
176
1.28M
        if (escaped == nullptr) {
177
1.28M
            ++index;
178
1.28M
            continue;
179
1.28M
        }
180
37
        if (index != plain_begin) {
181
29
            out.write(value.data + plain_begin, index - plain_begin);
182
29
        }
183
37
        out.write(escaped, escaped_size);
184
37
        index += consumed;
185
37
        plain_begin = index;
186
37
    }
187
56.3k
    if (plain_begin != value.size) {
188
56.3k
        out.write(value.data + plain_begin, value.size - plain_begin);
189
56.3k
    }
190
56.3k
    write_literal(out, "\"");
191
56.3k
}
unity_5_cxx.cxx:_ZN5doris12variant_json25write_escaped_json_stringINS_12_GLOBAL__N_111FixedWriterEEEvRT_NS_9StringRefE
Line
Count
Source
115
31
void write_escaped_json_string(Writer& out, StringRef value) {
116
31
    write_literal(out, "\"");
117
31
    size_t plain_begin = 0;
118
31
    size_t index = 0;
119
158
    while (index < value.size) {
120
127
        const auto byte = static_cast<uint8_t>(value.data[index]);
121
127
        const char* escaped = nullptr;
122
127
        size_t escaped_size = 0;
123
127
        size_t consumed = 1;
124
127
        switch (byte) {
125
18
        case '"':
126
18
            escaped = "\\\"";
127
18
            escaped_size = 2;
128
18
            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
6
        case '\n':
142
6
            escaped = "\\n";
143
6
            escaped_size = 2;
144
6
            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
103
        default:
154
103
            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
103
            if (index + 2 < value.size && byte == 0xE2 &&
166
103
                static_cast<uint8_t>(value.data[index + 1]) == 0x80 &&
167
103
                (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
103
            break;
175
127
        }
176
127
        if (escaped == nullptr) {
177
103
            ++index;
178
103
            continue;
179
103
        }
180
24
        if (index != plain_begin) {
181
18
            out.write(value.data + plain_begin, index - plain_begin);
182
18
        }
183
24
        out.write(escaped, escaped_size);
184
24
        index += consumed;
185
24
        plain_begin = index;
186
24
    }
187
31
    if (plain_begin != value.size) {
188
19
        out.write(value.data + plain_begin, value.size - plain_begin);
189
19
    }
190
31
    write_literal(out, "\"");
191
31
}
192
193
template <typename Writer>
194
35.8k
void write_json_string(Writer& out, StringRef value, const char* description) {
195
35.8k
    require_valid_json_utf8(value, description);
196
35.8k
    write_escaped_json_string(out, value);
197
35.8k
}
Unexecuted instantiation: column_variant_v2_test.cpp:_ZN5doris12variant_json17write_json_stringINS_12_GLOBAL__N_110JsonWriterEEEvRT_NS_9StringRefEPKc
function_variant_parse_test.cpp:_ZN5doris12variant_json17write_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
}
segment_flusher_format_test.cpp:_ZN5doris12variant_json17write_json_stringIZNS_12_GLOBAL__N_118variant_field_jsonB5cxx11ERKNS_12VariantFieldEE12StringWriterEEvRT_NS_9StringRefEPKc
Line
Count
Source
194
8
void write_json_string(Writer& out, StringRef value, const char* description) {
195
8
    require_valid_json_utf8(value, description);
196
8
    write_escaped_json_string(out, value);
197
8
}
hierarchical_data_iterator_test.cpp:_ZN5doris12variant_json17write_json_stringINS_12_GLOBAL__N_117VariantJsonWriterEEEvRT_NS_9StringRefEPKc
Line
Count
Source
194
3
void write_json_string(Writer& out, StringRef value, const char* description) {
195
3
    require_valid_json_utf8(value, description);
196
3
    write_escaped_json_string(out, value);
197
3
}
variant_assembler_legacy_test.cpp:_ZN5doris12variant_json17write_json_stringINS_10segment_v210variant_v212_GLOBAL__N_110JsonWriterEEEvRT_NS_9StringRefEPKc
Line
Count
Source
194
13
void write_json_string(Writer& out, StringRef value, const char* description) {
195
13
    require_valid_json_utf8(value, description);
196
13
    write_escaped_json_string(out, value);
197
13
}
variant_string_parse_test.cpp:_ZN5doris12variant_json17write_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
}
_ZN5doris12variant_json17write_json_stringINS_14BufferWritableEEEvRT_NS_9StringRefEPKc
Line
Count
Source
194
17.9k
void write_json_string(Writer& out, StringRef value, const char* description) {
195
17.9k
    require_valid_json_utf8(value, description);
196
17.9k
    write_escaped_json_string(out, value);
197
17.9k
}
unity_5_cxx.cxx:_ZN5doris12variant_json17write_json_stringINS_12_GLOBAL__N_114CountingWriterEEEvRT_NS_9StringRefEPKc
Line
Count
Source
194
17.9k
void write_json_string(Writer& out, StringRef value, const char* description) {
195
17.9k
    require_valid_json_utf8(value, description);
196
17.9k
    write_escaped_json_string(out, value);
197
17.9k
}
unity_5_cxx.cxx:_ZN5doris12variant_json17write_json_stringINS_12_GLOBAL__N_111FixedWriterEEEvRT_NS_9StringRefEPKc
Line
Count
Source
194
28
void write_json_string(Writer& out, StringRef value, const char* description) {
195
28
    require_valid_json_utf8(value, description);
196
28
    write_escaped_json_string(out, value);
197
28
}
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:_ZZN5doris12variant_json17write_json_binaryINS_12_GLOBAL__N_110JsonWriterEEEvRT_NS_9StringRefEENKUlvE_clEv
Unexecuted instantiation: function_variant_parse_test.cpp:_ZZN5doris12variant_json17write_json_binaryINS_12_GLOBAL__N_112StringWriterEEEvRT_NS_9StringRefEENKUlvE_clEv
Unexecuted instantiation: segment_flusher_format_test.cpp:_ZZN5doris12variant_json17write_json_binaryIZNS_12_GLOBAL__N_118variant_field_jsonB5cxx11ERKNS_12VariantFieldEE12StringWriterEEvRT_NS_9StringRefEENKUlvE_clEv
Unexecuted instantiation: hierarchical_data_iterator_test.cpp:_ZZN5doris12variant_json17write_json_binaryINS_12_GLOBAL__N_117VariantJsonWriterEEEvRT_NS_9StringRefEENKUlvE_clEv
Unexecuted instantiation: variant_assembler_legacy_test.cpp:_ZZN5doris12variant_json17write_json_binaryINS_10segment_v210variant_v212_GLOBAL__N_110JsonWriterEEEvRT_NS_9StringRefEENKUlvE_clEv
variant_string_parse_test.cpp:_ZZN5doris12variant_json17write_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
    };
_ZZN5doris12variant_json17write_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: unity_5_cxx.cxx:_ZZN5doris12variant_json17write_json_binaryINS_12_GLOBAL__N_114CountingWriterEEEvRT_NS_9StringRefEENKUlvE_clEv
Unexecuted instantiation: unity_5_cxx.cxx:_ZZN5doris12variant_json17write_json_binaryINS_12_GLOBAL__N_111FixedWriterEEEvRT_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:_ZN5doris12variant_json17write_json_binaryINS_12_GLOBAL__N_110JsonWriterEEEvRT_NS_9StringRefE
Unexecuted instantiation: function_variant_parse_test.cpp:_ZN5doris12variant_json17write_json_binaryINS_12_GLOBAL__N_112StringWriterEEEvRT_NS_9StringRefE
Unexecuted instantiation: segment_flusher_format_test.cpp:_ZN5doris12variant_json17write_json_binaryIZNS_12_GLOBAL__N_118variant_field_jsonB5cxx11ERKNS_12VariantFieldEE12StringWriterEEvRT_NS_9StringRefE
Unexecuted instantiation: hierarchical_data_iterator_test.cpp:_ZN5doris12variant_json17write_json_binaryINS_12_GLOBAL__N_117VariantJsonWriterEEEvRT_NS_9StringRefE
Unexecuted instantiation: variant_assembler_legacy_test.cpp:_ZN5doris12variant_json17write_json_binaryINS_10segment_v210variant_v212_GLOBAL__N_110JsonWriterEEEvRT_NS_9StringRefE
variant_string_parse_test.cpp:_ZN5doris12variant_json17write_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
}
_ZN5doris12variant_json17write_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: unity_5_cxx.cxx:_ZN5doris12variant_json17write_json_binaryINS_12_GLOBAL__N_114CountingWriterEEEvRT_NS_9StringRefE
Unexecuted instantiation: unity_5_cxx.cxx:_ZN5doris12variant_json17write_json_binaryINS_12_GLOBAL__N_111FixedWriterEEEvRT_NS_9StringRefE
246
247
template <typename Writer>
248
class Printer {
249
public:
250
26.8k
    Printer(Writer& out, const VariantJsonFormatOptions& options) : _out(out), _options(options) {}
column_variant_v2_test.cpp:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_110JsonWriterEEC2ERS3_RKNS_24VariantJsonFormatOptionsE
Line
Count
Source
250
143
    Printer(Writer& out, const VariantJsonFormatOptions& options) : _out(out), _options(options) {}
function_variant_parse_test.cpp:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_112StringWriterEEC2ERS3_RKNS_24VariantJsonFormatOptionsE
Line
Count
Source
250
13
    Printer(Writer& out, const VariantJsonFormatOptions& options) : _out(out), _options(options) {}
segment_flusher_format_test.cpp:_ZN5doris12variant_json7PrinterIZNS_12_GLOBAL__N_118variant_field_jsonB5cxx11ERKNS_12VariantFieldEE12StringWriterEC2ERS6_RKNS_24VariantJsonFormatOptionsE
Line
Count
Source
250
24
    Printer(Writer& out, const VariantJsonFormatOptions& options) : _out(out), _options(options) {}
hierarchical_data_iterator_test.cpp:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_117VariantJsonWriterEEC2ERS3_RKNS_24VariantJsonFormatOptionsE
Line
Count
Source
250
7
    Printer(Writer& out, const VariantJsonFormatOptions& options) : _out(out), _options(options) {}
variant_assembler_legacy_test.cpp:_ZN5doris12variant_json7PrinterINS_10segment_v210variant_v212_GLOBAL__N_110JsonWriterEEC2ERS5_RKNS_24VariantJsonFormatOptionsE
Line
Count
Source
250
153
    Printer(Writer& out, const VariantJsonFormatOptions& options) : _out(out), _options(options) {}
variant_string_parse_test.cpp:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_112StringWriterEEC2ERS3_RKNS_24VariantJsonFormatOptionsE
Line
Count
Source
250
47
    Printer(Writer& out, const VariantJsonFormatOptions& options) : _out(out), _options(options) {}
_ZN5doris12variant_json7PrinterINS_14BufferWritableEEC2ERS2_RKNS_24VariantJsonFormatOptionsE
Line
Count
Source
250
13.1k
    Printer(Writer& out, const VariantJsonFormatOptions& options) : _out(out), _options(options) {}
unity_5_cxx.cxx:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_114CountingWriterEEC2ERS3_RKNS_24VariantJsonFormatOptionsE
Line
Count
Source
250
13.2k
    Printer(Writer& out, const VariantJsonFormatOptions& options) : _out(out), _options(options) {}
unity_5_cxx.cxx:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_111FixedWriterEEC2ERS3_RKNS_24VariantJsonFormatOptionsE
Line
Count
Source
250
107
    Printer(Writer& out, const VariantJsonFormatOptions& options) : _out(out), _options(options) {}
251
252
104k
    void write(VariantRef value, uint32_t depth) {
253
104k
        require_json_depth(depth);
254
104k
        switch (value.basic_type()) {
255
35.8k
        case VariantBasicType::SHORT_STRING:
256
35.8k
            write_json_string(_out, value.get_string(), "string");
257
35.8k
            return;
258
42.9k
        case VariantBasicType::PRIMITIVE:
259
42.9k
            write_primitive(value);
260
42.9k
            return;
261
25.2k
        case VariantBasicType::OBJECT:
262
25.2k
            write_object(value, depth);
263
25.2k
            return;
264
403
        case VariantBasicType::ARRAY:
265
403
            write_array(value, depth);
266
403
            return;
267
104k
        }
268
104k
    }
column_variant_v2_test.cpp:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_110JsonWriterEE5writeENS_10VariantRefEj
Line
Count
Source
252
259
    void write(VariantRef value, uint32_t depth) {
253
259
        require_json_depth(depth);
254
259
        switch (value.basic_type()) {
255
0
        case VariantBasicType::SHORT_STRING:
256
0
            write_json_string(_out, value.get_string(), "string");
257
0
            return;
258
119
        case VariantBasicType::PRIMITIVE:
259
119
            write_primitive(value);
260
119
            return;
261
121
        case VariantBasicType::OBJECT:
262
121
            write_object(value, depth);
263
121
            return;
264
19
        case VariantBasicType::ARRAY:
265
19
            write_array(value, depth);
266
19
            return;
267
259
        }
268
259
    }
function_variant_parse_test.cpp:_ZN5doris12variant_json7PrinterINS_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
    }
segment_flusher_format_test.cpp:_ZN5doris12variant_json7PrinterIZNS_12_GLOBAL__N_118variant_field_jsonB5cxx11ERKNS_12VariantFieldEE12StringWriterE5writeENS_10VariantRefEj
Line
Count
Source
252
88
    void write(VariantRef value, uint32_t depth) {
253
88
        require_json_depth(depth);
254
88
        switch (value.basic_type()) {
255
8
        case VariantBasicType::SHORT_STRING:
256
8
            write_json_string(_out, value.get_string(), "string");
257
8
            return;
258
44
        case VariantBasicType::PRIMITIVE:
259
44
            write_primitive(value);
260
44
            return;
261
32
        case VariantBasicType::OBJECT:
262
32
            write_object(value, depth);
263
32
            return;
264
4
        case VariantBasicType::ARRAY:
265
4
            write_array(value, depth);
266
4
            return;
267
88
        }
268
88
    }
hierarchical_data_iterator_test.cpp:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_117VariantJsonWriterEE5writeENS_10VariantRefEj
Line
Count
Source
252
12
    void write(VariantRef value, uint32_t depth) {
253
12
        require_json_depth(depth);
254
12
        switch (value.basic_type()) {
255
3
        case VariantBasicType::SHORT_STRING:
256
3
            write_json_string(_out, value.get_string(), "string");
257
3
            return;
258
4
        case VariantBasicType::PRIMITIVE:
259
4
            write_primitive(value);
260
4
            return;
261
5
        case VariantBasicType::OBJECT:
262
5
            write_object(value, depth);
263
5
            return;
264
0
        case VariantBasicType::ARRAY:
265
0
            write_array(value, depth);
266
0
            return;
267
12
        }
268
12
    }
variant_assembler_legacy_test.cpp:_ZN5doris12variant_json7PrinterINS_10segment_v210variant_v212_GLOBAL__N_110JsonWriterEE5writeENS_10VariantRefEj
Line
Count
Source
252
252
    void write(VariantRef value, uint32_t depth) {
253
252
        require_json_depth(depth);
254
252
        switch (value.basic_type()) {
255
13
        case VariantBasicType::SHORT_STRING:
256
13
            write_json_string(_out, value.get_string(), "string");
257
13
            return;
258
163
        case VariantBasicType::PRIMITIVE:
259
163
            write_primitive(value);
260
163
            return;
261
56
        case VariantBasicType::OBJECT:
262
56
            write_object(value, depth);
263
56
            return;
264
20
        case VariantBasicType::ARRAY:
265
20
            write_array(value, depth);
266
20
            return;
267
252
        }
268
252
    }
variant_string_parse_test.cpp:_ZN5doris12variant_json7PrinterINS_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
    }
_ZN5doris12variant_json7PrinterINS_14BufferWritableEE5writeENS_10VariantRefEj
Line
Count
Source
252
51.6k
    void write(VariantRef value, uint32_t depth) {
253
51.6k
        require_json_depth(depth);
254
51.6k
        switch (value.basic_type()) {
255
17.9k
        case VariantBasicType::SHORT_STRING:
256
17.9k
            write_json_string(_out, value.get_string(), "string");
257
17.9k
            return;
258
21.2k
        case VariantBasicType::PRIMITIVE:
259
21.2k
            write_primitive(value);
260
21.2k
            return;
261
12.4k
        case VariantBasicType::OBJECT:
262
12.4k
            write_object(value, depth);
263
12.4k
            return;
264
44
        case VariantBasicType::ARRAY:
265
44
            write_array(value, depth);
266
44
            return;
267
51.6k
        }
268
51.6k
    }
unity_5_cxx.cxx:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_114CountingWriterEE5writeENS_10VariantRefEj
Line
Count
Source
252
51.7k
    void write(VariantRef value, uint32_t depth) {
253
51.7k
        require_json_depth(depth);
254
51.7k
        switch (value.basic_type()) {
255
17.9k
        case VariantBasicType::SHORT_STRING:
256
17.9k
            write_json_string(_out, value.get_string(), "string");
257
17.9k
            return;
258
21.2k
        case VariantBasicType::PRIMITIVE:
259
21.2k
            write_primitive(value);
260
21.2k
            return;
261
12.4k
        case VariantBasicType::OBJECT:
262
12.4k
            write_object(value, depth);
263
12.4k
            return;
264
45
        case VariantBasicType::ARRAY:
265
45
            write_array(value, depth);
266
45
            return;
267
51.7k
        }
268
51.7k
    }
unity_5_cxx.cxx:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_111FixedWriterEE5writeENS_10VariantRefEj
Line
Count
Source
252
95
    void write(VariantRef value, uint32_t depth) {
253
95
        require_json_depth(depth);
254
95
        switch (value.basic_type()) {
255
28
        case VariantBasicType::SHORT_STRING:
256
28
            write_json_string(_out, value.get_string(), "string");
257
28
            return;
258
58
        case VariantBasicType::PRIMITIVE:
259
58
            write_primitive(value);
260
58
            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
95
        }
268
95
    }
269
270
103
    void write_plain_scalar(VariantRef value) {
271
103
        require_json_depth(0);
272
103
        if (value.basic_type() == VariantBasicType::SHORT_STRING) {
273
27
            const StringRef string = value.get_string();
274
27
            require_valid_json_utf8(string, "string");
275
27
            _out.write(string.data, string.size);
276
27
            return;
277
27
        }
278
76
        if (value.basic_type() != VariantBasicType::PRIMITIVE) {
279
8
            write(value, 0);
280
8
            return;
281
8
        }
282
283
68
        switch (value.primitive_id()) {
284
0
        case VariantPrimitiveId::STRING: {
285
0
            const StringRef string = value.get_string();
286
0
            require_valid_json_utf8(string, "string");
287
0
            _out.write(string.data, string.size);
288
0
            return;
289
0
        }
290
8
        case VariantPrimitiveId::DATE:
291
8
            write_scalar(_out, format_json_date(value.get_date()));
292
8
            return;
293
0
        case VariantPrimitiveId::TIMESTAMP_MICROS:
294
0
            write_scalar(_out, format_json_timestamp(value.get_timestamp_micros(), 6, true,
295
0
                                                     _options.timezone));
296
0
            return;
297
8
        case VariantPrimitiveId::TIMESTAMP_NTZ_MICROS:
298
8
            write_scalar(_out, format_json_timestamp(value.get_timestamp_ntz_micros(), 6, false,
299
8
                                                     nullptr));
300
8
            return;
301
0
        case VariantPrimitiveId::TIME_NTZ_MICROS:
302
0
            write_scalar(_out, format_json_time_micros(value.get_time_ntz_micros()));
303
0
            return;
304
0
        case VariantPrimitiveId::TIMESTAMP_NANOS:
305
0
            write_scalar(_out, format_json_timestamp(value.get_timestamp_nanos(), 9, true,
306
0
                                                     _options.timezone));
307
0
            return;
308
0
        case VariantPrimitiveId::TIMESTAMP_NTZ_NANOS:
309
0
            write_scalar(_out,
310
0
                         format_json_timestamp(value.get_timestamp_ntz_nanos(), 9, false, nullptr));
311
0
            return;
312
0
        case VariantPrimitiveId::UUID:
313
0
            write_scalar(_out, format_json_uuid(value.get_uuid()));
314
0
            return;
315
52
        default:
316
52
            write_primitive(value);
317
52
            return;
318
68
        }
319
68
    }
_ZN5doris12variant_json7PrinterINS_14BufferWritableEE18write_plain_scalarENS_10VariantRefE
Line
Count
Source
270
51
    void write_plain_scalar(VariantRef value) {
271
51
        require_json_depth(0);
272
51
        if (value.basic_type() == VariantBasicType::SHORT_STRING) {
273
13
            const StringRef string = value.get_string();
274
13
            require_valid_json_utf8(string, "string");
275
13
            _out.write(string.data, string.size);
276
13
            return;
277
13
        }
278
38
        if (value.basic_type() != VariantBasicType::PRIMITIVE) {
279
4
            write(value, 0);
280
4
            return;
281
4
        }
282
283
34
        switch (value.primitive_id()) {
284
0
        case VariantPrimitiveId::STRING: {
285
0
            const StringRef string = value.get_string();
286
0
            require_valid_json_utf8(string, "string");
287
0
            _out.write(string.data, string.size);
288
0
            return;
289
0
        }
290
4
        case VariantPrimitiveId::DATE:
291
4
            write_scalar(_out, format_json_date(value.get_date()));
292
4
            return;
293
0
        case VariantPrimitiveId::TIMESTAMP_MICROS:
294
0
            write_scalar(_out, format_json_timestamp(value.get_timestamp_micros(), 6, true,
295
0
                                                     _options.timezone));
296
0
            return;
297
4
        case VariantPrimitiveId::TIMESTAMP_NTZ_MICROS:
298
4
            write_scalar(_out, format_json_timestamp(value.get_timestamp_ntz_micros(), 6, false,
299
4
                                                     nullptr));
300
4
            return;
301
0
        case VariantPrimitiveId::TIME_NTZ_MICROS:
302
0
            write_scalar(_out, format_json_time_micros(value.get_time_ntz_micros()));
303
0
            return;
304
0
        case VariantPrimitiveId::TIMESTAMP_NANOS:
305
0
            write_scalar(_out, format_json_timestamp(value.get_timestamp_nanos(), 9, true,
306
0
                                                     _options.timezone));
307
0
            return;
308
0
        case VariantPrimitiveId::TIMESTAMP_NTZ_NANOS:
309
0
            write_scalar(_out,
310
0
                         format_json_timestamp(value.get_timestamp_ntz_nanos(), 9, false, nullptr));
311
0
            return;
312
0
        case VariantPrimitiveId::UUID:
313
0
            write_scalar(_out, format_json_uuid(value.get_uuid()));
314
0
            return;
315
26
        default:
316
26
            write_primitive(value);
317
26
            return;
318
34
        }
319
34
    }
unity_5_cxx.cxx:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_114CountingWriterEE18write_plain_scalarENS_10VariantRefE
Line
Count
Source
270
26
    void write_plain_scalar(VariantRef value) {
271
26
        require_json_depth(0);
272
26
        if (value.basic_type() == VariantBasicType::SHORT_STRING) {
273
7
            const StringRef string = value.get_string();
274
7
            require_valid_json_utf8(string, "string");
275
7
            _out.write(string.data, string.size);
276
7
            return;
277
7
        }
278
19
        if (value.basic_type() != VariantBasicType::PRIMITIVE) {
279
2
            write(value, 0);
280
2
            return;
281
2
        }
282
283
17
        switch (value.primitive_id()) {
284
0
        case VariantPrimitiveId::STRING: {
285
0
            const StringRef string = value.get_string();
286
0
            require_valid_json_utf8(string, "string");
287
0
            _out.write(string.data, string.size);
288
0
            return;
289
0
        }
290
2
        case VariantPrimitiveId::DATE:
291
2
            write_scalar(_out, format_json_date(value.get_date()));
292
2
            return;
293
0
        case VariantPrimitiveId::TIMESTAMP_MICROS:
294
0
            write_scalar(_out, format_json_timestamp(value.get_timestamp_micros(), 6, true,
295
0
                                                     _options.timezone));
296
0
            return;
297
2
        case VariantPrimitiveId::TIMESTAMP_NTZ_MICROS:
298
2
            write_scalar(_out, format_json_timestamp(value.get_timestamp_ntz_micros(), 6, false,
299
2
                                                     nullptr));
300
2
            return;
301
0
        case VariantPrimitiveId::TIME_NTZ_MICROS:
302
0
            write_scalar(_out, format_json_time_micros(value.get_time_ntz_micros()));
303
0
            return;
304
0
        case VariantPrimitiveId::TIMESTAMP_NANOS:
305
0
            write_scalar(_out, format_json_timestamp(value.get_timestamp_nanos(), 9, true,
306
0
                                                     _options.timezone));
307
0
            return;
308
0
        case VariantPrimitiveId::TIMESTAMP_NTZ_NANOS:
309
0
            write_scalar(_out,
310
0
                         format_json_timestamp(value.get_timestamp_ntz_nanos(), 9, false, nullptr));
311
0
            return;
312
0
        case VariantPrimitiveId::UUID:
313
0
            write_scalar(_out, format_json_uuid(value.get_uuid()));
314
0
            return;
315
13
        default:
316
13
            write_primitive(value);
317
13
            return;
318
17
        }
319
17
    }
unity_5_cxx.cxx:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_111FixedWriterEE18write_plain_scalarENS_10VariantRefE
Line
Count
Source
270
26
    void write_plain_scalar(VariantRef value) {
271
26
        require_json_depth(0);
272
26
        if (value.basic_type() == VariantBasicType::SHORT_STRING) {
273
7
            const StringRef string = value.get_string();
274
7
            require_valid_json_utf8(string, "string");
275
7
            _out.write(string.data, string.size);
276
7
            return;
277
7
        }
278
19
        if (value.basic_type() != VariantBasicType::PRIMITIVE) {
279
2
            write(value, 0);
280
2
            return;
281
2
        }
282
283
17
        switch (value.primitive_id()) {
284
0
        case VariantPrimitiveId::STRING: {
285
0
            const StringRef string = value.get_string();
286
0
            require_valid_json_utf8(string, "string");
287
0
            _out.write(string.data, string.size);
288
0
            return;
289
0
        }
290
2
        case VariantPrimitiveId::DATE:
291
2
            write_scalar(_out, format_json_date(value.get_date()));
292
2
            return;
293
0
        case VariantPrimitiveId::TIMESTAMP_MICROS:
294
0
            write_scalar(_out, format_json_timestamp(value.get_timestamp_micros(), 6, true,
295
0
                                                     _options.timezone));
296
0
            return;
297
2
        case VariantPrimitiveId::TIMESTAMP_NTZ_MICROS:
298
2
            write_scalar(_out, format_json_timestamp(value.get_timestamp_ntz_micros(), 6, false,
299
2
                                                     nullptr));
300
2
            return;
301
0
        case VariantPrimitiveId::TIME_NTZ_MICROS:
302
0
            write_scalar(_out, format_json_time_micros(value.get_time_ntz_micros()));
303
0
            return;
304
0
        case VariantPrimitiveId::TIMESTAMP_NANOS:
305
0
            write_scalar(_out, format_json_timestamp(value.get_timestamp_nanos(), 9, true,
306
0
                                                     _options.timezone));
307
0
            return;
308
0
        case VariantPrimitiveId::TIMESTAMP_NTZ_NANOS:
309
0
            write_scalar(_out,
310
0
                         format_json_timestamp(value.get_timestamp_ntz_nanos(), 9, false, nullptr));
311
0
            return;
312
0
        case VariantPrimitiveId::UUID:
313
0
            write_scalar(_out, format_json_uuid(value.get_uuid()));
314
0
            return;
315
13
        default:
316
13
            write_primitive(value);
317
13
            return;
318
17
        }
319
17
    }
320
321
private:
322
42.9k
    void write_primitive(VariantRef value) {
323
42.9k
        const VariantPrimitiveId id = value.primitive_id();
324
42.9k
        switch (id) {
325
132
        case VariantPrimitiveId::NULL_VALUE:
326
132
            write_literal(_out, "null");
327
132
            return;
328
37
        case VariantPrimitiveId::TRUE_VALUE:
329
37
            write_literal(_out, "true");
330
37
            return;
331
3
        case VariantPrimitiveId::FALSE_VALUE:
332
3
            write_literal(_out, "false");
333
3
            return;
334
42.0k
        case VariantPrimitiveId::INT8:
335
42.5k
        case VariantPrimitiveId::INT16:
336
42.5k
        case VariantPrimitiveId::INT32:
337
42.5k
        case VariantPrimitiveId::INT64:
338
42.5k
            write_scalar(_out, format_json_int(value.get_int()));
339
42.5k
            return;
340
128
        case VariantPrimitiveId::DOUBLE: {
341
128
            const double number = value.get_double();
342
128
            if (!std::isfinite(number)) {
343
73
                write_non_finite(number);
344
73
                return;
345
73
            }
346
55
            write_scalar(_out, format_json_double(number));
347
55
            return;
348
128
        }
349
3
        case VariantPrimitiveId::DECIMAL4:
350
13
        case VariantPrimitiveId::DECIMAL8:
351
25
        case VariantPrimitiveId::DECIMAL16:
352
25
            write_scalar(_out, format_json_decimal(value.get_decimal()));
353
25
            return;
354
61
        case VariantPrimitiveId::DATE:
355
61
            write_quoted_scalar(_out, format_json_date(value.get_date()));
356
61
            return;
357
5
        case VariantPrimitiveId::TIMESTAMP_MICROS:
358
5
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_micros(), 6, true,
359
5
                                                            _options.timezone));
360
5
            return;
361
26
        case VariantPrimitiveId::TIMESTAMP_NTZ_MICROS:
362
26
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_ntz_micros(), 6,
363
26
                                                            false, nullptr));
364
26
            return;
365
6
        case VariantPrimitiveId::FLOAT: {
366
6
            const float number = value.get_float();
367
6
            if (!std::isfinite(number)) {
368
2
                write_non_finite(number);
369
2
                return;
370
2
            }
371
4
            write_scalar(_out, format_json_float(number));
372
4
            return;
373
6
        }
374
2
        case VariantPrimitiveId::BINARY:
375
2
            write_json_binary(_out, value.get_binary());
376
2
            return;
377
3
        case VariantPrimitiveId::STRING:
378
3
            write_json_string(_out, value.get_string(), "string");
379
3
            return;
380
2
        case VariantPrimitiveId::TIME_NTZ_MICROS:
381
2
            write_quoted_scalar(_out, format_json_time_micros(value.get_time_ntz_micros()));
382
2
            return;
383
3
        case VariantPrimitiveId::TIMESTAMP_NANOS:
384
3
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_nanos(), 9, true,
385
3
                                                            _options.timezone));
386
3
            return;
387
4
        case VariantPrimitiveId::TIMESTAMP_NTZ_NANOS:
388
4
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_ntz_nanos(), 9,
389
4
                                                            false, nullptr));
390
4
            return;
391
2
        case VariantPrimitiveId::UUID:
392
2
            write_quoted_scalar(_out, format_json_uuid(value.get_uuid()));
393
2
            return;
394
42.9k
        }
395
0
        throw_unsupported_json_primitive(id);
396
0
    }
column_variant_v2_test.cpp:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_110JsonWriterEE15write_primitiveENS_10VariantRefE
Line
Count
Source
322
119
    void write_primitive(VariantRef value) {
323
119
        const VariantPrimitiveId id = value.primitive_id();
324
119
        switch (id) {
325
0
        case VariantPrimitiveId::NULL_VALUE:
326
0
            write_literal(_out, "null");
327
0
            return;
328
0
        case VariantPrimitiveId::TRUE_VALUE:
329
0
            write_literal(_out, "true");
330
0
            return;
331
0
        case VariantPrimitiveId::FALSE_VALUE:
332
0
            write_literal(_out, "false");
333
0
            return;
334
119
        case VariantPrimitiveId::INT8:
335
119
        case VariantPrimitiveId::INT16:
336
119
        case VariantPrimitiveId::INT32:
337
119
        case VariantPrimitiveId::INT64:
338
119
            write_scalar(_out, format_json_int(value.get_int()));
339
119
            return;
340
0
        case VariantPrimitiveId::DOUBLE: {
341
0
            const double number = value.get_double();
342
0
            if (!std::isfinite(number)) {
343
0
                write_non_finite(number);
344
0
                return;
345
0
            }
346
0
            write_scalar(_out, format_json_double(number));
347
0
            return;
348
0
        }
349
0
        case VariantPrimitiveId::DECIMAL4:
350
0
        case VariantPrimitiveId::DECIMAL8:
351
0
        case VariantPrimitiveId::DECIMAL16:
352
0
            write_scalar(_out, format_json_decimal(value.get_decimal()));
353
0
            return;
354
0
        case VariantPrimitiveId::DATE:
355
0
            write_quoted_scalar(_out, format_json_date(value.get_date()));
356
0
            return;
357
0
        case VariantPrimitiveId::TIMESTAMP_MICROS:
358
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_micros(), 6, true,
359
0
                                                            _options.timezone));
360
0
            return;
361
0
        case VariantPrimitiveId::TIMESTAMP_NTZ_MICROS:
362
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_ntz_micros(), 6,
363
0
                                                            false, nullptr));
364
0
            return;
365
0
        case VariantPrimitiveId::FLOAT: {
366
0
            const float number = value.get_float();
367
0
            if (!std::isfinite(number)) {
368
0
                write_non_finite(number);
369
0
                return;
370
0
            }
371
0
            write_scalar(_out, format_json_float(number));
372
0
            return;
373
0
        }
374
0
        case VariantPrimitiveId::BINARY:
375
0
            write_json_binary(_out, value.get_binary());
376
0
            return;
377
0
        case VariantPrimitiveId::STRING:
378
0
            write_json_string(_out, value.get_string(), "string");
379
0
            return;
380
0
        case VariantPrimitiveId::TIME_NTZ_MICROS:
381
0
            write_quoted_scalar(_out, format_json_time_micros(value.get_time_ntz_micros()));
382
0
            return;
383
0
        case VariantPrimitiveId::TIMESTAMP_NANOS:
384
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_nanos(), 9, true,
385
0
                                                            _options.timezone));
386
0
            return;
387
0
        case VariantPrimitiveId::TIMESTAMP_NTZ_NANOS:
388
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_ntz_nanos(), 9,
389
0
                                                            false, nullptr));
390
0
            return;
391
0
        case VariantPrimitiveId::UUID:
392
0
            write_quoted_scalar(_out, format_json_uuid(value.get_uuid()));
393
0
            return;
394
119
        }
395
0
        throw_unsupported_json_primitive(id);
396
0
    }
function_variant_parse_test.cpp:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_112StringWriterEE15write_primitiveENS_10VariantRefE
Line
Count
Source
322
13
    void write_primitive(VariantRef value) {
323
13
        const VariantPrimitiveId id = value.primitive_id();
324
13
        switch (id) {
325
3
        case VariantPrimitiveId::NULL_VALUE:
326
3
            write_literal(_out, "null");
327
3
            return;
328
1
        case VariantPrimitiveId::TRUE_VALUE:
329
1
            write_literal(_out, "true");
330
1
            return;
331
0
        case VariantPrimitiveId::FALSE_VALUE:
332
0
            write_literal(_out, "false");
333
0
            return;
334
9
        case VariantPrimitiveId::INT8:
335
9
        case VariantPrimitiveId::INT16:
336
9
        case VariantPrimitiveId::INT32:
337
9
        case VariantPrimitiveId::INT64:
338
9
            write_scalar(_out, format_json_int(value.get_int()));
339
9
            return;
340
0
        case VariantPrimitiveId::DOUBLE: {
341
0
            const double number = value.get_double();
342
0
            if (!std::isfinite(number)) {
343
0
                write_non_finite(number);
344
0
                return;
345
0
            }
346
0
            write_scalar(_out, format_json_double(number));
347
0
            return;
348
0
        }
349
0
        case VariantPrimitiveId::DECIMAL4:
350
0
        case VariantPrimitiveId::DECIMAL8:
351
0
        case VariantPrimitiveId::DECIMAL16:
352
0
            write_scalar(_out, format_json_decimal(value.get_decimal()));
353
0
            return;
354
0
        case VariantPrimitiveId::DATE:
355
0
            write_quoted_scalar(_out, format_json_date(value.get_date()));
356
0
            return;
357
0
        case VariantPrimitiveId::TIMESTAMP_MICROS:
358
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_micros(), 6, true,
359
0
                                                            _options.timezone));
360
0
            return;
361
0
        case VariantPrimitiveId::TIMESTAMP_NTZ_MICROS:
362
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_ntz_micros(), 6,
363
0
                                                            false, nullptr));
364
0
            return;
365
0
        case VariantPrimitiveId::FLOAT: {
366
0
            const float number = value.get_float();
367
0
            if (!std::isfinite(number)) {
368
0
                write_non_finite(number);
369
0
                return;
370
0
            }
371
0
            write_scalar(_out, format_json_float(number));
372
0
            return;
373
0
        }
374
0
        case VariantPrimitiveId::BINARY:
375
0
            write_json_binary(_out, value.get_binary());
376
0
            return;
377
0
        case VariantPrimitiveId::STRING:
378
0
            write_json_string(_out, value.get_string(), "string");
379
0
            return;
380
0
        case VariantPrimitiveId::TIME_NTZ_MICROS:
381
0
            write_quoted_scalar(_out, format_json_time_micros(value.get_time_ntz_micros()));
382
0
            return;
383
0
        case VariantPrimitiveId::TIMESTAMP_NANOS:
384
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_nanos(), 9, true,
385
0
                                                            _options.timezone));
386
0
            return;
387
0
        case VariantPrimitiveId::TIMESTAMP_NTZ_NANOS:
388
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_ntz_nanos(), 9,
389
0
                                                            false, nullptr));
390
0
            return;
391
0
        case VariantPrimitiveId::UUID:
392
0
            write_quoted_scalar(_out, format_json_uuid(value.get_uuid()));
393
0
            return;
394
13
        }
395
0
        throw_unsupported_json_primitive(id);
396
0
    }
segment_flusher_format_test.cpp:_ZN5doris12variant_json7PrinterIZNS_12_GLOBAL__N_118variant_field_jsonB5cxx11ERKNS_12VariantFieldEE12StringWriterE15write_primitiveENS_10VariantRefE
Line
Count
Source
322
44
    void write_primitive(VariantRef value) {
323
44
        const VariantPrimitiveId id = value.primitive_id();
324
44
        switch (id) {
325
0
        case VariantPrimitiveId::NULL_VALUE:
326
0
            write_literal(_out, "null");
327
0
            return;
328
15
        case VariantPrimitiveId::TRUE_VALUE:
329
15
            write_literal(_out, "true");
330
15
            return;
331
0
        case VariantPrimitiveId::FALSE_VALUE:
332
0
            write_literal(_out, "false");
333
0
            return;
334
25
        case VariantPrimitiveId::INT8:
335
25
        case VariantPrimitiveId::INT16:
336
25
        case VariantPrimitiveId::INT32:
337
25
        case VariantPrimitiveId::INT64:
338
25
            write_scalar(_out, format_json_int(value.get_int()));
339
25
            return;
340
4
        case VariantPrimitiveId::DOUBLE: {
341
4
            const double number = value.get_double();
342
4
            if (!std::isfinite(number)) {
343
0
                write_non_finite(number);
344
0
                return;
345
0
            }
346
4
            write_scalar(_out, format_json_double(number));
347
4
            return;
348
4
        }
349
0
        case VariantPrimitiveId::DECIMAL4:
350
0
        case VariantPrimitiveId::DECIMAL8:
351
0
        case VariantPrimitiveId::DECIMAL16:
352
0
            write_scalar(_out, format_json_decimal(value.get_decimal()));
353
0
            return;
354
0
        case VariantPrimitiveId::DATE:
355
0
            write_quoted_scalar(_out, format_json_date(value.get_date()));
356
0
            return;
357
0
        case VariantPrimitiveId::TIMESTAMP_MICROS:
358
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_micros(), 6, true,
359
0
                                                            _options.timezone));
360
0
            return;
361
0
        case VariantPrimitiveId::TIMESTAMP_NTZ_MICROS:
362
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_ntz_micros(), 6,
363
0
                                                            false, nullptr));
364
0
            return;
365
0
        case VariantPrimitiveId::FLOAT: {
366
0
            const float number = value.get_float();
367
0
            if (!std::isfinite(number)) {
368
0
                write_non_finite(number);
369
0
                return;
370
0
            }
371
0
            write_scalar(_out, format_json_float(number));
372
0
            return;
373
0
        }
374
0
        case VariantPrimitiveId::BINARY:
375
0
            write_json_binary(_out, value.get_binary());
376
0
            return;
377
0
        case VariantPrimitiveId::STRING:
378
0
            write_json_string(_out, value.get_string(), "string");
379
0
            return;
380
0
        case VariantPrimitiveId::TIME_NTZ_MICROS:
381
0
            write_quoted_scalar(_out, format_json_time_micros(value.get_time_ntz_micros()));
382
0
            return;
383
0
        case VariantPrimitiveId::TIMESTAMP_NANOS:
384
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_nanos(), 9, true,
385
0
                                                            _options.timezone));
386
0
            return;
387
0
        case VariantPrimitiveId::TIMESTAMP_NTZ_NANOS:
388
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_ntz_nanos(), 9,
389
0
                                                            false, nullptr));
390
0
            return;
391
0
        case VariantPrimitiveId::UUID:
392
0
            write_quoted_scalar(_out, format_json_uuid(value.get_uuid()));
393
0
            return;
394
44
        }
395
0
        throw_unsupported_json_primitive(id);
396
0
    }
hierarchical_data_iterator_test.cpp:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_117VariantJsonWriterEE15write_primitiveENS_10VariantRefE
Line
Count
Source
322
4
    void write_primitive(VariantRef value) {
323
4
        const VariantPrimitiveId id = value.primitive_id();
324
4
        switch (id) {
325
2
        case VariantPrimitiveId::NULL_VALUE:
326
2
            write_literal(_out, "null");
327
2
            return;
328
0
        case VariantPrimitiveId::TRUE_VALUE:
329
0
            write_literal(_out, "true");
330
0
            return;
331
0
        case VariantPrimitiveId::FALSE_VALUE:
332
0
            write_literal(_out, "false");
333
0
            return;
334
2
        case VariantPrimitiveId::INT8:
335
2
        case VariantPrimitiveId::INT16:
336
2
        case VariantPrimitiveId::INT32:
337
2
        case VariantPrimitiveId::INT64:
338
2
            write_scalar(_out, format_json_int(value.get_int()));
339
2
            return;
340
0
        case VariantPrimitiveId::DOUBLE: {
341
0
            const double number = value.get_double();
342
0
            if (!std::isfinite(number)) {
343
0
                write_non_finite(number);
344
0
                return;
345
0
            }
346
0
            write_scalar(_out, format_json_double(number));
347
0
            return;
348
0
        }
349
0
        case VariantPrimitiveId::DECIMAL4:
350
0
        case VariantPrimitiveId::DECIMAL8:
351
0
        case VariantPrimitiveId::DECIMAL16:
352
0
            write_scalar(_out, format_json_decimal(value.get_decimal()));
353
0
            return;
354
0
        case VariantPrimitiveId::DATE:
355
0
            write_quoted_scalar(_out, format_json_date(value.get_date()));
356
0
            return;
357
0
        case VariantPrimitiveId::TIMESTAMP_MICROS:
358
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_micros(), 6, true,
359
0
                                                            _options.timezone));
360
0
            return;
361
0
        case VariantPrimitiveId::TIMESTAMP_NTZ_MICROS:
362
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_ntz_micros(), 6,
363
0
                                                            false, nullptr));
364
0
            return;
365
0
        case VariantPrimitiveId::FLOAT: {
366
0
            const float number = value.get_float();
367
0
            if (!std::isfinite(number)) {
368
0
                write_non_finite(number);
369
0
                return;
370
0
            }
371
0
            write_scalar(_out, format_json_float(number));
372
0
            return;
373
0
        }
374
0
        case VariantPrimitiveId::BINARY:
375
0
            write_json_binary(_out, value.get_binary());
376
0
            return;
377
0
        case VariantPrimitiveId::STRING:
378
0
            write_json_string(_out, value.get_string(), "string");
379
0
            return;
380
0
        case VariantPrimitiveId::TIME_NTZ_MICROS:
381
0
            write_quoted_scalar(_out, format_json_time_micros(value.get_time_ntz_micros()));
382
0
            return;
383
0
        case VariantPrimitiveId::TIMESTAMP_NANOS:
384
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_nanos(), 9, true,
385
0
                                                            _options.timezone));
386
0
            return;
387
0
        case VariantPrimitiveId::TIMESTAMP_NTZ_NANOS:
388
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_ntz_nanos(), 9,
389
0
                                                            false, nullptr));
390
0
            return;
391
0
        case VariantPrimitiveId::UUID:
392
0
            write_quoted_scalar(_out, format_json_uuid(value.get_uuid()));
393
0
            return;
394
4
        }
395
0
        throw_unsupported_json_primitive(id);
396
0
    }
variant_assembler_legacy_test.cpp:_ZN5doris12variant_json7PrinterINS_10segment_v210variant_v212_GLOBAL__N_110JsonWriterEE15write_primitiveENS_10VariantRefE
Line
Count
Source
322
163
    void write_primitive(VariantRef value) {
323
163
        const VariantPrimitiveId id = value.primitive_id();
324
163
        switch (id) {
325
46
        case VariantPrimitiveId::NULL_VALUE:
326
46
            write_literal(_out, "null");
327
46
            return;
328
2
        case VariantPrimitiveId::TRUE_VALUE:
329
2
            write_literal(_out, "true");
330
2
            return;
331
1
        case VariantPrimitiveId::FALSE_VALUE:
332
1
            write_literal(_out, "false");
333
1
            return;
334
31
        case VariantPrimitiveId::INT8:
335
32
        case VariantPrimitiveId::INT16:
336
34
        case VariantPrimitiveId::INT32:
337
36
        case VariantPrimitiveId::INT64:
338
36
            write_scalar(_out, format_json_int(value.get_int()));
339
36
            return;
340
2
        case VariantPrimitiveId::DOUBLE: {
341
2
            const double number = value.get_double();
342
2
            if (!std::isfinite(number)) {
343
0
                write_non_finite(number);
344
0
                return;
345
0
            }
346
2
            write_scalar(_out, format_json_double(number));
347
2
            return;
348
2
        }
349
2
        case VariantPrimitiveId::DECIMAL4:
350
11
        case VariantPrimitiveId::DECIMAL8:
351
21
        case VariantPrimitiveId::DECIMAL16:
352
21
            write_scalar(_out, format_json_decimal(value.get_decimal()));
353
21
            return;
354
40
        case VariantPrimitiveId::DATE:
355
40
            write_quoted_scalar(_out, format_json_date(value.get_date()));
356
40
            return;
357
2
        case VariantPrimitiveId::TIMESTAMP_MICROS:
358
2
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_micros(), 6, true,
359
2
                                                            _options.timezone));
360
2
            return;
361
8
        case VariantPrimitiveId::TIMESTAMP_NTZ_MICROS:
362
8
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_ntz_micros(), 6,
363
8
                                                            false, nullptr));
364
8
            return;
365
3
        case VariantPrimitiveId::FLOAT: {
366
3
            const float number = value.get_float();
367
3
            if (!std::isfinite(number)) {
368
0
                write_non_finite(number);
369
0
                return;
370
0
            }
371
3
            write_scalar(_out, format_json_float(number));
372
3
            return;
373
3
        }
374
0
        case VariantPrimitiveId::BINARY:
375
0
            write_json_binary(_out, value.get_binary());
376
0
            return;
377
0
        case VariantPrimitiveId::STRING:
378
0
            write_json_string(_out, value.get_string(), "string");
379
0
            return;
380
0
        case VariantPrimitiveId::TIME_NTZ_MICROS:
381
0
            write_quoted_scalar(_out, format_json_time_micros(value.get_time_ntz_micros()));
382
0
            return;
383
0
        case VariantPrimitiveId::TIMESTAMP_NANOS:
384
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_nanos(), 9, true,
385
0
                                                            _options.timezone));
386
0
            return;
387
2
        case VariantPrimitiveId::TIMESTAMP_NTZ_NANOS:
388
2
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_ntz_nanos(), 9,
389
2
                                                            false, nullptr));
390
2
            return;
391
0
        case VariantPrimitiveId::UUID:
392
0
            write_quoted_scalar(_out, format_json_uuid(value.get_uuid()));
393
0
            return;
394
163
        }
395
0
        throw_unsupported_json_primitive(id);
396
0
    }
variant_string_parse_test.cpp:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_112StringWriterEE15write_primitiveENS_10VariantRefE
Line
Count
Source
322
57
    void write_primitive(VariantRef value) {
323
57
        const VariantPrimitiveId id = value.primitive_id();
324
57
        switch (id) {
325
5
        case VariantPrimitiveId::NULL_VALUE:
326
5
            write_literal(_out, "null");
327
5
            return;
328
4
        case VariantPrimitiveId::TRUE_VALUE:
329
4
            write_literal(_out, "true");
330
4
            return;
331
2
        case VariantPrimitiveId::FALSE_VALUE:
332
2
            write_literal(_out, "false");
333
2
            return;
334
19
        case VariantPrimitiveId::INT8:
335
20
        case VariantPrimitiveId::INT16:
336
21
        case VariantPrimitiveId::INT32:
337
22
        case VariantPrimitiveId::INT64:
338
22
            write_scalar(_out, format_json_int(value.get_int()));
339
22
            return;
340
2
        case VariantPrimitiveId::DOUBLE: {
341
2
            const double number = value.get_double();
342
2
            if (!std::isfinite(number)) {
343
1
                write_non_finite(number);
344
1
                return;
345
1
            }
346
1
            write_scalar(_out, format_json_double(number));
347
1
            return;
348
2
        }
349
1
        case VariantPrimitiveId::DECIMAL4:
350
2
        case VariantPrimitiveId::DECIMAL8:
351
4
        case VariantPrimitiveId::DECIMAL16:
352
4
            write_scalar(_out, format_json_decimal(value.get_decimal()));
353
4
            return;
354
1
        case VariantPrimitiveId::DATE:
355
1
            write_quoted_scalar(_out, format_json_date(value.get_date()));
356
1
            return;
357
3
        case VariantPrimitiveId::TIMESTAMP_MICROS:
358
3
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_micros(), 6, true,
359
3
                                                            _options.timezone));
360
3
            return;
361
2
        case VariantPrimitiveId::TIMESTAMP_NTZ_MICROS:
362
2
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_ntz_micros(), 6,
363
2
                                                            false, nullptr));
364
2
            return;
365
3
        case VariantPrimitiveId::FLOAT: {
366
3
            const float number = value.get_float();
367
3
            if (!std::isfinite(number)) {
368
2
                write_non_finite(number);
369
2
                return;
370
2
            }
371
1
            write_scalar(_out, format_json_float(number));
372
1
            return;
373
3
        }
374
1
        case VariantPrimitiveId::BINARY:
375
1
            write_json_binary(_out, value.get_binary());
376
1
            return;
377
1
        case VariantPrimitiveId::STRING:
378
1
            write_json_string(_out, value.get_string(), "string");
379
1
            return;
380
1
        case VariantPrimitiveId::TIME_NTZ_MICROS:
381
1
            write_quoted_scalar(_out, format_json_time_micros(value.get_time_ntz_micros()));
382
1
            return;
383
3
        case VariantPrimitiveId::TIMESTAMP_NANOS:
384
3
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_nanos(), 9, true,
385
3
                                                            _options.timezone));
386
3
            return;
387
2
        case VariantPrimitiveId::TIMESTAMP_NTZ_NANOS:
388
2
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_ntz_nanos(), 9,
389
2
                                                            false, nullptr));
390
2
            return;
391
1
        case VariantPrimitiveId::UUID:
392
1
            write_quoted_scalar(_out, format_json_uuid(value.get_uuid()));
393
1
            return;
394
57
        }
395
0
        throw_unsupported_json_primitive(id);
396
0
    }
_ZN5doris12variant_json7PrinterINS_14BufferWritableEE15write_primitiveENS_10VariantRefE
Line
Count
Source
322
21.2k
    void write_primitive(VariantRef value) {
323
21.2k
        const VariantPrimitiveId id = value.primitive_id();
324
21.2k
        switch (id) {
325
28
        case VariantPrimitiveId::NULL_VALUE:
326
28
            write_literal(_out, "null");
327
28
            return;
328
8
        case VariantPrimitiveId::TRUE_VALUE:
329
8
            write_literal(_out, "true");
330
8
            return;
331
0
        case VariantPrimitiveId::FALSE_VALUE:
332
0
            write_literal(_out, "false");
333
0
            return;
334
20.9k
        case VariantPrimitiveId::INT8:
335
21.1k
        case VariantPrimitiveId::INT16:
336
21.1k
        case VariantPrimitiveId::INT32:
337
21.1k
        case VariantPrimitiveId::INT64:
338
21.1k
            write_scalar(_out, format_json_int(value.get_int()));
339
21.1k
            return;
340
30
        case VariantPrimitiveId::DOUBLE: {
341
30
            const double number = value.get_double();
342
30
            if (!std::isfinite(number)) {
343
18
                write_non_finite(number);
344
18
                return;
345
18
            }
346
12
            write_scalar(_out, format_json_double(number));
347
12
            return;
348
30
        }
349
0
        case VariantPrimitiveId::DECIMAL4:
350
0
        case VariantPrimitiveId::DECIMAL8:
351
0
        case VariantPrimitiveId::DECIMAL16:
352
0
            write_scalar(_out, format_json_decimal(value.get_decimal()));
353
0
            return;
354
2
        case VariantPrimitiveId::DATE:
355
2
            write_quoted_scalar(_out, format_json_date(value.get_date()));
356
2
            return;
357
0
        case VariantPrimitiveId::TIMESTAMP_MICROS:
358
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_micros(), 6, true,
359
0
                                                            _options.timezone));
360
0
            return;
361
2
        case VariantPrimitiveId::TIMESTAMP_NTZ_MICROS:
362
2
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_ntz_micros(), 6,
363
2
                                                            false, nullptr));
364
2
            return;
365
0
        case VariantPrimitiveId::FLOAT: {
366
0
            const float number = value.get_float();
367
0
            if (!std::isfinite(number)) {
368
0
                write_non_finite(number);
369
0
                return;
370
0
            }
371
0
            write_scalar(_out, format_json_float(number));
372
0
            return;
373
0
        }
374
1
        case VariantPrimitiveId::BINARY:
375
1
            write_json_binary(_out, value.get_binary());
376
1
            return;
377
1
        case VariantPrimitiveId::STRING:
378
1
            write_json_string(_out, value.get_string(), "string");
379
1
            return;
380
1
        case VariantPrimitiveId::TIME_NTZ_MICROS:
381
1
            write_quoted_scalar(_out, format_json_time_micros(value.get_time_ntz_micros()));
382
1
            return;
383
0
        case VariantPrimitiveId::TIMESTAMP_NANOS:
384
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_nanos(), 9, true,
385
0
                                                            _options.timezone));
386
0
            return;
387
0
        case VariantPrimitiveId::TIMESTAMP_NTZ_NANOS:
388
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_ntz_nanos(), 9,
389
0
                                                            false, nullptr));
390
0
            return;
391
1
        case VariantPrimitiveId::UUID:
392
1
            write_quoted_scalar(_out, format_json_uuid(value.get_uuid()));
393
1
            return;
394
21.2k
        }
395
0
        throw_unsupported_json_primitive(id);
396
0
    }
unity_5_cxx.cxx:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_114CountingWriterEE15write_primitiveENS_10VariantRefE
Line
Count
Source
322
21.2k
    void write_primitive(VariantRef value) {
323
21.2k
        const VariantPrimitiveId id = value.primitive_id();
324
21.2k
        switch (id) {
325
34
        case VariantPrimitiveId::NULL_VALUE:
326
34
            write_literal(_out, "null");
327
34
            return;
328
7
        case VariantPrimitiveId::TRUE_VALUE:
329
7
            write_literal(_out, "true");
330
7
            return;
331
0
        case VariantPrimitiveId::FALSE_VALUE:
332
0
            write_literal(_out, "false");
333
0
            return;
334
20.9k
        case VariantPrimitiveId::INT8:
335
21.1k
        case VariantPrimitiveId::INT16:
336
21.1k
        case VariantPrimitiveId::INT32:
337
21.1k
        case VariantPrimitiveId::INT64:
338
21.1k
            write_scalar(_out, format_json_int(value.get_int()));
339
21.1k
            return;
340
50
        case VariantPrimitiveId::DOUBLE: {
341
50
            const double number = value.get_double();
342
50
            if (!std::isfinite(number)) {
343
30
                write_non_finite(number);
344
30
                return;
345
30
            }
346
20
            write_scalar(_out, format_json_double(number));
347
20
            return;
348
50
        }
349
0
        case VariantPrimitiveId::DECIMAL4:
350
0
        case VariantPrimitiveId::DECIMAL8:
351
0
        case VariantPrimitiveId::DECIMAL16:
352
0
            write_scalar(_out, format_json_decimal(value.get_decimal()));
353
0
            return;
354
10
        case VariantPrimitiveId::DATE:
355
10
            write_quoted_scalar(_out, format_json_date(value.get_date()));
356
10
            return;
357
0
        case VariantPrimitiveId::TIMESTAMP_MICROS:
358
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_micros(), 6, true,
359
0
                                                            _options.timezone));
360
0
            return;
361
8
        case VariantPrimitiveId::TIMESTAMP_NTZ_MICROS:
362
8
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_ntz_micros(), 6,
363
8
                                                            false, nullptr));
364
8
            return;
365
0
        case VariantPrimitiveId::FLOAT: {
366
0
            const float number = value.get_float();
367
0
            if (!std::isfinite(number)) {
368
0
                write_non_finite(number);
369
0
                return;
370
0
            }
371
0
            write_scalar(_out, format_json_float(number));
372
0
            return;
373
0
        }
374
0
        case VariantPrimitiveId::BINARY:
375
0
            write_json_binary(_out, value.get_binary());
376
0
            return;
377
1
        case VariantPrimitiveId::STRING:
378
1
            write_json_string(_out, value.get_string(), "string");
379
1
            return;
380
0
        case VariantPrimitiveId::TIME_NTZ_MICROS:
381
0
            write_quoted_scalar(_out, format_json_time_micros(value.get_time_ntz_micros()));
382
0
            return;
383
0
        case VariantPrimitiveId::TIMESTAMP_NANOS:
384
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_nanos(), 9, true,
385
0
                                                            _options.timezone));
386
0
            return;
387
0
        case VariantPrimitiveId::TIMESTAMP_NTZ_NANOS:
388
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_ntz_nanos(), 9,
389
0
                                                            false, nullptr));
390
0
            return;
391
0
        case VariantPrimitiveId::UUID:
392
0
            write_quoted_scalar(_out, format_json_uuid(value.get_uuid()));
393
0
            return;
394
21.2k
        }
395
0
        throw_unsupported_json_primitive(id);
396
0
    }
unity_5_cxx.cxx:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_111FixedWriterEE15write_primitiveENS_10VariantRefE
Line
Count
Source
322
71
    void write_primitive(VariantRef value) {
323
71
        const VariantPrimitiveId id = value.primitive_id();
324
71
        switch (id) {
325
14
        case VariantPrimitiveId::NULL_VALUE:
326
14
            write_literal(_out, "null");
327
14
            return;
328
0
        case VariantPrimitiveId::TRUE_VALUE:
329
0
            write_literal(_out, "true");
330
0
            return;
331
0
        case VariantPrimitiveId::FALSE_VALUE:
332
0
            write_literal(_out, "false");
333
0
            return;
334
3
        case VariantPrimitiveId::INT8:
335
3
        case VariantPrimitiveId::INT16:
336
3
        case VariantPrimitiveId::INT32:
337
3
        case VariantPrimitiveId::INT64:
338
3
            write_scalar(_out, format_json_int(value.get_int()));
339
3
            return;
340
40
        case VariantPrimitiveId::DOUBLE: {
341
40
            const double number = value.get_double();
342
40
            if (!std::isfinite(number)) {
343
24
                write_non_finite(number);
344
24
                return;
345
24
            }
346
16
            write_scalar(_out, format_json_double(number));
347
16
            return;
348
40
        }
349
0
        case VariantPrimitiveId::DECIMAL4:
350
0
        case VariantPrimitiveId::DECIMAL8:
351
0
        case VariantPrimitiveId::DECIMAL16:
352
0
            write_scalar(_out, format_json_decimal(value.get_decimal()));
353
0
            return;
354
8
        case VariantPrimitiveId::DATE:
355
8
            write_quoted_scalar(_out, format_json_date(value.get_date()));
356
8
            return;
357
0
        case VariantPrimitiveId::TIMESTAMP_MICROS:
358
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_micros(), 6, true,
359
0
                                                            _options.timezone));
360
0
            return;
361
6
        case VariantPrimitiveId::TIMESTAMP_NTZ_MICROS:
362
6
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_ntz_micros(), 6,
363
6
                                                            false, nullptr));
364
6
            return;
365
0
        case VariantPrimitiveId::FLOAT: {
366
0
            const float number = value.get_float();
367
0
            if (!std::isfinite(number)) {
368
0
                write_non_finite(number);
369
0
                return;
370
0
            }
371
0
            write_scalar(_out, format_json_float(number));
372
0
            return;
373
0
        }
374
0
        case VariantPrimitiveId::BINARY:
375
0
            write_json_binary(_out, value.get_binary());
376
0
            return;
377
0
        case VariantPrimitiveId::STRING:
378
0
            write_json_string(_out, value.get_string(), "string");
379
0
            return;
380
0
        case VariantPrimitiveId::TIME_NTZ_MICROS:
381
0
            write_quoted_scalar(_out, format_json_time_micros(value.get_time_ntz_micros()));
382
0
            return;
383
0
        case VariantPrimitiveId::TIMESTAMP_NANOS:
384
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_nanos(), 9, true,
385
0
                                                            _options.timezone));
386
0
            return;
387
0
        case VariantPrimitiveId::TIMESTAMP_NTZ_NANOS:
388
0
            write_quoted_scalar(_out, format_json_timestamp(value.get_timestamp_ntz_nanos(), 9,
389
0
                                                            false, nullptr));
390
0
            return;
391
0
        case VariantPrimitiveId::UUID:
392
0
            write_quoted_scalar(_out, format_json_uuid(value.get_uuid()));
393
0
            return;
394
71
        }
395
0
        throw_unsupported_json_primitive(id);
396
0
    }
397
398
    template <typename Number>
399
75
    void write_non_finite(Number value) {
400
75
        if (std::isnan(value)) {
401
25
            write_literal(_out, "\"NaN\"");
402
50
        } else if (value > 0) {
403
25
            write_literal(_out, "\"Infinity\"");
404
25
        } else {
405
25
            write_literal(_out, "\"-Infinity\"");
406
25
        }
407
75
    }
Unexecuted instantiation: column_variant_v2_test.cpp:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_110JsonWriterEE16write_non_finiteIdEEvT_
Unexecuted instantiation: column_variant_v2_test.cpp:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_110JsonWriterEE16write_non_finiteIfEEvT_
Unexecuted instantiation: function_variant_parse_test.cpp:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_112StringWriterEE16write_non_finiteIdEEvT_
Unexecuted instantiation: function_variant_parse_test.cpp:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_112StringWriterEE16write_non_finiteIfEEvT_
Unexecuted instantiation: segment_flusher_format_test.cpp:_ZN5doris12variant_json7PrinterIZNS_12_GLOBAL__N_118variant_field_jsonB5cxx11ERKNS_12VariantFieldEE12StringWriterE16write_non_finiteIdEEvT_
Unexecuted instantiation: segment_flusher_format_test.cpp:_ZN5doris12variant_json7PrinterIZNS_12_GLOBAL__N_118variant_field_jsonB5cxx11ERKNS_12VariantFieldEE12StringWriterE16write_non_finiteIfEEvT_
Unexecuted instantiation: hierarchical_data_iterator_test.cpp:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_117VariantJsonWriterEE16write_non_finiteIdEEvT_
Unexecuted instantiation: hierarchical_data_iterator_test.cpp:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_117VariantJsonWriterEE16write_non_finiteIfEEvT_
Unexecuted instantiation: variant_assembler_legacy_test.cpp:_ZN5doris12variant_json7PrinterINS_10segment_v210variant_v212_GLOBAL__N_110JsonWriterEE16write_non_finiteIdEEvT_
Unexecuted instantiation: variant_assembler_legacy_test.cpp:_ZN5doris12variant_json7PrinterINS_10segment_v210variant_v212_GLOBAL__N_110JsonWriterEE16write_non_finiteIfEEvT_
variant_string_parse_test.cpp:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_112StringWriterEE16write_non_finiteIdEEvT_
Line
Count
Source
399
1
    void write_non_finite(Number value) {
400
1
        if (std::isnan(value)) {
401
0
            write_literal(_out, "\"NaN\"");
402
1
        } else if (value > 0) {
403
0
            write_literal(_out, "\"Infinity\"");
404
1
        } else {
405
1
            write_literal(_out, "\"-Infinity\"");
406
1
        }
407
1
    }
variant_string_parse_test.cpp:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_112StringWriterEE16write_non_finiteIfEEvT_
Line
Count
Source
399
2
    void write_non_finite(Number value) {
400
2
        if (std::isnan(value)) {
401
1
            write_literal(_out, "\"NaN\"");
402
1
        } else if (value > 0) {
403
1
            write_literal(_out, "\"Infinity\"");
404
1
        } else {
405
0
            write_literal(_out, "\"-Infinity\"");
406
0
        }
407
2
    }
_ZN5doris12variant_json7PrinterINS_14BufferWritableEE16write_non_finiteIdEEvT_
Line
Count
Source
399
18
    void write_non_finite(Number value) {
400
18
        if (std::isnan(value)) {
401
6
            write_literal(_out, "\"NaN\"");
402
12
        } else if (value > 0) {
403
6
            write_literal(_out, "\"Infinity\"");
404
6
        } else {
405
6
            write_literal(_out, "\"-Infinity\"");
406
6
        }
407
18
    }
Unexecuted instantiation: _ZN5doris12variant_json7PrinterINS_14BufferWritableEE16write_non_finiteIfEEvT_
unity_5_cxx.cxx:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_114CountingWriterEE16write_non_finiteIdEEvT_
Line
Count
Source
399
30
    void write_non_finite(Number value) {
400
30
        if (std::isnan(value)) {
401
10
            write_literal(_out, "\"NaN\"");
402
20
        } else if (value > 0) {
403
10
            write_literal(_out, "\"Infinity\"");
404
10
        } else {
405
10
            write_literal(_out, "\"-Infinity\"");
406
10
        }
407
30
    }
Unexecuted instantiation: unity_5_cxx.cxx:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_114CountingWriterEE16write_non_finiteIfEEvT_
unity_5_cxx.cxx:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_111FixedWriterEE16write_non_finiteIdEEvT_
Line
Count
Source
399
24
    void write_non_finite(Number value) {
400
24
        if (std::isnan(value)) {
401
8
            write_literal(_out, "\"NaN\"");
402
16
        } else if (value > 0) {
403
8
            write_literal(_out, "\"Infinity\"");
404
8
        } else {
405
8
            write_literal(_out, "\"-Infinity\"");
406
8
        }
407
24
    }
Unexecuted instantiation: unity_5_cxx.cxx:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_111FixedWriterEE16write_non_finiteIfEEvT_
408
409
25.2k
    void write_object(VariantRef value, uint32_t depth) {
410
25.2k
        write_literal(_out, "{");
411
25.2k
        const uint32_t count = value.num_elements();
412
25.2k
        StringRef previous_key;
413
102k
        for (uint32_t index = 0; index < count; ++index) {
414
77.1k
            if (index != 0) {
415
52.5k
                write_literal(_out, ",");
416
52.5k
            }
417
77.1k
            uint32_t field_id = 0;
418
77.1k
            VariantRef child = value.object_value_at(index, &field_id);
419
77.1k
            const StringRef key = value.metadata.key_at(field_id);
420
77.1k
            require_json_object_key(key, previous_key, index);
421
77.1k
            write_escaped_json_string(_out, key);
422
77.1k
            write_literal(_out, ":");
423
77.1k
            write(child, depth + 1);
424
77.1k
            previous_key = key;
425
77.1k
        }
426
25.2k
        write_literal(_out, "}");
427
25.2k
    }
column_variant_v2_test.cpp:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_110JsonWriterEE12write_objectENS_10VariantRefEj
Line
Count
Source
409
121
    void write_object(VariantRef value, uint32_t depth) {
410
121
        write_literal(_out, "{");
411
121
        const uint32_t count = value.num_elements();
412
121
        StringRef previous_key;
413
218
        for (uint32_t index = 0; index < count; ++index) {
414
97
            if (index != 0) {
415
0
                write_literal(_out, ",");
416
0
            }
417
97
            uint32_t field_id = 0;
418
97
            VariantRef child = value.object_value_at(index, &field_id);
419
97
            const StringRef key = value.metadata.key_at(field_id);
420
97
            require_json_object_key(key, previous_key, index);
421
97
            write_escaped_json_string(_out, key);
422
97
            write_literal(_out, ":");
423
97
            write(child, depth + 1);
424
97
            previous_key = key;
425
97
        }
426
121
        write_literal(_out, "}");
427
121
    }
function_variant_parse_test.cpp:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_112StringWriterEE12write_objectENS_10VariantRefEj
Line
Count
Source
409
6
    void write_object(VariantRef value, uint32_t depth) {
410
6
        write_literal(_out, "{");
411
6
        const uint32_t count = value.num_elements();
412
6
        StringRef previous_key;
413
11
        for (uint32_t index = 0; index < count; ++index) {
414
5
            if (index != 0) {
415
0
                write_literal(_out, ",");
416
0
            }
417
5
            uint32_t field_id = 0;
418
5
            VariantRef child = value.object_value_at(index, &field_id);
419
5
            const StringRef key = value.metadata.key_at(field_id);
420
5
            require_json_object_key(key, previous_key, index);
421
5
            write_escaped_json_string(_out, key);
422
5
            write_literal(_out, ":");
423
5
            write(child, depth + 1);
424
5
            previous_key = key;
425
5
        }
426
6
        write_literal(_out, "}");
427
6
    }
segment_flusher_format_test.cpp:_ZN5doris12variant_json7PrinterIZNS_12_GLOBAL__N_118variant_field_jsonB5cxx11ERKNS_12VariantFieldEE12StringWriterE12write_objectENS_10VariantRefEj
Line
Count
Source
409
32
    void write_object(VariantRef value, uint32_t depth) {
410
32
        write_literal(_out, "{");
411
32
        const uint32_t count = value.num_elements();
412
32
        StringRef previous_key;
413
88
        for (uint32_t index = 0; index < count; ++index) {
414
56
            if (index != 0) {
415
24
                write_literal(_out, ",");
416
24
            }
417
56
            uint32_t field_id = 0;
418
56
            VariantRef child = value.object_value_at(index, &field_id);
419
56
            const StringRef key = value.metadata.key_at(field_id);
420
56
            require_json_object_key(key, previous_key, index);
421
56
            write_escaped_json_string(_out, key);
422
56
            write_literal(_out, ":");
423
56
            write(child, depth + 1);
424
56
            previous_key = key;
425
56
        }
426
32
        write_literal(_out, "}");
427
32
    }
hierarchical_data_iterator_test.cpp:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_117VariantJsonWriterEE12write_objectENS_10VariantRefEj
Line
Count
Source
409
5
    void write_object(VariantRef value, uint32_t depth) {
410
5
        write_literal(_out, "{");
411
5
        const uint32_t count = value.num_elements();
412
5
        StringRef previous_key;
413
10
        for (uint32_t index = 0; index < count; ++index) {
414
5
            if (index != 0) {
415
0
                write_literal(_out, ",");
416
0
            }
417
5
            uint32_t field_id = 0;
418
5
            VariantRef child = value.object_value_at(index, &field_id);
419
5
            const StringRef key = value.metadata.key_at(field_id);
420
5
            require_json_object_key(key, previous_key, index);
421
5
            write_escaped_json_string(_out, key);
422
5
            write_literal(_out, ":");
423
5
            write(child, depth + 1);
424
5
            previous_key = key;
425
5
        }
426
5
        write_literal(_out, "}");
427
5
    }
variant_assembler_legacy_test.cpp:_ZN5doris12variant_json7PrinterINS_10segment_v210variant_v212_GLOBAL__N_110JsonWriterEE12write_objectENS_10VariantRefEj
Line
Count
Source
409
56
    void write_object(VariantRef value, uint32_t depth) {
410
56
        write_literal(_out, "{");
411
56
        const uint32_t count = value.num_elements();
412
56
        StringRef previous_key;
413
127
        for (uint32_t index = 0; index < count; ++index) {
414
71
            if (index != 0) {
415
19
                write_literal(_out, ",");
416
19
            }
417
71
            uint32_t field_id = 0;
418
71
            VariantRef child = value.object_value_at(index, &field_id);
419
71
            const StringRef key = value.metadata.key_at(field_id);
420
71
            require_json_object_key(key, previous_key, index);
421
71
            write_escaped_json_string(_out, key);
422
71
            write_literal(_out, ":");
423
71
            write(child, depth + 1);
424
71
            previous_key = key;
425
71
        }
426
56
        write_literal(_out, "}");
427
56
    }
variant_string_parse_test.cpp:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_112StringWriterEE12write_objectENS_10VariantRefEj
Line
Count
Source
409
21
    void write_object(VariantRef value, uint32_t depth) {
410
21
        write_literal(_out, "{");
411
21
        const uint32_t count = value.num_elements();
412
21
        StringRef previous_key;
413
49
        for (uint32_t index = 0; index < count; ++index) {
414
28
            if (index != 0) {
415
8
                write_literal(_out, ",");
416
8
            }
417
28
            uint32_t field_id = 0;
418
28
            VariantRef child = value.object_value_at(index, &field_id);
419
28
            const StringRef key = value.metadata.key_at(field_id);
420
28
            require_json_object_key(key, previous_key, index);
421
28
            write_escaped_json_string(_out, key);
422
28
            write_literal(_out, ":");
423
28
            write(child, depth + 1);
424
28
            previous_key = key;
425
28
        }
426
21
        write_literal(_out, "}");
427
21
    }
_ZN5doris12variant_json7PrinterINS_14BufferWritableEE12write_objectENS_10VariantRefEj
Line
Count
Source
409
12.4k
    void write_object(VariantRef value, uint32_t depth) {
410
12.4k
        write_literal(_out, "{");
411
12.4k
        const uint32_t count = value.num_elements();
412
12.4k
        StringRef previous_key;
413
50.9k
        for (uint32_t index = 0; index < count; ++index) {
414
38.4k
            if (index != 0) {
415
26.2k
                write_literal(_out, ",");
416
26.2k
            }
417
38.4k
            uint32_t field_id = 0;
418
38.4k
            VariantRef child = value.object_value_at(index, &field_id);
419
38.4k
            const StringRef key = value.metadata.key_at(field_id);
420
38.4k
            require_json_object_key(key, previous_key, index);
421
38.4k
            write_escaped_json_string(_out, key);
422
38.4k
            write_literal(_out, ":");
423
38.4k
            write(child, depth + 1);
424
38.4k
            previous_key = key;
425
38.4k
        }
426
12.4k
        write_literal(_out, "}");
427
12.4k
    }
unity_5_cxx.cxx:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_114CountingWriterEE12write_objectENS_10VariantRefEj
Line
Count
Source
409
12.4k
    void write_object(VariantRef value, uint32_t depth) {
410
12.4k
        write_literal(_out, "{");
411
12.4k
        const uint32_t count = value.num_elements();
412
12.4k
        StringRef previous_key;
413
50.9k
        for (uint32_t index = 0; index < count; ++index) {
414
38.4k
            if (index != 0) {
415
26.2k
                write_literal(_out, ",");
416
26.2k
            }
417
38.4k
            uint32_t field_id = 0;
418
38.4k
            VariantRef child = value.object_value_at(index, &field_id);
419
38.4k
            const StringRef key = value.metadata.key_at(field_id);
420
38.4k
            require_json_object_key(key, previous_key, index);
421
38.4k
            write_escaped_json_string(_out, key);
422
38.4k
            write_literal(_out, ":");
423
38.4k
            write(child, depth + 1);
424
38.4k
            previous_key = key;
425
38.4k
        }
426
12.4k
        write_literal(_out, "}");
427
12.4k
    }
unity_5_cxx.cxx:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_111FixedWriterEE12write_objectENS_10VariantRefEj
Line
Count
Source
409
3
    void write_object(VariantRef value, uint32_t depth) {
410
3
        write_literal(_out, "{");
411
3
        const uint32_t count = value.num_elements();
412
3
        StringRef previous_key;
413
6
        for (uint32_t index = 0; index < count; ++index) {
414
3
            if (index != 0) {
415
0
                write_literal(_out, ",");
416
0
            }
417
3
            uint32_t field_id = 0;
418
3
            VariantRef child = value.object_value_at(index, &field_id);
419
3
            const StringRef key = value.metadata.key_at(field_id);
420
3
            require_json_object_key(key, previous_key, index);
421
3
            write_escaped_json_string(_out, key);
422
3
            write_literal(_out, ":");
423
3
            write(child, depth + 1);
424
3
            previous_key = key;
425
3
        }
426
3
        write_literal(_out, "}");
427
3
    }
428
429
403
    void write_array(VariantRef value, uint32_t depth) {
430
403
        write_literal(_out, "[");
431
403
        const uint32_t count = value.num_elements();
432
887
        for (uint32_t index = 0; index < count; ++index) {
433
484
            if (index != 0) {
434
101
                write_literal(_out, ",");
435
101
            }
436
484
            write(value.array_at(index), depth + 1);
437
484
        }
438
403
        write_literal(_out, "]");
439
403
    }
column_variant_v2_test.cpp:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_110JsonWriterEE11write_arrayENS_10VariantRefEj
Line
Count
Source
429
19
    void write_array(VariantRef value, uint32_t depth) {
430
19
        write_literal(_out, "[");
431
19
        const uint32_t count = value.num_elements();
432
38
        for (uint32_t index = 0; index < count; ++index) {
433
19
            if (index != 0) {
434
0
                write_literal(_out, ",");
435
0
            }
436
19
            write(value.array_at(index), depth + 1);
437
19
        }
438
19
        write_literal(_out, "]");
439
19
    }
function_variant_parse_test.cpp:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_112StringWriterEE11write_arrayENS_10VariantRefEj
Line
Count
Source
429
2
    void write_array(VariantRef value, uint32_t depth) {
430
2
        write_literal(_out, "[");
431
2
        const uint32_t count = value.num_elements();
432
6
        for (uint32_t index = 0; index < count; ++index) {
433
4
            if (index != 0) {
434
2
                write_literal(_out, ",");
435
2
            }
436
4
            write(value.array_at(index), depth + 1);
437
4
        }
438
2
        write_literal(_out, "]");
439
2
    }
segment_flusher_format_test.cpp:_ZN5doris12variant_json7PrinterIZNS_12_GLOBAL__N_118variant_field_jsonB5cxx11ERKNS_12VariantFieldEE12StringWriterE11write_arrayENS_10VariantRefEj
Line
Count
Source
429
4
    void write_array(VariantRef value, uint32_t depth) {
430
4
        write_literal(_out, "[");
431
4
        const uint32_t count = value.num_elements();
432
12
        for (uint32_t index = 0; index < count; ++index) {
433
8
            if (index != 0) {
434
4
                write_literal(_out, ",");
435
4
            }
436
8
            write(value.array_at(index), depth + 1);
437
8
        }
438
4
        write_literal(_out, "]");
439
4
    }
Unexecuted instantiation: hierarchical_data_iterator_test.cpp:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_117VariantJsonWriterEE11write_arrayENS_10VariantRefEj
variant_assembler_legacy_test.cpp:_ZN5doris12variant_json7PrinterINS_10segment_v210variant_v212_GLOBAL__N_110JsonWriterEE11write_arrayENS_10VariantRefEj
Line
Count
Source
429
20
    void write_array(VariantRef value, uint32_t depth) {
430
20
        write_literal(_out, "[");
431
20
        const uint32_t count = value.num_elements();
432
48
        for (uint32_t index = 0; index < count; ++index) {
433
28
            if (index != 0) {
434
10
                write_literal(_out, ",");
435
10
            }
436
28
            write(value.array_at(index), depth + 1);
437
28
        }
438
20
        write_literal(_out, "]");
439
20
    }
variant_string_parse_test.cpp:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_112StringWriterEE11write_arrayENS_10VariantRefEj
Line
Count
Source
429
263
    void write_array(VariantRef value, uint32_t depth) {
430
263
        write_literal(_out, "[");
431
263
        const uint32_t count = value.num_elements();
432
538
        for (uint32_t index = 0; index < count; ++index) {
433
275
            if (index != 0) {
434
12
                write_literal(_out, ",");
435
12
            }
436
275
            write(value.array_at(index), depth + 1);
437
275
        }
438
263
        write_literal(_out, "]");
439
263
    }
_ZN5doris12variant_json7PrinterINS_14BufferWritableEE11write_arrayENS_10VariantRefEj
Line
Count
Source
429
44
    void write_array(VariantRef value, uint32_t depth) {
430
44
        write_literal(_out, "[");
431
44
        const uint32_t count = value.num_elements();
432
114
        for (uint32_t index = 0; index < count; ++index) {
433
70
            if (index != 0) {
434
33
                write_literal(_out, ",");
435
33
            }
436
70
            write(value.array_at(index), depth + 1);
437
70
        }
438
44
        write_literal(_out, "]");
439
44
    }
unity_5_cxx.cxx:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_114CountingWriterEE11write_arrayENS_10VariantRefEj
Line
Count
Source
429
45
    void write_array(VariantRef value, uint32_t depth) {
430
45
        write_literal(_out, "[");
431
45
        const uint32_t count = value.num_elements();
432
116
        for (uint32_t index = 0; index < count; ++index) {
433
71
            if (index != 0) {
434
34
                write_literal(_out, ",");
435
34
            }
436
71
            write(value.array_at(index), depth + 1);
437
71
        }
438
45
        write_literal(_out, "]");
439
45
    }
unity_5_cxx.cxx:_ZN5doris12variant_json7PrinterINS_12_GLOBAL__N_111FixedWriterEE11write_arrayENS_10VariantRefEj
Line
Count
Source
429
6
    void write_array(VariantRef value, uint32_t depth) {
430
6
        write_literal(_out, "[");
431
6
        const uint32_t count = value.num_elements();
432
15
        for (uint32_t index = 0; index < count; ++index) {
433
9
            if (index != 0) {
434
6
                write_literal(_out, ",");
435
6
            }
436
9
            write(value.array_at(index), depth + 1);
437
9
        }
438
6
        write_literal(_out, "]");
439
6
    }
440
441
    Writer& _out;
442
    const VariantJsonFormatOptions& _options;
443
};
444
445
} // namespace variant_json
446
447
// Writer is statically dispatched and only needs write(const char*, size_t).
448
template <typename Writer>
449
void to_json(VariantRef value, Writer& out,
450
26.7k
             const VariantJsonFormatOptions& options = VariantJsonFormatOptions {}) {
451
26.7k
    variant_json::require_exact_json_value(value);
452
26.7k
    variant_json::Printer<Writer>(out, options).write(value, 0);
453
26.7k
}
column_variant_v2_test.cpp:_ZN5doris7to_jsonINS_12_GLOBAL__N_110JsonWriterEEEvNS_10VariantRefERT_RKNS_24VariantJsonFormatOptionsE
Line
Count
Source
450
143
             const VariantJsonFormatOptions& options = VariantJsonFormatOptions {}) {
451
143
    variant_json::require_exact_json_value(value);
452
143
    variant_json::Printer<Writer>(out, options).write(value, 0);
453
143
}
function_variant_parse_test.cpp:_ZN5doris7to_jsonINS_12_GLOBAL__N_112StringWriterEEEvNS_10VariantRefERT_RKNS_24VariantJsonFormatOptionsE
Line
Count
Source
450
13
             const VariantJsonFormatOptions& options = VariantJsonFormatOptions {}) {
451
13
    variant_json::require_exact_json_value(value);
452
13
    variant_json::Printer<Writer>(out, options).write(value, 0);
453
13
}
segment_flusher_format_test.cpp:_ZN5doris7to_jsonIZNS_12_GLOBAL__N_118variant_field_jsonB5cxx11ERKNS_12VariantFieldEE12StringWriterEEvNS_10VariantRefERT_RKNS_24VariantJsonFormatOptionsE
Line
Count
Source
450
24
             const VariantJsonFormatOptions& options = VariantJsonFormatOptions {}) {
451
24
    variant_json::require_exact_json_value(value);
452
24
    variant_json::Printer<Writer>(out, options).write(value, 0);
453
24
}
hierarchical_data_iterator_test.cpp:_ZN5doris7to_jsonINS_12_GLOBAL__N_117VariantJsonWriterEEEvNS_10VariantRefERT_RKNS_24VariantJsonFormatOptionsE
Line
Count
Source
450
7
             const VariantJsonFormatOptions& options = VariantJsonFormatOptions {}) {
451
7
    variant_json::require_exact_json_value(value);
452
7
    variant_json::Printer<Writer>(out, options).write(value, 0);
453
7
}
variant_assembler_legacy_test.cpp:_ZN5doris7to_jsonINS_10segment_v210variant_v212_GLOBAL__N_110JsonWriterEEEvNS_10VariantRefERT_RKNS_24VariantJsonFormatOptionsE
Line
Count
Source
450
153
             const VariantJsonFormatOptions& options = VariantJsonFormatOptions {}) {
451
153
    variant_json::require_exact_json_value(value);
452
153
    variant_json::Printer<Writer>(out, options).write(value, 0);
453
153
}
variant_string_parse_test.cpp:_ZN5doris7to_jsonINS_12_GLOBAL__N_112StringWriterEEEvNS_10VariantRefERT_RKNS_24VariantJsonFormatOptionsE
Line
Count
Source
450
48
             const VariantJsonFormatOptions& options = VariantJsonFormatOptions {}) {
451
48
    variant_json::require_exact_json_value(value);
452
48
    variant_json::Printer<Writer>(out, options).write(value, 0);
453
48
}
_ZN5doris7to_jsonINS_14BufferWritableEEEvNS_10VariantRefERT_RKNS_24VariantJsonFormatOptionsE
Line
Count
Source
450
13.1k
             const VariantJsonFormatOptions& options = VariantJsonFormatOptions {}) {
451
13.1k
    variant_json::require_exact_json_value(value);
452
13.1k
    variant_json::Printer<Writer>(out, options).write(value, 0);
453
13.1k
}
unity_5_cxx.cxx:_ZN5doris7to_jsonINS_12_GLOBAL__N_114CountingWriterEEEvNS_10VariantRefERT_RKNS_24VariantJsonFormatOptionsE
Line
Count
Source
450
13.1k
             const VariantJsonFormatOptions& options = VariantJsonFormatOptions {}) {
451
13.1k
    variant_json::require_exact_json_value(value);
452
13.1k
    variant_json::Printer<Writer>(out, options).write(value, 0);
453
13.1k
}
unity_5_cxx.cxx:_ZN5doris7to_jsonINS_12_GLOBAL__N_111FixedWriterEEEvNS_10VariantRefERT_RKNS_24VariantJsonFormatOptionsE
Line
Count
Source
450
81
             const VariantJsonFormatOptions& options = VariantJsonFormatOptions {}) {
451
81
    variant_json::require_exact_json_value(value);
452
81
    variant_json::Printer<Writer>(out, options).write(value, 0);
453
81
}
454
455
// Preserve the current Variant V1 SQL result contract for top-level scalar values: JSON strings
456
// such as "value" and "2" are returned as value and 2. Once V1 is removed, this compatibility
457
// output will change to the uniform JSON representation ("value" and "2").
458
template <typename Writer>
459
void to_sql_string(VariantRef value, Writer& out,
460
103
                   const VariantJsonFormatOptions& options = VariantJsonFormatOptions {}) {
461
103
    variant_json::require_exact_json_value(value);
462
103
    variant_json::Printer<Writer>(out, options).write_plain_scalar(value);
463
103
}
_ZN5doris13to_sql_stringINS_14BufferWritableEEEvNS_10VariantRefERT_RKNS_24VariantJsonFormatOptionsE
Line
Count
Source
460
51
                   const VariantJsonFormatOptions& options = VariantJsonFormatOptions {}) {
461
51
    variant_json::require_exact_json_value(value);
462
51
    variant_json::Printer<Writer>(out, options).write_plain_scalar(value);
463
51
}
unity_5_cxx.cxx:_ZN5doris13to_sql_stringINS_12_GLOBAL__N_114CountingWriterEEEvNS_10VariantRefERT_RKNS_24VariantJsonFormatOptionsE
Line
Count
Source
460
26
                   const VariantJsonFormatOptions& options = VariantJsonFormatOptions {}) {
461
26
    variant_json::require_exact_json_value(value);
462
26
    variant_json::Printer<Writer>(out, options).write_plain_scalar(value);
463
26
}
unity_5_cxx.cxx:_ZN5doris13to_sql_stringINS_12_GLOBAL__N_111FixedWriterEEEvNS_10VariantRefERT_RKNS_24VariantJsonFormatOptionsE
Line
Count
Source
460
26
                   const VariantJsonFormatOptions& options = VariantJsonFormatOptions {}) {
461
26
    variant_json::require_exact_json_value(value);
462
26
    variant_json::Printer<Writer>(out, options).write_plain_scalar(value);
463
26
}
464
465
} // namespace doris