1
votes

In many of the examples using the java arangoDB driver, they use method chaining

arangoDB.db("myDatabase").createCollection("myCollection", null);

or

arangoDB.db("myDatabase").collection("myCollection").insertDocument(myObject);

Are there any drawbacks with re-using objects?

ArangoDatabase db = arangoDB.db("myDatabase");
...
db.createCollection("myCollection", null);
ArangoCollection coll = db.collection("myCollection");
...
coll.insertDocument(myObject);

I am not sure if chaining approach is preferred or just for simplicity (fewer lines for an example).

  • Is there much of a performance benefit to reuse? Less object creation overhead...
  • Are connection, database and collection objects thread safe? i.e after getting a database can the object be shared between multiple threads?
1

1 Answers

2
votes

Yes, you can reuse instances of ArangoDatabase, ArangoCollection, ArangoGraph, ArangoVertexCollection, ArangoEdgeCollection.

  • Yes, there is a small performance benefit through less object creation.
  • Yes, all of them are thread-safe. You can share them between threads.