14.6.2.3 GraphChangeSet with Partitioned IDs
You can use the GraphChangeSet
API with graph with partitioned IDs.
Ensure to set both the vertex ID generation strategy as well as the edge ID generation
strategy to IdGenerationStrategy.USER_IDS
. Furthermore, make sure to
set the vertex ID type to String
. An edge ID type does not need to be
specified.
You can add, update and remove vertices and edges as shown in the following examples:
GraphChangeSet<String> changeSet = g.createChangeSet(IdGenerationStrategy.USER_IDS, IdGenerationStrategy.USER_IDS);
changeSet.addVertex("Accounts(1002)").setProperty("NAME","User1002");
changeSet.updateVertex("Accounts(4)").setProperty("NAME","User4");
changeSet.removeVertex("Accounts(3)");
changeSet.addEdge("Transfers(5002)", "Accounts(5)", "Accounts(6)").setProperty("AMOUNT", 12.50);
changeSet.updateEdge("Transfers(5)").setProperty("DESCRIPTION", 'Transfer from User');
changeSet.removeEdge("Transfers(5001)");
PgxGraph g1 = changeSet.build();
change_set = graph.create_change_set(vertex_id_generation_strategy = 'user_ids', edge_id_generation_strategy = 'user_ids')
change_set.add_vertex("Accounts(1002)").set_property("NAME", "User1002")
change_set.update_vertex("Accounts(4)").set_property("NAME", "User4")
change_set.remove_vertex("Accounts(3)")
change_set.remove_edge("Transfers(5001)")
PgxGraph g1 = change_set.build()
Note:
You cannot use thesetLabel()
API when IDs are partitioned. The vertex or edge
will be labelled automatically based on the label attached to the provider (for
which the name is provided as part of the ID). Similarly, you cannot set the vertex
or edge key properties through the setProperty()
API as the value
is already extracted from the vertex or edge ID.
Parent topic: Modifying Loaded Graphs Using ChangeSet