1

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 Answer 1

2

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.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.