-
Notifications
You must be signed in to change notification settings - Fork 19
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
results removal #270
results removal #270
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is more like cosmetic notes (except explicit for ctor). Also could you plz add describtion into your PR? Looks like we just moved from multiple result types to one cursor type.
Looks fine to me, but wait @kotbegemot approve plz. |
@@ -124,7 +124,7 @@ namespace services { | |||
bool memory_storage_t::check_database_(components::session::session_id_t& session, const database_name_t& name) { | |||
if (!is_exists_database_(name)) { | |||
actor_zeta::send(current_message()->sender(), this->address(), handler_id(route::execute_plan_finish), session, | |||
make_error(error_code_t::database_not_exists, "database not exists")); | |||
make_error(actor_zeta::detail::pmr::get_default_resource(), error_code_t::database_not_exists, "database not exists")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be we can use namespace alias here? @kotbegemot WDYT?
namespace az_res = actor_zeta::detail::pmr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw this actor_zeta::detail::pmr::get_default_resource()
@kotbegemot why don't just wrap this function and place in in some memory utils?
For example in core::pmr?
std::pmr::memory_resource* default_resource(){
return actor_zeta::detail::pmr::get_default_resource();
}
and usage:
make_error(core::pmr::get_default_resource(), error_code_t::database_not_exists, "database not exists"));
I don't like an idea of usage function from detail
namespace of other library. Usually this namespace means "for internal usage".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for now please use
https://en.cppreference.com/w/cpp/memory/get_default_resource
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even though, I thinl it'll better to create aliase fot this, if we want in a future chanege it to something else it will be much easier to do in one place.
services/dispatcher/dispatcher.cpp
Outdated
@@ -211,7 +210,7 @@ namespace services::dispatcher { | |||
} | |||
|
|||
if (ql->type() == statement_type::create_collection) { | |||
collection_address_book_.emplace(collection_full_name_t(ql->database_, ql->collection_), result.get<result_address_t>().address); | |||
collection_address_book_.emplace(collection_full_name_t(ql->database_, ql->collection_), result->begin()->get()->address()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
result->begin()->get()->address()
@kotbegemot is it expected? I mean result->begin()
looks quite strange to me and not logical at first glance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to cover in some method and just call
result->get_address();
@OrangeSmokingJacket @kotbegemot What is selection logic to use |
services/dispatcher/dispatcher.cpp
Outdated
remove_session(session_to_address_, session); | ||
} | ||
actor_zeta::send(s.address(), dispatcher_t::address(), handler_id(route::execute_ql_finish), session, result); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@OrangeSmokingJacket please pay attention while rebase on the latest commit with inserts. This operation should be valid only for non mutable or from wal operations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@makeyavelly cc
@@ -124,7 +124,7 @@ namespace services { | |||
bool memory_storage_t::check_database_(components::session::session_id_t& session, const database_name_t& name) { | |||
if (!is_exists_database_(name)) { | |||
actor_zeta::send(current_message()->sender(), this->address(), handler_id(route::execute_plan_finish), session, | |||
make_error(error_code_t::database_not_exists, "database not exists")); | |||
make_error(actor_zeta::detail::pmr::get_default_resource(), error_code_t::database_not_exists, "database not exists")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw this actor_zeta::detail::pmr::get_default_resource()
@kotbegemot why don't just wrap this function and place in in some memory utils?
For example in core::pmr?
std::pmr::memory_resource* default_resource(){
return actor_zeta::detail::pmr::get_default_resource();
}
and usage:
make_error(core::pmr::get_default_resource(), error_code_t::database_not_exists, "database not exists"));
I don't like an idea of usage function from detail
namespace of other library. Usually this namespace means "for internal usage".
services/dispatcher/dispatcher.cpp
Outdated
@@ -211,7 +210,7 @@ namespace services::dispatcher { | |||
} | |||
|
|||
if (ql->type() == statement_type::create_collection) { | |||
collection_address_book_.emplace(collection_full_name_t(ql->database_, ql->collection_), result.get<result_address_t>().address); | |||
collection_address_book_.emplace(collection_full_name_t(ql->database_, ql->collection_), result->begin()->get()->address()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to cover in some method and just call
result->get_address();
services/dispatcher/dispatcher.cpp
Outdated
@@ -263,11 +262,12 @@ namespace services::dispatcher { | |||
auto logic_plan = create_logic_plan(statement).first; | |||
actor_zeta::send(it_collection->second, dispatcher_t::address(), collection::handler_id(collection::route::insert_documents), session, logic_plan, components::ql::storage_parameters{}); | |||
} else { | |||
actor_zeta::send(address, dispatcher_t::address(), collection::handler_id(collection::route::insert_finish), session, result_insert(resource_)); | |||
actor_zeta::send(address, dispatcher_t::address(), collection::handler_id(collection::route::insert_finish), session, | |||
make_from_sub_cursor(actor_zeta::detail::pmr::get_default_resource(), new sub_cursor_t(resource_, address))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code hard to read, looks like 2 lines, lets create cursor before send and move it:
auto cursor = make_from_sub_cursor(actor_zeta::detail::pmr::get_default_resource(), new sub_cursor_t(resource_, address));
actor_zeta::send(address, dispatcher_t::address(), collection::handler_id(collection::route::insert_finish), session, std::move(cursor));
and you can do this for all similar cases.
@kotbegemot What is your opinion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dispatcher does not create cursors; the logic needs to be changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kotbegemot you mean this line is not correct?
actor_zeta::send(address, dispatcher_t::address(), collection::handler_id(collection::route::insert_finish), session,
make_from_sub_cursor(actor_zeta::detail::pmr::get_default_resource(), new sub_cursor_t(resource_, address)));
services/dispatcher/dispatcher.cpp
Outdated
@@ -298,11 +298,12 @@ namespace services::dispatcher { | |||
auto logic_plan = create_logic_plan(statement); | |||
actor_zeta::send(it_collection->second, dispatcher_t::address(), collection::handler_id(collection::route::delete_documents), session, std::move(logic_plan.first), std::move(logic_plan.second)); | |||
} else { | |||
actor_zeta::send(address, dispatcher_t::address(), collection::handler_id(collection::route::delete_finish), session, result_delete(resource_)); | |||
actor_zeta::send(address, dispatcher_t::address(), collection::handler_id(collection::route::delete_finish), session, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
split
services/dispatcher/dispatcher.cpp
Outdated
@@ -333,11 +334,12 @@ namespace services::dispatcher { | |||
auto logic_plan = create_logic_plan(statement); | |||
actor_zeta::send(it_collection->second, dispatcher_t::address(), collection::handler_id(collection::route::update_documents), session, std::move(logic_plan.first), std::move(logic_plan.second)); | |||
} else { | |||
actor_zeta::send(address, dispatcher_t::address(), collection::handler_id(collection::route::update_finish), session, result_update(resource_)); | |||
actor_zeta::send(address, dispatcher_t::address(), collection::handler_id(collection::route::update_finish), session, | |||
make_from_sub_cursor(actor_zeta::detail::pmr::get_default_resource(), new sub_cursor_t(resource_, address))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
split
services/dispatcher/dispatcher.cpp
Outdated
@@ -263,11 +262,12 @@ namespace services::dispatcher { | |||
auto logic_plan = create_logic_plan(statement).first; | |||
actor_zeta::send(it_collection->second, dispatcher_t::address(), collection::handler_id(collection::route::insert_documents), session, logic_plan, components::ql::storage_parameters{}); | |||
} else { | |||
actor_zeta::send(address, dispatcher_t::address(), collection::handler_id(collection::route::insert_finish), session, result_insert(resource_)); | |||
actor_zeta::send(address, dispatcher_t::address(), collection::handler_id(collection::route::insert_finish), session, | |||
make_from_sub_cursor(actor_zeta::detail::pmr::get_default_resource(), new sub_cursor_t(resource_, address))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a note, no need to fix. @kotbegemot are you ok with new
here? if it throw exception, actor_zeta::detail::pmr::get_default_resource() will be released?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dispatcher does not create cursors; the logic needs to be changed.
for now please use
https://en.cppreference.com/w/cpp/memory/get_default_resource
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general looks fine, well done!
I have only one question about default resource, why in memory_manegment
we use std::prm
but in collections actor_zeta::prm::detail
if (ql->type() == statement_type::create_collection) { | ||
trace(log_, "dispatcher_t::execute_ql_finish: create_collection"); | ||
collection_address_book_.emplace(collection_full_name_t(ql->database_, ql->collection_), result.get<result_address_t>().address); | ||
collection_address_book_.emplace(collection_full_name_t(ql->database_, ql->collection_), last_collection_.at(session)); | ||
last_collection_.erase(session); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@OrangeSmokingJacket Can you give some comments why we need this?
|
||
namespace services { | ||
|
||
using namespace services::memory_storage; | ||
|
||
std::pmr::memory_resource* default_resource(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not bad but I recommend to place it in core directory and use it everywhere instead of std::pmr::get_default_resource()
|
||
cursor_t_ptr make_cursor(std::pmr::memory_resource* resource, operation_status_t op_status); | ||
cursor_t_ptr make_cursor(std::pmr::memory_resource* resource); | ||
cursor_t_ptr make_cursor(std::pmr::memory_resource* resource, error_code_t type, const std::string& what = std::string()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@OrangeSmokingJacket @kotbegemot this function designed only for error cursor, so might be we can rename it into
make_error_cursor
or
make_error
in this case much easier to read code when we return an error.
services/collection/create_index.cpp
Outdated
@@ -44,7 +44,8 @@ namespace services::collection { | |||
void collection_t::create_index(const session_id_t& session, create_index_t& index) { | |||
debug(log(), "collection::create_index : {} {} {}", name_.to_string(), name_index_type(index.index_type_), keys_index(index.keys_)); //todo: maybe delete | |||
if (dropped_) { | |||
actor_zeta::send(current_message()->sender(), address(), handler_id(route::create_index_finish), session, result_create_index(false)); | |||
actor_zeta::send(current_message()->sender(), address(), handler_id(route::create_index_finish), session, | |||
make_cursor(actor_zeta::detail::pmr::get_default_resource(), error_code_t::collection_dropped)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@OrangeSmokingJacket @kotbegemot sorry I don't get, for actors we use actor_zeta::detail::pmr::get_default_resource()
in make_cursor
? Not std::prm::get_default_resource()
?
@@ -132,7 +136,7 @@ namespace services { | |||
if (check_database_(session, name.database)) { | |||
if (!is_exists_collection_(name)) { | |||
actor_zeta::send(current_message()->sender(), this->address(), handler_id(route::execute_plan_finish), session, | |||
make_error(error_code_t::collection_not_exists, "collection not exists")); | |||
make_cursor(default_resource(), error_code_t::collection_not_exists, "collection not exists")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In collection we still use default_resource()
from actor_zeta, why?
actor_zeta::send(dispatcher, address(), handler_id(route::size_finish), session, | ||
make_cursor(context_->resource(), error_code_t::collection_dropped)); | ||
} else { | ||
auto* sub_cursor = new sub_cursor_t(context_->resource(), address()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kotbegemot This place(how we add docs into cursor) looks like can be improvement in the future. For now we can leave it as it is.
REQUIRE(cursor->is_success()); | ||
REQUIRE(!cursor->is_error()); | ||
} | ||
INFO("error cursor") { | ||
std::string description = "error description"; | ||
auto cursor = components::cursor::make_cursor(actor_zeta::detail::pmr::get_default_resource(), components::cursor::error_code_t::other_error, description); | ||
auto cursor = components::cursor::make_cursor(std::pmr::get_default_resource(), components::cursor::error_code_t::other_error, description); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use default_resource()
function
Functionality of components::result::result_t has been moved to components::cursor::cursor_t.
dispatcher_t and other associated structures now return and receive cursor_t_ptr, which can carry operation status(success or failure), error with description (if there was one) and changes to a collection
ctests and pytests are working properly