Coverage Report

Created: 2026-04-23 18:29

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/format/table/transactional_hive_common.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 <cstddef>
21
#include <cstdint>
22
#include <string>
23
#include <unordered_map>
24
#include <vector>
25
26
#include "core/data_type/define_primitive_type.h"
27
#include "exec/common/hash_table/phmap_fwd_decl.h"
28
29
namespace doris {
30
struct TransactionalHive {
31
    static const std::string OPERATION;
32
    static const std::string ORIGINAL_TRANSACTION;
33
    static const std::string BUCKET;
34
    static const std::string ROW_ID;
35
    static const std::string CURRENT_TRANSACTION;
36
    static const std::string ROW;
37
    static const std::string OPERATION_LOWER_CASE;
38
    static const std::string ORIGINAL_TRANSACTION_LOWER_CASE;
39
    static const std::string BUCKET_LOWER_CASE;
40
    static const std::string ROW_ID_LOWER_CASE;
41
    static const std::string CURRENT_TRANSACTION_LOWER_CASE;
42
    static const std::string ROW_LOWER_CASE;
43
    static const int ROW_OFFSET;
44
    struct Param {
45
        const std::string column_name;
46
        const std::string column_lower_case;
47
        const PrimitiveType type;
48
    };
49
    static const std::vector<Param> DELETE_ROW_PARAMS;
50
    static const std::vector<Param> READ_PARAMS;
51
    static const std::vector<std::string> DELETE_ROW_COLUMN_NAMES;
52
    static const std::vector<std::string> DELETE_ROW_COLUMN_NAMES_LOWER_CASE;
53
    static const std::vector<std::string> READ_ROW_COLUMN_NAMES;
54
    static const std::vector<std::string> READ_ROW_COLUMN_NAMES_LOWER_CASE;
55
    static const std::vector<std::string> ACID_COLUMN_NAMES;
56
    static const std::vector<std::string> ACID_COLUMN_NAMES_LOWER_CASE;
57
58
    static const std::unordered_map<std::string, uint32_t> DELETE_COL_NAME_TO_BLOCK_IDX;
59
};
60
61
// ACID row identifier for transactional Hive tables, used for delete row matching.
62
// Placed here (not in TransactionalHiveReader) to avoid circular dependency with OrcReader.
63
struct AcidRowID {
64
    int64_t original_transaction;
65
    int64_t bucket;
66
    int64_t row_id;
67
68
    struct Hash {
69
2
        size_t operator()(const AcidRowID& transactional_row_id) const {
70
2
            size_t hash_value = 0;
71
2
            hash_value ^= std::hash<int64_t> {}(transactional_row_id.original_transaction) +
72
2
                          0x9e3779b9 + (hash_value << 6) + (hash_value >> 2);
73
2
            hash_value ^= std::hash<int64_t> {}(transactional_row_id.bucket) + 0x9e3779b9 +
74
2
                          (hash_value << 6) + (hash_value >> 2);
75
2
            hash_value ^= std::hash<int64_t> {}(transactional_row_id.row_id) + 0x9e3779b9 +
76
2
                          (hash_value << 6) + (hash_value >> 2);
77
2
            return hash_value;
78
2
        }
79
    };
80
81
    struct Eq {
82
1
        bool operator()(const AcidRowID& lhs, const AcidRowID& rhs) const {
83
1
            return lhs.original_transaction == rhs.original_transaction &&
84
1
                   lhs.bucket == rhs.bucket && lhs.row_id == rhs.row_id;
85
1
        }
86
    };
87
};
88
89
using AcidRowIDSet = flat_hash_set<AcidRowID, AcidRowID::Hash, AcidRowID::Eq>;
90
91
0
inline bool operator<(const AcidRowID& lhs, const AcidRowID& rhs) {
92
0
    if (lhs.original_transaction != rhs.original_transaction) {
93
0
        return lhs.original_transaction < rhs.original_transaction;
94
0
    } else if (lhs.bucket != rhs.bucket) {
95
0
        return lhs.bucket < rhs.bucket;
96
0
    } else if (lhs.row_id != rhs.row_id) {
97
0
        return lhs.row_id < rhs.row_id;
98
0
    } else {
99
0
        return false;
100
0
    }
101
0
}
102
103
} // namespace doris