@DELETE @Timed @Path("{key}") @Consumes(APPLICATION_JSON) public void delete(@Context GraphManager manager, @PathParam("graph") String graph, @PathParam("key") String key) { LOG.debug("Graph [{}] remove variable by key '{}'", graph, key); HugeGraph g = graph(manager, graph); commit(g, () -> g.variables().remove(key)); }
@Watched protected void clearVariables() { Variables variables = this.variables(); variables.keys().forEach(key -> variables.remove(key)); }
@Test public void canMergeConflictingGraphVariables() { ChronoGraph g = this.getGraph(); { // initial commit g.variables().set("hello", "world"); g.variables().set("foo", "bar"); g.tx().commit(); } ChronoGraph g1 = g.tx().createThreadedTx(); ChronoGraph g2 = g.tx().createThreadedTx(); g1.variables().set("hello", "john"); g1.variables().remove("foo"); g1.variables().set("john", "doe"); g1.tx().commit(); g2.variables().set("hello", "jack"); g2.variables().set("foo", "baz"); g2.variables().set("jane", "doe"); g2.tx().commit(); assertThat(g.variables().get("hello").orElse(null), is("jack")); assertThat(g.variables().get("foo").orElse(null), is("baz")); assertThat(g.variables().get("john").orElse(null), is("doe")); assertThat(g.variables().get("jane").orElse(null), is("doe")); }
private void mergeGraphVariableChangesInto(final ChronoGraph currentStateGraph) { Set<String> modifiedVariables = this.getContext().getModifiedVariables(); Graph.Variables variables = currentStateGraph.variables(); for (String variable : modifiedVariables) { Object value = this.getContext().getModifiedVariableValue(variable); if (value == null) { variables.remove(variable); } else { variables.set(variable, value); } } }
public static void testVariables(final HugeGraph graph) { // variables test Graph.Variables variables = graph.variables(); variables.set("owner", "zhangyi"); variables.set("time", 3); variables.set("owner", "zhangyi1"); variables.keys(); graph.tx().commit(); variables.remove("time"); variables.get("time"); variables.get("owner"); variables.remove("owner"); variables.get("owner"); }