in src/hbase/client/request-converter.cc [163:194]
std::unique_ptr<Request> RequestConverter::ToMultiRequest(
const ActionsByRegion &actions_by_region) {
auto pb_req = Request::multi();
auto pb_msg = std::static_pointer_cast<hbase::pb::MultiRequest>(pb_req->req_msg());
for (const auto &action_by_region : actions_by_region) {
auto pb_region_action = pb_msg->add_regionaction();
RequestConverter::SetRegion(action_by_region.first, pb_region_action->mutable_region());
int action_num = 0;
for (const auto ®ion_action : action_by_region.second->actions()) {
auto pb_action = pb_region_action->add_action();
auto pget = region_action->action();
// We store only hbase::Get in hbase::Action as of now. It will be changed later on.
CHECK(pget) << "Unexpected. action can't be null.";
std::string error_msg("");
if (typeid(*pget) == typeid(hbase::Get)) {
auto getp = dynamic_cast<hbase::Get *>(pget.get());
pb_action->set_allocated_get(RequestConverter::ToGet(*getp).release());
} else if (typeid(*pget) == typeid(hbase::Put)) {
auto putp = dynamic_cast<hbase::Put *>(pget.get());
pb_action->set_allocated_mutation(
RequestConverter::ToMutation(MutationType::MutationProto_MutationType_PUT, *putp, -1)
.release());
} else {
throw std::runtime_error("Unexpected action type encountered.");
}
pb_action->set_index(action_num);
action_num++;
}
}
return pb_req;
}