简体   繁体   English

ArangoDB 中的节点哈希?

[英]Node Hash in ArangoDB?

I'm using ArangoDB for Graph-Versioning and would be looking for a faster method to evaluate whether or not a Node is the same in two different collections.我正在使用 ArangoDB 进行图形版本控制,并且正在寻找一种更快的方法来评估两个不同集合中的节点是否相同。 Apart from hashing each node before I write it - does ArangoDB have any mechanism that lets me read the Hash of the node?除了在我写之前对每个节点进行散列 - ArangoDB 是否有任何机制可以让我读取节点的散列? I usually access the Database with Python-Arango.我通常使用 Python-Arango 访问数据库。

If hashing it by myself is the only viable option what would be a reasonable Hash-Function for these types of documents in a Graph-DB?如果我自己散列是唯一可行的选择,那么对于 Graph-DB 中的这些类型的文档,什么是合理的散列函数? _id should not be included as the same node in two different collections would still differ. _id不应包含在内,因为两个不同集合中的同一节点仍然会有所不同。 _rev would not really matter, and I am not sure if _key is in fact required as the node is identified by it any way. _rev并不重要,我不确定_key是否真的需要,因为节点是由它以任何方式标识的。

You need to make your own hash algo to do this.您需要制作自己的哈希算法来执行此操作。

The issue is that the unique values of a document that build the hash are user specific, so you need to build that hash value externally and save it with every document.问题是构建散列的文档的唯一值是用户特定的,因此您需要在外部构建该散列值并将其与每个文档一起保存。

To confirm uniqueness, you can do that via a Foxx Microservice or in your AQL query, where you throw an error if multiple nodes are ever found with duplicate hashes.要确认唯一性,您可以通过 Foxx 微服务或在您的 AQL 查询中执行此操作,如果发现多个节点具有重复的哈希值,则会引发错误。

If you want to enforce uniqueness on inserts, then you'll need to build that logic externally.如果要对插入强制执行唯一性,则需要在外部构建该逻辑。

You then have the option of trusting your uniqueness or setting up a Foxx Microservice that would scour the collections in scope to ensure no other document had the same hash value.然后,您可以选择信任您的唯一性或设置 Foxx 微服务,该微服务将搜索范围内的集合,以确保没有其他文档具有相同的哈希值。

The performance of querying many other collections would be poor, so an alternative to that is to set up a Foxx Queue that accepted document updates, and you then have a Foxx service performing the INSERT/UPDATE commands from the queue.查询许多其他集合的性能会很差,因此另一种方法是设置一个接受文档更新的 Foxx 队列,然后让 Foxx 服务从队列中执行 INSERT/UPDATE 命令。 That way you don't slow down your client application, and data will be eventually updated in Arango as fast as possible.这样您就不会减慢客户端应用程序的速度,并且数据最终会尽快在 Arango 中更新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM