be/src/format/table/paimon_jni_reader.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 "paimon_jni_reader.h" |
19 | | |
20 | | #include <map> |
21 | | |
22 | | #include "core/types.h" |
23 | | #include "format/jni/jni_data_bridge.h" |
24 | | #include "runtime/descriptors.h" |
25 | | #include "runtime/runtime_state.h" |
26 | | |
27 | | namespace doris { |
28 | | class RuntimeProfile; |
29 | | class RuntimeState; |
30 | | class Block; |
31 | | } // namespace doris |
32 | | |
33 | | namespace doris { |
34 | | #include "common/compile_check_begin.h" |
35 | | |
36 | | const std::string PaimonJniReader::PAIMON_OPTION_PREFIX = "paimon."; |
37 | | const std::string PaimonJniReader::HADOOP_OPTION_PREFIX = "hadoop."; |
38 | | |
39 | | PaimonJniReader::PaimonJniReader(const std::vector<SlotDescriptor*>& file_slot_descs, |
40 | | RuntimeState* state, RuntimeProfile* profile, |
41 | | const TFileRangeDesc& range, |
42 | | const TFileScanRangeParams* range_params) |
43 | 0 | : JniReader( |
44 | 0 | file_slot_descs, state, profile, "org/apache/doris/paimon/PaimonJniScanner", |
45 | 0 | [&]() { |
46 | 0 | std::vector<std::string> column_names; |
47 | 0 | std::vector<std::string> column_types; |
48 | 0 | for (const auto& desc : file_slot_descs) { |
49 | 0 | column_names.emplace_back(desc->col_name()); |
50 | 0 | column_types.emplace_back( |
51 | 0 | JniDataBridge::get_jni_type_with_different_string(desc->type())); |
52 | 0 | } |
53 | 0 | const auto& paimon_params = range.table_format_params.paimon_params; |
54 | 0 | std::map<String, String> params; |
55 | 0 | params["paimon_split"] = paimon_params.paimon_split; |
56 | 0 | if (range_params->__isset.paimon_predicate && |
57 | 0 | !range_params->paimon_predicate.empty()) { |
58 | 0 | params["paimon_predicate"] = range_params->paimon_predicate; |
59 | 0 | } else if (paimon_params.__isset.paimon_predicate) { |
60 | 0 | params["paimon_predicate"] = paimon_params.paimon_predicate; |
61 | 0 | } |
62 | 0 | params["required_fields"] = join(column_names, ","); |
63 | 0 | params["columns_types"] = join(column_types, "#"); |
64 | 0 | params["time_zone"] = state->timezone(); |
65 | 0 | if (range_params->__isset.serialized_table) { |
66 | 0 | params["serialized_table"] = range_params->serialized_table; |
67 | 0 | } |
68 | 0 | for (const auto& kv : paimon_params.paimon_options) { |
69 | 0 | params[PAIMON_OPTION_PREFIX + kv.first] = kv.second; |
70 | 0 | } |
71 | 0 | if (range_params->__isset.properties && !range_params->properties.empty()) { |
72 | 0 | for (const auto& kv : range_params->properties) { |
73 | 0 | params[HADOOP_OPTION_PREFIX + kv.first] = kv.second; |
74 | 0 | } |
75 | 0 | } else if (paimon_params.__isset.hadoop_conf) { |
76 | 0 | for (const auto& kv : paimon_params.hadoop_conf) { |
77 | 0 | params[HADOOP_OPTION_PREFIX + kv.first] = kv.second; |
78 | 0 | } |
79 | 0 | } |
80 | 0 | return params; |
81 | 0 | }(), |
82 | 0 | [&]() { |
83 | 0 | std::vector<std::string> names; |
84 | 0 | for (const auto& desc : file_slot_descs) { |
85 | 0 | names.emplace_back(desc->col_name()); |
86 | 0 | } |
87 | 0 | return names; |
88 | 0 | }(), |
89 | 0 | range.__isset.self_split_weight ? range.self_split_weight : -1) { |
90 | 0 | if (range.table_format_params.__isset.table_level_row_count) { |
91 | 0 | _remaining_table_level_row_count = range.table_format_params.table_level_row_count; |
92 | 0 | } else { |
93 | 0 | _remaining_table_level_row_count = -1; |
94 | 0 | } |
95 | 0 | } |
96 | | |
97 | 0 | Status PaimonJniReader::get_next_block(Block* block, size_t* read_rows, bool* eof) { |
98 | 0 | if (_push_down_agg_type == TPushAggOp::type::COUNT && _remaining_table_level_row_count >= 0) { |
99 | 0 | auto rows = std::min(_remaining_table_level_row_count, |
100 | 0 | (int64_t)_state->query_options().batch_size); |
101 | 0 | _remaining_table_level_row_count -= rows; |
102 | 0 | auto mutate_columns = block->mutate_columns(); |
103 | 0 | for (auto& col : mutate_columns) { |
104 | 0 | col->resize(rows); |
105 | 0 | } |
106 | 0 | block->set_columns(std::move(mutate_columns)); |
107 | 0 | *read_rows = rows; |
108 | 0 | if (_remaining_table_level_row_count == 0) { |
109 | 0 | *eof = true; |
110 | 0 | } |
111 | |
|
112 | 0 | return Status::OK(); |
113 | 0 | } |
114 | 0 | return JniReader::get_next_block(block, read_rows, eof); |
115 | 0 | } |
116 | | |
117 | 0 | Status PaimonJniReader::init_reader() { |
118 | 0 | return open(_state, _profile); |
119 | 0 | } |
120 | | #include "common/compile_check_end.h" |
121 | | } // namespace doris |