Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move key_begin and key_end members from scan_context to scan_info #121

Closed
wants to merge 1 commit into from

Conversation

YoshiakiNishimura
Copy link
Contributor

https://github.com/project-tsurugi/tsurugi-issues/issues/991

改造

scan_context

以下のメンバーを取り除く
data::aligned_buffer key_begin_{};
data::aligned_buffer key_end_{};

scan_info

以下のメンバーを追加する
data::aligned_buffer key_begin_{};
data::aligned_buffer key_end_{};
std::size_t blen_{};
std::size_t elen_{};
status status_result_{};

scan::open

機能のほとんどをflow::create_task_contextにもっていく
残す機能は

  • secondaryの設定
  • エラーメッセージの処理
  • iteratorの設定
status scan::open(scan_context& ctx) {  //NOLINT(readability-make-member-function-const)
    auto& stg = use_secondary_ ? *ctx.secondary_stg_ : *ctx.stg_;
    if (auto status = ctx.scan_info_->status_result(); status != status::ok) {
        return status;
    }
    if(auto res = stg.content_scan(
            *ctx.tx_,
            ctx.scan_info_->begin_key(),
            ctx.scan_info_->begin_kind(use_secondary_),
            ctx.scan_info_->end_key(),
            ctx.scan_info_->end_kind(use_secondary_),
            ctx.it_
        ); res != status::ok) {
        handle_kvs_errors(*ctx.req_context(), res);
        handle_generic_error(*ctx.req_context(), res, error_code::sql_execution_exception);
        return res;
    }
    return status::ok;
}

flow::create_task_context

scan::operatorの設定はimpl:task_contextに新設のencode_keyメンバ関数を行う

std::shared_ptr<impl::task_context> flow::create_task_context(
    std::size_t partition,
    impl::ops::operator_container const& operators,
    std::size_t sink_index
) {
...
    if (ctx->scan_info() != nullptr){
        ctx->encode_key();
    }
...

impl::task_context

void task_context::encode_key(){
    std::size_t blen{};
    std::string msg{};
    executor::process::impl::variable_table vars{};
    if(auto res = impl::ops::details::encode_key(
        request_context_,
        scan_info_->begin_columns(),
        vars,
        *getImplWorkContext().varlen_resource(),
        scan_info_->key_begin(),
        blen,
        msg
      );
       res != status::ok) {
        if(res == status::err_type_mismatch) {
            // only on err_type_mismatch, msg is filled with error message. use it to create the error info in request context
            set_error(*request_context_, error_code::unsupported_runtime_feature_exception, msg, res);
        }
        scan_info_->status_result(res);
        return;
    }
    scan_info_->blen(blen);
    std::size_t elen{};
    if(auto res = impl::ops::details::encode_key(
        request_context_,
        scan_info_->end_columns(),
        vars,
        *getImplWorkContext().varlen_resource(),
        scan_info_->key_end(),
        elen,
        msg
       );
       res != status::ok) {
        if(res == status::err_type_mismatch) {
            // only on err_type_mismatch, msg is filled with error message. use it to create the error info in request context
            set_error(*request_context_, error_code::unsupported_runtime_feature_exception, msg, res);
        }
        scan_info_->status_result(res);
    }
    scan_info_->elen(elen);
    scan_info_->status_result(status::ok);
    return;
}

@YoshiakiNishimura YoshiakiNishimura deleted the move-key-to-scan-info branch October 22, 2024 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant