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