MCPcopy Index your code
hub / github.com/ShiftLeftSecurity/overflowdb / copyTo

Method copyTo

core/src/main/java/overflowdb/Graph.java:396–414  ·  view source on GitHub ↗

Copies all nodes/edges into the given empty graph, preserving their ids and properties.

(Graph destination)

Source from the content-addressed store, hash-verified

394
395 /** Copies all nodes/edges into the given empty graph, preserving their ids and properties. */
396 public void copyTo(Graph destination) {
397 if (destination.nodeCount() > 0) throw new AssertionError("destination graph must be empty, but isn't");
398 nodes().forEachRemaining(node -> {
399 destination.addNode(node.id(), node.label(), PropertyHelper.toKeyValueArray(node.propertiesMap()));
400 });
401 nodes().forEachRemaining( node -> {
402 NodeDb mapped = ((NodeRef<NodeDb>) destination.node(node.id())).get();
403
404 node.outE().forEachRemaining(edge -> {
405 NodeRef<?> other = (NodeRef<?>) destination.node(edge.inNode().id());
406 mapped.storeAdjacentNode(Direction.OUT, edge.label(), other, PropertyHelper.toKeyValueArray(edge.propertiesMap()));
407 });
408 node.inE().forEachRemaining(edge -> {
409 NodeRef<?> other = (NodeRef<?>) destination.node(edge.outNode().id());
410 mapped.storeAdjacentNode(Direction.IN, edge.label(), other, PropertyHelper.toKeyValueArray(edge.propertiesMap()));
411 });
412
413 });
414 }
415
416 public void remove(Node node) {
417 final NodeRef nodeRef = getNodeRef(node);

Callers 2

shouldDeepCloneGraphMethod · 0.95

Calls 14

nodesMethod · 0.95
toKeyValueArrayMethod · 0.95
storeAdjacentNodeMethod · 0.95
nodeCountMethod · 0.80
getMethod · 0.80
nodeMethod · 0.80
inNodeMethod · 0.80
outNodeMethod · 0.80
labelMethod · 0.65
addNodeMethod · 0.45
idMethod · 0.45
propertiesMapMethod · 0.45

Tested by 2

shouldDeepCloneGraphMethod · 0.76