|
| 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 "runtime/query_handle.h" |
| 19 | + |
| 20 | +#include "runtime/query_context.h" |
| 21 | + |
| 22 | +namespace doris { |
| 23 | + |
| 24 | +QueryHandle::QueryHandle(TUniqueId query_id, TQueryOptions query_options, |
| 25 | + std::weak_ptr<QueryContext> query_ctx) |
| 26 | + : _query_id(std::move(query_id)), |
| 27 | + _query_options(std::move(query_options)), |
| 28 | + _query_ctx(std::move(query_ctx)) { |
| 29 | + CHECK(_query_ctx.lock() != nullptr); |
| 30 | + _resource_ctx = _query_ctx.lock()->_resource_ctx; |
| 31 | +} |
| 32 | + |
| 33 | +QueryHandle::~QueryHandle() = default; |
| 34 | + |
| 35 | +std::string QueryHandle::debug_string() const { |
| 36 | + return fmt::format( |
| 37 | + "QueryHandle(query_id={}): {}", print_id(_query_id), |
| 38 | + _merge_controller_handler ? _merge_controller_handler->debug_string() : "null"); |
| 39 | +} |
| 40 | + |
| 41 | +void QueryHandle::set_merge_controller_handler( |
| 42 | + std::shared_ptr<RuntimeFilterMergeControllerEntity>& handler) { |
| 43 | + _merge_controller_handler = handler; |
| 44 | +} |
| 45 | +std::shared_ptr<RuntimeFilterMergeControllerEntity> QueryHandle::get_merge_controller_handler() |
| 46 | + const { |
| 47 | + return _merge_controller_handler; |
| 48 | +} |
| 49 | + |
| 50 | +const TQueryOptions& QueryHandle::query_options() const { |
| 51 | + return _query_options; |
| 52 | +} |
| 53 | + |
| 54 | +std::weak_ptr<QueryContext> QueryHandle::weak_query_ctx() const { |
| 55 | + return _query_ctx; |
| 56 | +} |
| 57 | + |
| 58 | +int QueryHandle::execution_timeout() const { |
| 59 | + return _query_options.__isset.execution_timeout ? _query_options.execution_timeout |
| 60 | + : _query_options.query_timeout; |
| 61 | +} |
| 62 | + |
| 63 | +TUniqueId QueryHandle::query_id() const { |
| 64 | + return _query_id; |
| 65 | +} |
| 66 | + |
| 67 | +std::shared_ptr<ResourceContext> QueryHandle::resource_ctx() const { |
| 68 | + return _resource_ctx; |
| 69 | +} |
| 70 | + |
| 71 | +} // namespace doris |
0 commit comments