Skip to content

Commit

Permalink
Change get_write_count parameter type to const reference
Browse files Browse the repository at this point in the history
  • Loading branch information
YoshiakiNishimura committed Feb 13, 2025
1 parent f45949b commit 0a2870b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
8 changes: 8 additions & 0 deletions src/jogasaki/api/impl/executable_statement.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,12 @@ inline api::impl::executable_statement& get_impl(api::executable_statement& es)
return unsafe_downcast<api::impl::executable_statement>(es);
}

/**
* @brief accessor to the impl of api::executable_statement
* @return reference to the const impl object
*/
inline api::impl::executable_statement const& get_impl(api::executable_statement const& es) {
return unsafe_downcast<api::impl::executable_statement const>(es);
}

} // namespace jogasaki::api::impl
9 changes: 4 additions & 5 deletions src/jogasaki/api/impl/service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1412,7 +1412,7 @@ void service::execute_query(
std::shared_ptr<tateyama::api::server::data_channel> ch{};
{
trace_scope_name("acquire_channel"); //NOLINT
const auto max_write_count = get_write_count(e);
const auto max_write_count = get_write_count(*e);
if (auto rc = res->acquire_channel(info->name_, ch, max_write_count);
rc != tateyama::status::ok) {
auto msg = "creating output channel failed (maybe too many requests)";
Expand Down Expand Up @@ -1604,7 +1604,7 @@ void service::execute_dump(
std::shared_ptr<tateyama::api::server::data_channel> ch{};
{
trace_scope_name("acquire_channel"); //NOLINT
const auto max_write_count = get_write_count(e);
const auto max_write_count = get_write_count(*e);
if (auto rc = res->acquire_channel(info->name_, ch, max_write_count);
rc != tateyama::status::ok) {
auto msg = "creating output channel failed (maybe too many requests)";
Expand Down Expand Up @@ -1750,9 +1750,8 @@ jogasaki::api::database* service::database() const noexcept {
return db_;
}

std::size_t service::get_write_count(
std::unique_ptr<jogasaki::api::executable_statement> const& es) const noexcept {
const auto& impl_stmt = get_impl(*es);
std::size_t service::get_write_count(jogasaki::api::executable_statement const& es) const noexcept {
const auto& impl_stmt = get_impl(es);
const auto partitions = impl_stmt.body()->mirrors()->get_partitions();
if (VLOG_IS_ON(log_debug)) {
std::stringstream ss{};
Expand Down
2 changes: 1 addition & 1 deletion src/jogasaki/api/impl/service.h
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ class service {
* @return count of the write_count
*/
[[nodiscard]] std::size_t get_write_count(
std::unique_ptr<jogasaki::api::executable_statement> const& es) const noexcept;
jogasaki::api::executable_statement const& es) const noexcept;
};

// public for testing purpose
Expand Down

0 comments on commit 0a2870b

Please sign in to comment.