Updated Sync and Async Java Drivers with ArangoDB 3.1
ArrangoDB 3.1's upcoming release comes with a binary protocol to help speed things along. Read on to find out details and how it can help you get the most of out of your database.
Join the DZone community and get the full member experience.Join For Free
The upcoming 3.1 release comes with a binary protocol — VelocyStream — to transport VelocyPack (internal storage format of ArangoDB introduced with the 3.0 release) data between ArangoDB and client applications. VelocyPack stores a superset of JSON, is more compact and has a fast attribute lookup. On the other hand, VelocyStream allows to send VelocyPack in an optimized form over the network. We think it would be the right time to update our official Java Driver to modernize it and to let it be the first to fully support VelocyStream.
VelocyStream is the new bi-directional async binary protocol of ArangoDB. It supports sending messages pipelined, multiplexed, uni-directional or bi-directional. The messages themselves are VelocyPack objects.
Alongside the HTTP protocol, ArangoDB also uses VelocyPack and VelocyStream. We have decided that the new Java Driver will exclusively use the new more efficient binary protocol. The new version natively supports de-/serialization of Java objects in and out of VelocyPack and also parsing of JSON documents from and in VelocyPack. But this does not only belong to the client – server communication. As a developer, you can work directly on the raw VelocyPack returned by ArangoDB over a light API and profit from the performance and data-types supported by VelocyPack like date, binary and different number-types which is much more comfortable than JSON.
To get a stable driver that takes into consideration all benefits of the new ArangoDB release, the updated version of our Java driver renounces the HTTP protocol and goes with VelocyStream.
ArangoDB Java Driver 4.0
In combination with all of the above and other improvements of ArangoDB 3.1, the new Java Driver (ArangoDB-Java-Driver 4.0) shows up to 4 times better performance in synchronous operations compared to the previous 3.0 version of the driver.
Performance Java-Driver — synchronous read — single Server:
We also have a detailed 10 min Java tutorial for the updated driver, explaining how to perform operations in ArangoDB.
Java Driver With Asynchronous Support
ArangoDB 3.1 and VelocyStream enable the possibility of asynchronous communication. By using Java 8 it becomes possible to get the right API for asynchronous computation — CompletableFuture.
Keeping that in mind, we have decided to also offer a second driver which supports asynchronous calls showing an even better performance — ArangoDB-Java-Driver-Async 4.0. Here we went with Java 8 and built an additional very strong async driver powered by the CompletableFuture.
What About Multi-Document Operations?
What can be better than reducing the time of a requests? Of course reducing the number of needed requests.
The two new drivers now support multi-document operations for insert/delete/update/replace. So instead of batching thousands of documents with just as many requests into ArangoDB, you can now insert thousands of documents together with only one request. Which dramatically reduces network traffic and allows for better performance.
So here we go, here are the two updated versions for the Java crowd of our community:
Try them out with the RC2 of ArangoDB 3.1 and let us know what you think.
Published at DZone with permission of Mark Vollmary, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.