1

i have tried both the native api and fluent api for datastax graph in java. i found fluent api more readable since it resembles java's OOP.

Native api has less readability in java since basically strings are being appended to create the entire gremlin script. but on the plus side a single call is made to execute the entire gremlin script

i wanted to know which is the best api to go with in case i need to add a large number of edges and vertices in one transaction and what are the performance issues which can occur in either case

Erick Ramirez
  • 13,964
  • 1
  • 18
  • 23
Aditya S
  • 82
  • 1
  • 10

1 Answers1

2

Going forward I would recommend using the Fluent API over the String-based API. While we still support the string-based API in the DataStax drivers, most of our work and improvements will be using the fluent API.

The primary benefits of the Fluent API is that you can use the Apache TinkerPop library directly to form Traversals, it doesn't need to go through the groovy scripting engine (like the String-based API does).

In terms of loading multiple vertices/edges in one transaction, you can do that with Apache TinkerPop, and it will be much more effective than the String-based API because that all doesn't need to be evaluated through the gremlin-groovy engine. Also any future work around batching will likely be done in the Fluent API (via Apache TinkerPop), see JAVA-1311 for more details.

Andy Tolbert
  • 11,418
  • 1
  • 30
  • 45
  • thanks for the answer. I will go ahead with Fluent API. i also had the question on batching since right now in fluent for every traversal which updates the graph i need to run the executeGraph() function and found no way to create a batch of traversals. good to know this also will be available in the near future – Aditya S Jul 24 '17 at 03:13
  • At the moment there is not much you can do other than chain addV() calls on a single traversal. Here's an example of doing that (albeit in scala): https://github.com/mpollmeier/gremlin-scala-examples/blob/master/dse-graph/src/test/scala/SimpleSpec.scala#L82-L89. Hopefully that will change over time. – Andy Tolbert Jul 24 '17 at 14:57