ArangoDB的哪些部分由Node-GYP完成 [英] What parts of ArangoDB are done with Node-GYP

查看:101
本文介绍了ArangoDB的哪些部分由Node-GYP完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在弄清楚ArangoDB的结构,以确保它是否可以作为我的长期解决方案.

I am figuring out the structure of ArangoDB to be sure whether it could be my long term solution.

我的重要问题之一是,node-gyp(或Node-Addon)由哪些部分组成-查询生成器如何将JavaScript生成的AQL查询转换为与原生一样快?

One of my important questions is, what parts are made by node-gyp (or Node-Addon) - and how does the query-builder transforms JavaScript generated AQL queries to be fast as native?

我知道我自己也可以更深入地研究代码,但是我认为如果一些核心开发人员回答这个问题(或者解释他们如何向JavaScript和AQL公开功能),这样做会更快.

I know I also could go deeper into the code myself, but I think it is much faster if some of the core developers would answer this (or explain how they expose functionality to JavaScript and AQL).

我认为对于许多负责分析ArangoDB的人来说很有趣. (我们的工作不是相信营销短语和基准……我们必须了解其工作原理.)

I think it is interesting for many people are responsible to analyze ArangoDB. (Our job is not to belief marketing phrases and benchmarks... we have to understand how it works).

我的主要目标是将ArangoDB视为JavaScript开发人员.

My major goal is to look at ArangoDB as an JavaScript developer.

推荐答案

ArangoDB并非由节点或gyp组成.但是,ArangoDB使用Google的V8 JavaScript引擎来执行JavaScript代码,就像node.js一样.

ArangoDB is not made of node or gyp. But ArangoDB uses Google's V8 JavaScript engine to execute JavaScript code, the same as node.js does.

这意味着您可以在ArangoDB中运行用户定义的JavaScript代码,并且V8会即时将其编译为本地代码. ArangoDB自己的一些模块也是用JavaScript编写的.多个第三方JavaScript模块,包括供node.js和npm使用或为之编写的一些模块,也都与ArangoDB捆绑在一起.

That means you can run user-defined JavaScript code inside ArangoDB, and it will be compiled to native code by V8 on the fly. Some of ArangoDB's own modules are written in JavaScript, too. Several third-party JavaScript modules, including a few modules used by or written for node.js and npm, are bundled with ArangoDB, too.

关于与node.js和npm模块的兼容性:

Regarding compatibility with node.js and npm modules:

模块不依赖于node.js内部或其他模块中的代码,它们也可以在ArangoDB中工作.这意味着所有仅使用JavaScript且不需要任何特定于节点的东西的模块都应在ArangoDB中工作. joi是一个很好的例子.依赖于Node.js特定对象或Node.js的C ++扩展的node.js/npm模块将无法在ArangoDB中使用.

modules from node.js and npm work in ArangoDB too as long as they do not rely on node.js internals or code from other modules that do. That means all modules that are JavaScript only and do not require any node specific stuff should work in ArangoDB. joi is a good example for this. node.js/npm modules that rely on node.js-specific object or C++ extensions for node.js will not work in ArangoDB.

ArangoDB本身是用C ++编写的,其某些模块是用JavaScript编写的. V8包装器对象和函数可让用户定义的JavaScript代码和捆绑的ArangoDB JavaScript模块访问ArangoDB的内部结构.这些函数是C ++函数,它们通过告诉V8它们存在的方式向JavaScript公开.

ArangoDB itself is written in C++, with some its modules being written in JavaScript. ArangoDB's internals are made accessible to user-defined JavaScript code and the bundled ArangoDB JavaScript modules by V8 wrapper objects and functions. These functions are C++ functions that are exposed to JavaScript by telling V8 that they exist.

这里是一个示例:ArangoDB公开了一个名为db的JavaScript对象.该对象具有一些预定义的功能,例如_collection(<name>).调用此函数时,将实际上是对C ++函数的调用,该函数随后可以处理其(JavaScript)参数,在这种情况下,该参数应该是集合名称字符串.然后,在C ++函数内部,将查找指定名称的集合.如果找不到,该函数将返回一个JavaScript null对象.如果找到,该函数将返回一个包装在所谓的 V8 external 中的收集对象.对于JavaScript代码,这看起来像一个常规对象,但是该对象再次具有一些C ++绑定.

Here's an example: ArangoDB exposes a JavaScript object named db. This object has some predefined functions, e.g. _collection(<name>). When this function is called, this will effectively be a call to a C++ function, which can then handle its (JavaScript) arguments, which in this case should be a collection name string. Inside the C++ function there will then be a lookup for the collection of the specified name. If not found, the function will return a JavaScript null object. If found, the function will return a collection object, wrapped in a so-called V8 external. For the JavaScript code, this will look like a regular object, but this object has some C++ bindings again.

为了使所有这些工作正常进行,服务器将在启动时在V8上下文中注册db对象,并为所有对象的方法注册包装函数.它将对其他对象和功能执行此操作,因此服务器内部具有完整的JavaScript API.

In order for all this to work, the server will register the db object in a V8 context at start, and also register the wrapper functions for all the object's methods. It will do so for other objects and functions, so there is a full JavaScript API for the server internals.

AQL 是用C ++编写的,将照此执行.但是,某些AQL函数和运算符是用JavaScript实现的.如果AQL查询使用此类函数或运算符,则将生成查询专用的JavaScript代码段,并使用V8即时对其进行编译并执行. 此外,AQL查询可以利用用户定义的JavaScript函数进行计算.这些函数是常规的JavaScript函数,必须在命令中注册才能在查询中使用它们.这些函数的调用如上所述,并生成并执行了一段动态JavaScript代码以调用用户定义的函数.

AQL, ArangoDB's query language, is written in C++ and will be executed as such. Some AQL functions and operators however are implemented in JavaScript. If an AQL query makes use of such function or operator, a query-specific JavaScript snippet will be generated, compiled on the fly using V8 and executed. Additionally, AQL queries can make use of user-defined JavaScript functions for calculations. These functions are regular JavaScript functions, which must be registered with a command before they can be used in a query. Invocation of these functions is as above, with a piece of dynamic JavaScript code being generated and executed to call the user-defined function.

最后, ArangoDB的Foxx框架用JavaScript编写,并允许在ArangoDB服务器中定义HTTP路由.这些路由背后的动作是用户定义的,并且可以通过上述方式访问服务器内部和数据库数据.

Finally, ArangoDB's Foxx framework is written in JavaScript and allows defining HTTP routes in the ArangoDB server. The actions behind these routes are user-defined, and can have access to the server internals and database data via the beforementioned way.

这篇关于ArangoDB的哪些部分由Node-GYP完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆