Coverage Report

Created: 2026-03-14 06:50

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/format/table/iceberg/partition_spec.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 "format/table/iceberg/partition_spec.h"
19
20
#include <memory>
21
#include <string>
22
#include <vector>
23
24
#include "format/table/iceberg/schema.h"
25
26
namespace doris::iceberg {
27
#include "common/compile_check_begin.h"
28
29
PartitionField::PartitionField(int source_id, int field_id, std::string name, std::string transform)
30
4
        : _source_id(source_id),
31
4
          _field_id(field_id),
32
4
          _name(std::move(name)),
33
4
          _transform(std::move(transform)) {}
34
35
PartitionSpec::Builder::Builder(std::shared_ptr<Schema> schema)
36
2
        : _schema(std::move(schema)),
37
2
          _spec_id(0),
38
2
          _last_assigned_field_id(PARTITION_DATA_ID_START - 1) {}
39
40
0
PartitionSpec::Builder& PartitionSpec::Builder::with_spec_id(int new_spec_id) {
41
0
    _spec_id = new_spec_id;
42
0
    return *this;
43
0
}
44
45
PartitionSpec::Builder& PartitionSpec::Builder::add(int source_id, int field_id, std::string name,
46
4
                                                    std::string transform) {
47
4
    _fields.emplace_back(source_id, field_id, std::move(name), std::move(transform));
48
4
    _last_assigned_field_id.store(std::max(_last_assigned_field_id.load(), field_id));
49
4
    return *this;
50
4
}
51
52
PartitionSpec::Builder& PartitionSpec::Builder::add(int source_id, std::string name,
53
2
                                                    std::string transform) {
54
2
    return add(source_id, next_field_id(), std::move(name), std::move(transform));
55
2
}
56
57
2
std::unique_ptr<PartitionSpec> PartitionSpec::Builder::build() {
58
2
    return std::make_unique<PartitionSpec>(std::move(_schema), _spec_id, std::move(_fields),
59
2
                                           _last_assigned_field_id.load());
60
2
}
61
62
PartitionSpec::PartitionSpec(std::shared_ptr<Schema> schema, int spec_id,
63
                             std::vector<PartitionField> fields, int last_assigned_field_id)
64
2
        : _schema(std::move(schema)),
65
2
          _spec_id(spec_id),
66
2
          _fields(std::move(fields)),
67
2
          _last_assigned_field_id(last_assigned_field_id) {}
68
69
#include "common/compile_check_end.h"
70
} // namespace doris::iceberg