Coverage Report

Created: 2026-04-14 13:42

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