Coverage Report

Created: 2026-10-28 16:27

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/root/doris/be/src/util/s3_uri.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 <string>
21
22
#include "common/status.h"
23
#include "util/string_util.h"
24
25
namespace doris {
26
27
// S3URI can handle following input:
28
// 1. s3://bucket_name/path/to/file.txt
29
//      bucket: bucket_num
30
//      key: path/to/file.txt
31
// 2. path/to/file.txt
32
//      bucket: ""
33
//      key: path/to/file.txt
34
class S3URI {
35
public:
36
2.28k
    S3URI(const std::string& location) : _location(location) {}
37
    // Preserve object keys verbatim when the path denotes an object rather than a URL.
38
    Status parse(bool preserve_key = false);
39
201
    const std::string& get_bucket() const { return _bucket; }
40
2.26k
    const std::string& get_key() const { return _key; }
41
0
    const std::string& get_location() const { return _location; }
42
    std::string to_string() const;
43
44
private:
45
    static const std::string _SCHEME_S3;
46
    static const std::string _SCHEME_HTTP;
47
    static const std::string _SCHEME_HTTPS;
48
    static const std::string _SCHEME_DELIM;
49
    static const std::string _PATH_DELIM;
50
    static const std::string _QUERY_DELIM;
51
    static const std::string _FRAGMENT_DELIM;
52
    static const StringCaseSet _VALID_SCHEMES;
53
54
    std::string _location;
55
    std::string _bucket;
56
    std::string _key;
57
};
58
} // end namespace doris