CouchDB如何计算序列ID(seq) [英] How does CouchDB calculate the Sequence Id (seq)
问题描述
我正在源存储库中寻找伪代码或实际代码( https://github.com/ apache / couchdb ),定义CouchDB如何计算 seq
值。
在docs: http://docs.couchdb.org/en/2.2。 0 / intro / overview.html 表示:
对数据库实例的每次更新都会产生一个新的序号。
但是它没有涉及到。我认为这可能与实现有关,请查看复制协议文档中的内容:
序列ID:
变更Feed提供的ID。它必须是渐进的,但可能不总是整数。
1-g1AAAAIreJyVkEsKwjAURZ-toI5cgq5A0sQ0OrI70XyppcaRY92J7kR3ojupaSPUUgotgRd4yTlwbw4A0zRUMLdnpaMkwmyF3Ily9xBwEIuiKLI05KOTW0wkV4rruP29UyGWbordzwKVxWBNOGMKZhertDlarbr5pOT3DV4gudUC9 -MPJX9tpEAYx4TQASns2E24ucuJ7rXJSL1BbEgf3vTwpmedCZkYa7Pulck7Xt7x_usFU2aIHOD4eEfVTVA5KMGUkqhNZV-8_o5i
解决方案您可以找到此处有关更改序列内部的一些信息
序列号反映了集群陈述文档更新序列,此信息被编码为序列号。
序列号的数字部分是每个群集节点中文档更新序列的总和。
序列号的第二部分是base64编码的字符串,其中包含每个群集节点中的更新序列信息。
I am looking for pseudo code or the actual code in the source repository (https://github.com/apache/couchdb) defining how CouchDB calculates the
seq
value.Reviewing the technical overview in the docs: http://docs.couchdb.org/en/2.2.0/intro/overview.html it says:
Each update to a database instance generates a new sequential number.
But it doesn't go into how. I think that it may be implementation dependent, looking at the replication protocol docs it states:
Sequence ID: An ID provided by the Changes Feed. It MUST be incremental, but MAY NOT always be an integer.
1-g1AAAAIreJyVkEsKwjAURZ-toI5cgq5A0sQ0OrI70XyppcaRY92J7kR3ojupaSPUUgotgRd4yTlwbw4A0zRUMLdnpaMkwmyF3Ily9xBwEIuiKLI05KOTW0wkV4rruP29UyGWbordzwKVxWBNOGMKZhertDlarbr5pOT3DV4gudUC9-MPJX9tpEAYx4TQASns2E24ucuJ7rXJSL1BbEgf3vTwpmedCZkYa7Pulck7Xt7x_usFU2aIHOD4eEfVTVA5KMGUkqhNZV-8_o5i
This questions is somewhat related in that it's asking how it calculates another component of a document, the rev:
How does CouchDB calculate the Revision number
解决方案You can find here some information about the change sequence internals
The sequence number reflects the cluster state for a document update sequence, this information is encoded into the sequence number.
The numeric part of the sequence number is the sum of the update sequences of a document in each of the cluster nodes.
The second part of the sequence number is a base64 encoded string with the update sequence information in each of the cluster nodes.
这篇关于CouchDB如何计算序列ID(seq)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!