(From a thread on the official Discord Channel)
ArcadeDB provides the useful ArcadeGraph.traversal() that returns a Gremlin traversal. Since 23.11.1, ArcadeDB allowed to execute traversal even with a remote database instance.
While this works, it's sub-optimal because every step is executed on the server side. The best solution should be wrapping the traversal execution as a Gremlin Client call and executing it on the remote GremlinServer. This means the GremlinServer plugin must be activated on ArcadeDB server to use remote traversal.
The only issue with this is the transaction isolation: an open transaction on a remote database, and therefore remote ArcadeGraph, will be in a separate scope than the traversal. This means if a client is executing an insert of vertices, the transaction must be committed before executing the remote traversal, or the traversal will not see the newly added vertices.
Example:
@Test
public void executeTraversalSeparateTransactions() {
try (ArcadeGraphFactory pool = ArcadeGraphFactory.withRemote("127.0.0.1", 2480, getDatabaseName(), "root",
BaseGraphServerTest.DEFAULT_PASSWORD_FOR_TESTS)) {
try (final ArcadeGraph graph = pool.get()) {
for (int i = 0; i < 1_000; i++)
graph.addVertex(org.apache.tinkerpop.gremlin.structure.T.label, "inputstructure", "json", "{\"name\": \"Elon\"}");
// THIS IS IN THE SAME SCOPE, SO IT CAN SEE THE PENDING VERTICES ADDED EARLIER
try (final ResultSet list = graph.gremlin("g.V().hasLabel(\"inputstructure\").count()").execute()) {
Assertions.assertEquals(1_000, (Integer) list.nextIfAvailable().getProperty("result"));
}
graph.tx().commit(); // <-- WITHOUT THIS COMMIT THE 2ND TRAVERSAL WOULD NOT SEE THE ADDED VERTICES
Assertions.assertEquals(1_000, graph.traversal().V().hasLabel("inputstructure").count().next());
Assertions.assertEquals(1_000, graph.traversal().V().hasLabel("inputstructure").count().toList().get(0));
}
}
}
(From a thread on the official Discord Channel)
ArcadeDB provides the useful
ArcadeGraph.traversal()that returns a Gremlin traversal. Since 23.11.1, ArcadeDB allowed to execute traversal even with a remote database instance.While this works, it's sub-optimal because every step is executed on the server side. The best solution should be wrapping the traversal execution as a Gremlin Client call and executing it on the remote GremlinServer. This means the GremlinServer plugin must be activated on ArcadeDB server to use remote traversal.
The only issue with this is the transaction isolation: an open transaction on a remote database, and therefore remote ArcadeGraph, will be in a separate scope than the traversal. This means if a client is executing an insert of vertices, the transaction must be committed before executing the remote traversal, or the traversal will not see the newly added vertices.
Example: