Coverage Report

Created: 2026-06-04 11:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/format/table/transactional_hive_reader.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 <memory>
23
#include <string>
24
#include <unordered_map>
25
#include <vector>
26
27
#include "common/factory_creator.h"
28
#include "common/status.h"
29
#include "format/orc/vorc_reader.h"
30
#include "format/table/table_schema_change_helper.h"
31
#include "format/table/transactional_hive_common.h"
32
33
namespace doris {
34
class RuntimeState;
35
class TFileRangeDesc;
36
class TFileScanRangeParams;
37
38
namespace io {
39
struct IOContext;
40
} // namespace io
41
42
class Block;
43
class ShardedKVCache;
44
class VExprContext;
45
46
// TransactionalHiveReader: directly inherits OrcReader (no composition wrapping).
47
// ACID column expansion/shrinking done via on_before_read_block/on_after_read_block hooks.
48
// Delete delta reading done via on_after_init_reader hook.
49
class TransactionalHiveReader final : public OrcReader, public TableSchemaChangeHelper {
50
    ENABLE_FACTORY_CREATOR(TransactionalHiveReader);
51
52
public:
53
    TransactionalHiveReader(RuntimeProfile* profile, RuntimeState* state,
54
                            const TFileScanRangeParams& params, const TFileRangeDesc& range,
55
                            size_t batch_size, const std::string& ctz, io::IOContext* io_ctx,
56
                            FileMetaCache* meta_cache = nullptr);
57
    TransactionalHiveReader(RuntimeProfile* profile, RuntimeState* state,
58
                            const TFileScanRangeParams& params, const TFileRangeDesc& range,
59
                            size_t batch_size, const std::string& ctz,
60
                            std::shared_ptr<io::IOContext> io_ctx_holder,
61
                            FileMetaCache* meta_cache = nullptr);
62
0
    ~TransactionalHiveReader() final = default;
63
64
protected:
65
    // Hook: ACID schema mapping (add transactional columns, map row.* fields)
66
    Status on_before_init_reader(ReaderInitContext* ctx) override;
67
68
    // Hook: read delete delta files
69
    Status on_after_init_reader(ReaderInitContext* /*ctx*/) override;
70
71
    // Hook: expand ACID columns into block before reading
72
    Status on_before_read_block(Block* block) override;
73
74
    // Hook: shrink ACID columns from block after reading
75
    Status on_after_read_block(Block* block, size_t* read_rows) override;
76
77
private:
78
    void _init_transactional_hive_profile();
79
80
    struct TransactionalHiveProfile {
81
        RuntimeProfile::Counter* num_delete_files = nullptr;
82
        RuntimeProfile::Counter* num_delete_rows = nullptr;
83
        RuntimeProfile::Counter* delete_files_read_time = nullptr;
84
    };
85
86
    TransactionalHiveProfile _transactional_orc_profile;
87
    AcidRowIDSet _acid_delete_rows;
88
    std::vector<std::string> _col_names;
89
};
90
91
} // namespace doris