Revert "Remote edge with gid creation"

Summary: This reverts commit adda7d1200.

Reviewers: teon.banek

Reviewed By: teon.banek

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D1409
This commit is contained in:
Dominik Gleich 2018-05-30 12:59:22 +02:00
parent ce29517998
commit dd04aa7631
7 changed files with 22 additions and 43 deletions

View File

@ -422,10 +422,7 @@ EdgeAccessor GraphDbAccessor::InsertEdge(
} else {
edge_address = db().updates_clients().CreateEdge(transaction_id(), from, to,
edge_type, requested_gid);
CHECK(!requested_gid || *requested_gid == edge_address.gid())
<< "Unable to assign requested edge gid";
edge_type);
from_updated = db().data_manager()
.Elements<Vertex>(transaction_id())

View File

@ -47,15 +47,13 @@ gid::Gid UpdatesRpcClients::CreateVertex(
storage::EdgeAddress UpdatesRpcClients::CreateEdge(
tx::TransactionId tx_id, VertexAccessor &from, VertexAccessor &to,
storage::EdgeType edge_type,
std::experimental::optional<gid::Gid> requested_gid) {
storage::EdgeType edge_type) {
CHECK(from.address().is_remote()) << "In CreateEdge `from` must be remote";
int from_worker = from.address().worker_id();
auto res =
worker_clients_.GetClientPool(from_worker)
.Call<CreateEdgeRpc>(CreateEdgeReqData{
from.gid(), to.GlobalAddress(), edge_type, tx_id, requested_gid});
auto res = worker_clients_.GetClientPool(from_worker)
.Call<CreateEdgeRpc>(CreateEdgeReqData{
from.gid(), to.GlobalAddress(), edge_type, tx_id});
CHECK(res) << "CreateEdge RPC failed on worker: " << from_worker;
RaiseIfRemoteError(res->member.result);
return {res->member.gid, from_worker};

View File

@ -34,16 +34,14 @@ class UpdatesRpcClients {
query::TypedValue> &properties,
std::experimental::optional<gid::Gid> requested_gid);
/// Creates an edge with gid equal to `requested gid` (if possible) on the
/// given worker and returns it's address. If the `to` vertex is on the same
/// worker as `from`, then all remote CRUD will be handled by a call to this
/// function. Otherwise a separate call to `AddInEdge` might be necessary.
/// Throws all the exceptions that can occur remotely as a result of updating
/// a vertex.
storage::EdgeAddress CreateEdge(
tx::TransactionId tx_id, VertexAccessor &from, VertexAccessor &to,
storage::EdgeType edge_type,
std::experimental::optional<gid::Gid> requested_gid);
/// Creates an edge on the given worker and returns it's address. If the `to`
/// vertex is on the same worker as `from`, then all remote CRUD will be
/// handled by a call to this function. Otherwise a separate call to
/// `AddInEdge` might be necessary. Throws all the exceptions that can
/// occur remotely as a result of updating a vertex.
storage::EdgeAddress CreateEdge(tx::TransactionId tx_id, VertexAccessor &from,
VertexAccessor &to,
storage::EdgeType edge_type);
/// Adds the edge with the given address to the `to` vertex as an incoming
/// edge. Only used when `to` is remote and not on the same worker as `from`.

View File

@ -95,7 +95,6 @@ struct CreateEdgeReqData {
storage::VertexAddress to;
storage::EdgeType edge_type;
tx::TransactionId tx_id;
std::experimental::optional<gid::Gid> requested_gid;
private:
friend class boost::serialization::access;
@ -106,7 +105,6 @@ struct CreateEdgeReqData {
ar &to;
ar &edge_type;
ar &tx_id;
ar &requested_gid;
}
};

View File

@ -74,14 +74,12 @@ gid::Gid UpdatesRpcServer::TransactionUpdates<TRecordAccessor>::CreateVertex(
template <typename TRecordAccessor>
gid::Gid UpdatesRpcServer::TransactionUpdates<TRecordAccessor>::CreateEdge(
gid::Gid from, storage::VertexAddress to, storage::EdgeType edge_type,
std::experimental::optional<gid::Gid> requested_gid) {
gid::Gid from, storage::VertexAddress to, storage::EdgeType edge_type) {
auto &db = db_accessor_.db();
auto from_addr = db.storage().LocalizedAddressIfPossible(
storage::VertexAddress(from, db.WorkerId()));
auto to_addr = db.storage().LocalizedAddressIfPossible(to);
auto edge =
db_accessor_.InsertOnlyEdge(from_addr, to_addr, edge_type, requested_gid);
auto edge = db_accessor_.InsertOnlyEdge(from_addr, to_addr, edge_type);
std::lock_guard<SpinLock> guard{lock_};
deltas_.emplace(edge.gid(),
std::make_pair(edge, std::vector<database::StateDelta>{}));
@ -303,9 +301,8 @@ UpdatesRpcServer::TransactionUpdates<TAccessor> &UpdatesRpcServer::GetUpdates(
}
CreateResult UpdatesRpcServer::CreateEdge(const CreateEdgeReqData &req) {
auto gid =
GetUpdates(edge_updates_, req.tx_id)
.CreateEdge(req.from, req.to, req.edge_type, req.requested_gid);
auto gid = GetUpdates(edge_updates_, req.tx_id)
.CreateEdge(req.from, req.to, req.edge_type);
auto from_delta = database::StateDelta::AddOutEdge(
req.tx_id, req.from, req.to, {gid, db_.WorkerId()}, req.edge_type);

View File

@ -48,12 +48,10 @@ class UpdatesRpcServer {
&properties,
std::experimental::optional<gid::Gid> requested_gid);
/// Creates a new edge and returns it's gid (tries to create it with
/// requested gid if possible (tries to create it with requested gid if
/// possible)). Does not update vertices at the end of the edge.
/// Creates a new edge and returns it's gid. Does not update vertices at the
/// end of the edge.
gid::Gid CreateEdge(gid::Gid from, storage::VertexAddress to,
storage::EdgeType edge_type,
std::experimental::optional<gid::Gid> requested_gid);
storage::EdgeType edge_type);
/// Applies all the deltas on the record.
UpdateResult Apply();

View File

@ -378,18 +378,15 @@ class DistributedEdgeCreateTest : public DistributedGraphDbTest {
}
void CreateEdge(database::GraphDb &creator, storage::VertexAddress from_addr,
storage::VertexAddress to_addr,
std::experimental::optional<gid::Gid> requested_gid =
std::experimental::nullopt) {
storage::VertexAddress to_addr) {
CHECK(from_addr.is_remote() && to_addr.is_remote())
<< "Local address given to CreateEdge";
database::GraphDbAccessor dba{creator};
auto edge_type = dba.EdgeType("et");
VertexAccessor v1{from_addr, dba};
VertexAccessor v2{to_addr, dba};
auto edge = dba.InsertEdge(v1, v2, edge_type, requested_gid);
auto edge = dba.InsertEdge(v1, v2, edge_type);
e_ga = edge.GlobalAddress();
EXPECT_TRUE(!requested_gid || *requested_gid == e_ga.gid());
for (auto &kv : props) edge.PropsSet(dba.Property(kv.first), kv.second);
@ -486,10 +483,6 @@ TEST_F(DistributedEdgeCreateTest, RemoteRemoteCycle) {
CheckAll(w1_a, w1_a);
}
TEST_F(DistributedEdgeCreateTest, EdgeWithGid) {
CreateEdge(worker(1), w1_a, w2_a, 1337);
}
class DistributedEdgeRemoveTest : public DistributedGraphDbTest {
protected:
storage::VertexAddress from_addr;