Coverage Report

Created: 2025-04-11 14:39

/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()) {
29
1
        parse_format("CSV", compress_type_str, format_type, compress_type);
30
1
        return;
31
1
    }
32
19
    *compress_type = TFileCompressType::PLAIN;
33
19
    *format_type = TFileFormatType::FORMAT_UNKNOWN;
34
19
    if (iequal(format_str, "CSV")) {
35
7
        if (compress_type_str.empty()) {
36
1
            *format_type = TFileFormatType::FORMAT_CSV_PLAIN;
37
6
        } else if (iequal(compress_type_str, "GZ")) {
38
1
            *format_type = TFileFormatType::FORMAT_CSV_GZ;
39
1
            *compress_type = TFileCompressType::GZ;
40
5
        } else if (iequal(compress_type_str, "LZO")) {
41
1
            *format_type = TFileFormatType::FORMAT_CSV_LZO;
42
1
            *compress_type = TFileCompressType::LZO;
43
4
        } else if (iequal(compress_type_str, "BZ2")) {
44
1
            *format_type = TFileFormatType::FORMAT_CSV_BZ2;
45
1
            *compress_type = TFileCompressType::BZ2;
46
3
        } else if (iequal(compress_type_str, "LZ4")) {
47
1
            *format_type = TFileFormatType::FORMAT_CSV_LZ4FRAME;
48
1
            *compress_type = TFileCompressType::LZ4FRAME;
49
2
        } else if (iequal(compress_type_str, "LZ4_BLOCK")) {
50
0
            *format_type = TFileFormatType::FORMAT_CSV_LZ4BLOCK;
51
0
            *compress_type = TFileCompressType::LZ4BLOCK;
52
2
        } else if (iequal(compress_type_str, "LZOP")) {
53
1
            *format_type = TFileFormatType::FORMAT_CSV_LZOP;
54
1
            *compress_type = TFileCompressType::LZO;
55
1
        } else if (iequal(compress_type_str, "SNAPPY_BLOCK")) {
56
0
            *format_type = TFileFormatType::FORMAT_CSV_SNAPPYBLOCK;
57
0
            *compress_type = TFileCompressType::SNAPPYBLOCK;
58
1
        } else if (iequal(compress_type_str, "DEFLATE")) {
59
1
            *format_type = TFileFormatType::FORMAT_CSV_DEFLATE;
60
1
            *compress_type = TFileCompressType::DEFLATE;
61
1
        }
62
12
    } else if (iequal(format_str, "JSON")) {
63
10
        if (compress_type_str.empty()) {
64
1
            *format_type = TFileFormatType::FORMAT_JSON;
65
9
        } else if (iequal(compress_type_str, "GZ")) {
66
1
            *format_type = TFileFormatType::FORMAT_JSON;
67
1
            *compress_type = TFileCompressType::GZ;
68
8
        } else if (iequal(compress_type_str, "LZO")) {
69
0
            *format_type = TFileFormatType::FORMAT_JSON;
70
0
            *compress_type = TFileCompressType::LZO;
71
8
        } else if (iequal(compress_type_str, "BZ2")) {
72
1
            *format_type = TFileFormatType::FORMAT_JSON;
73
1
            *compress_type = TFileCompressType::BZ2;
74
7
        } else if (iequal(compress_type_str, "LZ4")) {
75
1
            *format_type = TFileFormatType::FORMAT_JSON;
76
1
            *compress_type = TFileCompressType::LZ4FRAME;
77
6
        } else if (iequal(compress_type_str, "LZ4_BLOCK")) {
78
1
            *format_type = TFileFormatType::FORMAT_JSON;
79
1
            *compress_type = TFileCompressType::LZ4BLOCK;
80
5
        } else if (iequal(compress_type_str, "LZOP")) {
81
2
            *format_type = TFileFormatType::FORMAT_JSON;
82
2
            *compress_type = TFileCompressType::LZO;
83
3
        } else if (iequal(compress_type_str, "SNAPPY_BLOCK")) {
84
1
            *format_type = TFileFormatType::FORMAT_JSON;
85
1
            *compress_type = TFileCompressType::SNAPPYBLOCK;
86
2
        } else if (iequal(compress_type_str, "DEFLATE")) {
87
1
            *format_type = TFileFormatType::FORMAT_JSON;
88
1
            *compress_type = TFileCompressType::DEFLATE;
89
1
        }
90
10
    } else if (iequal(format_str, "PARQUET")) {
91
1
        *format_type = TFileFormatType::FORMAT_PARQUET;
92
1
    } else if (iequal(format_str, "ORC")) {
93
1
        *format_type = TFileFormatType::FORMAT_ORC;
94
1
    } else if (iequal(format_str, "WAL")) {
95
0
        *format_type = TFileFormatType::FORMAT_WAL;
96
0
    } else if (iequal(format_str, "ARROW")) {
97
0
        *format_type = TFileFormatType::FORMAT_ARROW;
98
0
    }
99
19
    return;
100
20
}
101
102
14
bool LoadUtil::is_format_support_streaming(TFileFormatType::type format) {
103
14
    switch (format) {
104
1
    case TFileFormatType::FORMAT_CSV_PLAIN:
105
2
    case TFileFormatType::FORMAT_CSV_BZ2:
106
3
    case TFileFormatType::FORMAT_CSV_DEFLATE:
107
4
    case TFileFormatType::FORMAT_CSV_GZ:
108
5
    case TFileFormatType::FORMAT_CSV_LZ4FRAME:
109
5
    case TFileFormatType::FORMAT_CSV_LZ4BLOCK:
110
6
    case TFileFormatType::FORMAT_CSV_LZO:
111
7
    case TFileFormatType::FORMAT_CSV_LZOP:
112
8
    case TFileFormatType::FORMAT_JSON:
113
8
    case TFileFormatType::FORMAT_WAL:
114
8
    case TFileFormatType::FORMAT_ARROW:
115
8
        return true;
116
6
    default:
117
6
        return false;
118
14
    }
119
0
    return false;
120
14
}
121
} // namespace  doris