1

我想创建一个带有时间戳和我知道的漂亮值的 MVCCKey。但我意识到 aroachpb.key不是很简单;是否涉及一些前缀/后缀?数据库名称是否也编码为roachpb.key

谁能告诉我 MVCCKey 是如何形成的?它有什么信息?在文档中,它只是说它看起来像 /table/primary/key/column。

4

1 回答 1

2

An engine.MVCCKey combines a regular key with a timestamp. MVCCKeys are encoded into byte strings for use as RockDB keys (RocksDB is configured with a custom comparator so MVCCKeys are sorted correctly even though the timestamp uses a variable-width encoding).

Regular keys are byte strings of type roachpb.Key. For ordinary data records, the keys are constructed from table, column, and index IDs, along with the values of indexed columns. (The database ID is not included here; the database to which a table belongs can be found in the system.descriptors table)

The function keys.PrettyPrint can convert a roachpb.Key to a human-readable form.

于 2016-07-29T15:56:59.903 回答