| // Licensed to the Apache Software Foundation (ASF) under one |
| // or more contributor license agreements. See the NOTICE file |
| // distributed with this work for additional information |
| // regarding copyright ownership. The ASF licenses this file |
| // to you under the Apache License, Version 2.0 (the |
| // "License"); you may not use this file except in compliance |
| // with the License. You may obtain a copy of the License at |
| // |
| // http://www.apache.org/licenses/LICENSE-2.0 |
| // |
| // Unless required by applicable law or agreed to in writing, |
| // software distributed under the License is distributed on an |
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| // KIND, either express or implied. See the License for the |
| // specific language governing permissions and limitations |
| // under the License. |
| |
| #include "jni_reader.h" |
| |
| #include <map> |
| #include <ostream> |
| |
| #include "runtime/descriptors.h" |
| #include "runtime/types.h" |
| #include "vec/core/types.h" |
| |
| namespace doris { |
| #include "common/compile_check_begin.h" |
| class RuntimeProfile; |
| class RuntimeState; |
| |
| namespace vectorized { |
| class Block; |
| } // namespace vectorized |
| } // namespace doris |
| |
| namespace doris::vectorized { |
| |
| MockJniReader::MockJniReader(const std::vector<SlotDescriptor*>& file_slot_descs, |
| RuntimeState* state, RuntimeProfile* profile) |
| : JniReader(file_slot_descs, state, profile) { |
| std::ostringstream required_fields; |
| std::ostringstream columns_types; |
| std::vector<std::string> column_names; |
| int index = 0; |
| for (const auto& desc : _file_slot_descs) { |
| std::string field = desc->col_name(); |
| std::string type = JniConnector::get_jni_type_with_different_string(desc->type()); |
| column_names.emplace_back(field); |
| if (index == 0) { |
| required_fields << field; |
| columns_types << type; |
| } else { |
| required_fields << "," << field; |
| columns_types << "#" << type; |
| } |
| index++; |
| } |
| std::map<String, String> params = {{"mock_rows", "10240"}, |
| {"required_fields", required_fields.str()}, |
| {"columns_types", columns_types.str()}}; |
| _jni_connector = std::make_unique<JniConnector>("org/apache/doris/common/jni/MockJniScanner", |
| params, column_names); |
| } |
| |
| Status MockJniReader::init_reader() { |
| RETURN_IF_ERROR(_jni_connector->init()); |
| return _jni_connector->open(_state, _profile); |
| } |
| #include "common/compile_check_end.h" |
| } // namespace doris::vectorized |