Coverage Report

Created: 2025-07-28 22:10

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