J@ArangoDB

{ "subject" : "ArangoDB", "tags": [ "multi-model", "nosql", "database" ] }

On Building AQL Query Strings

I recently wrote two recipes about generating AQL query strings. They are contained in the ArangoDB cookbook by now:

After that, Github user tracker1 suggested in Github issue 1457 to take the ES6 template string variant even further, using a generator function for string building, and also using promises and ES7 async/await.

We can’t use ES7 async/await in ArangoDB at the moment due to lacking support in V8, but the suggested template string generator function seemed to be an obvious improvement that deserved inclusion in ArangoDB.

How V8 Is Used in ArangoDB

ArangoDB allows running user-defined JavaScript code in the database. This can be used for more complex, stored procedures-like database operations. Additionally, ArangoDB’s Foxx framework can be used to make any database functionality available via an HTTP REST API. It’s easy to build microservices with it, using the scripting functionality for tasks like access control, data validation, sanitation etc.

We often get asked how the scripting functionality is implemented under the hood. Additionally, several people have asked how ArangoDB’s JavaScript functionality relates to node.js.

This post tries to explain that in detail.

Throughput Enhancements

We’ve recently been working on improving ArangoDB’s throughput, especially when using the ArangoDB’s interface.

In this post, I will show some of the improvements already achieved, though the work is not yet finished. Therefore, the results shown here are still somewhat preliminary.

Introducing RETURN DISTINCT

Last week saw the addition of the RETURN DISTINCT for AQL queries. This is a new shortcut syntax for making result sets unique.

For this purpose it can be used as an easier-to-memorize alternative for the already existing COLLECT statement. COLLECT is very flexible and can be used for multiple purposes, but it is syntactic overkill for making a result set unique.

The new RETURN DISTINCT syntax makes queries easier to write and understand.

AQL Object Literal Simplification

ArangoDB’s devel branch recently saw a change that makes writing some AQL queries a bit simpler.

The change introduces an optional shorthand notation for object attributes in the style of ES6’s enhanced object literal notation.

ES6 Features in ArangoDB 2.7

ArangoDB 2.6 uses V8 engine version 3.31.74.1 for running its own and all user-defined JavaScript code. In ArangoDB 2.7 (currently in development), we have upgraded V8 to version 4.3.61.

The new V8 version in ArangoDB 2.7 provides several additional ES6 features that can be used to improve JavaScript usability and code quality. This blog post showcases strong mode and rest parameters, and also shows how to activate TurboFan, V8’s new JIT compiler for JavaScript.

ArangoDB 2.7 is in development right now, but it can be tried today by compiling it from source.

AQL Improvements for 2.7

With ArangoDB 2.6 being in beta already, it’s time to look at some features scheduled for 2.7. Today I’ll showcase a few AQL parser improvements that are present in the devel branch already, which will be the foundation for the 2.7 release.

Parsing PHP Arrays With PHP

By accident I found this StackOverflow question about how to convert a PHP string with array data into an actual PHP array variable.

For example, if your application gets this string from somewhere:

example string data
1
$string = "array(array('aaa','bbb','ccc','ddd'),array('AAA','BBB','CCC','DDD'))";

How do you convert this into a PHP array variable so you can access the individual array elements? This is what we want to be able to do:

1
2
$result = magicallyConvertStringToArray($string);
var_dump($result[0][0]);  // should be 'aaa'

How do we get to our variable?

Speeding Up Array/object Literal Access

Last week some further optimization slipped into 2.6. The optimization can provide significant speedups in AQL queries using huge array/object bind parameters and passing them into V8-based functions.