Coverage Report

Created: 2025-07-28 21:04

/root/doris/be/src/util/load_util.cpp
Line
Count
Source (jump to first uncovered line)
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
#include "util/load_util.h"
19
20
#include <string>
21
22
#include "util/string_util.h"
23
24
namespace doris {
25
void LoadUtil::parse_format(const std::string& format_str, const std::string& compress_type_str,
26
                            TFileFormatType::type* format_type,
27
20
                            TFileCompressType::type* compress_type) {
28
20
    if (format_str.empty()) {
  Branch (28:9): [True: 1, False: 19]
29
1
        parse_format("CSV", compress_type_str, format_type, compress_type);
30
1
        return;
31
1
    }
32
33
    // Assign compress_type
34
19
    if (iequal(compress_type_str, "GZ")) {
  Branch (34:9): [True: 2, False: 17]
35
2
        *compress_type = TFileCompressType::GZ;
36
17
    } else if (iequal(compress_type_str, "LZO")) {
  Branch (36:16): [True: 1, False: 16]
37
1
        *compress_type = TFileCompressType::LZO;
38
16
    } else if (iequal(compress_type_str, "BZ2")) {
  Branch (38:16): [True: 2, False: 14]
39
2
        *compress_type = TFileCompressType::BZ2;
40
14
    } else if (iequal(compress_type_str, "LZ4")) {
  Branch (40:16): [True: 2, False: 12]
41
2
        *compress_type = TFileCompressType::LZ4FRAME;
42
12
    } else if (iequal(compress_type_str, "LZ4_BLOCK")) {
  Branch (42:16): [True: 1, False: 11]
43
1
        *compress_type = TFileCompressType::LZ4BLOCK;
44
11
    } else if (iequal(compress_type_str, "LZOP")) {
  Branch (44:16): [True: 3, False: 8]
45
3
        *compress_type = TFileCompressType::LZO;
46
8
    } else if (iequal(compress_type_str, "SNAPPY_BLOCK")) {
  Branch (46:16): [True: 1, False: 7]
47
1
        *compress_type = TFileCompressType::SNAPPYBLOCK;
48
7
    } else if (iequal(compress_type_str, "DEFLATE")) {
  Branch (48:16): [True: 2, False: 5]
49
2
        *compress_type = TFileCompressType::DEFLATE;
50
5
    } else {
51
5
        *compress_type = TFileCompressType::PLAIN;
52
5
    }
53
54
    // Assign format_type
55
19
    *format_type = TFileFormatType::FORMAT_UNKNOWN;
56
19
    if (iequal(format_str, "CSV")) {
  Branch (56:9): [True: 7, False: 12]
57
7
        if (compress_type_str.empty()) {
  Branch (57:13): [True: 1, False: 6]
58
1
            *format_type = TFileFormatType::FORMAT_CSV_PLAIN;
59
6
        } else if (iequal(compress_type_str, "GZ")) {
  Branch (59:20): [True: 1, False: 5]
60
1
            *format_type = TFileFormatType::FORMAT_CSV_GZ;
61
5
        } else if (iequal(compress_type_str, "LZO")) {
  Branch (61:20): [True: 1, False: 4]
62
1
            *format_type = TFileFormatType::FORMAT_CSV_LZO;
63
4
        } else if (iequal(compress_type_str, "BZ2")) {
  Branch (63:20): [True: 1, False: 3]
64
1
            *format_type = TFileFormatType::FORMAT_CSV_BZ2;
65
3
        } else if (iequal(compress_type_str, "LZ4")) {
  Branch (65:20): [True: 1, False: 2]
66
1
            *format_type = TFileFormatType::FORMAT_CSV_LZ4FRAME;
67
2
        } else if (iequal(compress_type_str, "LZ4_BLOCK")) {
  Branch (67:20): [True: 0, False: 2]
68
0
            *format_type = TFileFormatType::FORMAT_CSV_LZ4BLOCK;
69
2
        } else if (iequal(compress_type_str, "LZOP")) {
  Branch (69:20): [True: 1, False: 1]
70
1
            *format_type = TFileFormatType::FORMAT_CSV_LZOP;
71
1
        } else if (iequal(compress_type_str, "SNAPPY_BLOCK")) {
  Branch (71:20): [True: 0, False: 1]
72
0
            *format_type = TFileFormatType::FORMAT_CSV_SNAPPYBLOCK;
73
1
        } else if (iequal(compress_type_str, "DEFLATE")) {
  Branch (73:20): [True: 1, False: 0]
74
1
            *format_type = TFileFormatType::FORMAT_CSV_DEFLATE;
75
1
        }
76
12
    } else if (iequal(format_str, "HIVE_TEXT")) {
  Branch (76:16): [True: 0, False: 12]
77
0
        *format_type = TFileFormatType::FORMAT_TEXT;
78
12
    } else if (iequal(format_str, "JSON")) {
  Branch (78:16): [True: 10, False: 2]
79
10
        *format_type = TFileFormatType::FORMAT_JSON;
80
10
    } else if (iequal(format_str, "PARQUET")) {
  Branch (80:16): [True: 1, False: 1]
81
1
        *format_type = TFileFormatType::FORMAT_PARQUET;
82
1
    } else if (iequal(format_str, "ORC")) {
  Branch (82:16): [True: 1, False: 0]
83
1
        *format_type = TFileFormatType::FORMAT_ORC;
84
1
    } else if (iequal(format_str, "WAL")) {
  Branch (84:16): [True: 0, False: 0]
85
0
        *format_type = TFileFormatType::FORMAT_WAL;
86
0
    } else if (iequal(format_str, "ARROW")) {
  Branch (86:16): [True: 0, False: 0]
87
0
        *format_type = TFileFormatType::FORMAT_ARROW;
88
0
    }
89
19
}
90
91
14
bool LoadUtil::is_format_support_streaming(TFileFormatType::type format) {
92
14
    switch (format) {
93
1
    case TFileFormatType::FORMAT_CSV_PLAIN:
  Branch (93:5): [True: 1, False: 13]
94
2
    case TFileFormatType::FORMAT_CSV_BZ2:
  Branch (94:5): [True: 1, False: 13]
95
3
    case TFileFormatType::FORMAT_CSV_DEFLATE:
  Branch (95:5): [True: 1, False: 13]
96
4
    case TFileFormatType::FORMAT_CSV_GZ:
  Branch (96:5): [True: 1, False: 13]
97
5
    case TFileFormatType::FORMAT_CSV_LZ4FRAME:
  Branch (97:5): [True: 1, False: 13]
98
5
    case TFileFormatType::FORMAT_CSV_LZ4BLOCK:
  Branch (98:5): [True: 0, False: 14]
99
6
    case TFileFormatType::FORMAT_CSV_LZO:
  Branch (99:5): [True: 1, False: 13]
100
7
    case TFileFormatType::FORMAT_CSV_LZOP:
  Branch (100:5): [True: 1, False: 13]
101
8
    case TFileFormatType::FORMAT_JSON:
  Branch (101:5): [True: 1, False: 13]
102
8
    case TFileFormatType::FORMAT_TEXT:
  Branch (102:5): [True: 0, False: 14]
103
8
    case TFileFormatType::FORMAT_WAL:
  Branch (103:5): [True: 0, False: 14]
104
8
    case TFileFormatType::FORMAT_ARROW:
  Branch (104:5): [True: 0, False: 14]
105
8
        return true;
106
6
    default:
  Branch (106:5): [True: 6, False: 8]
107
6
        return false;
108
14
    }
109
0
    return false;
110
14
}
111
} // namespace  doris