Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.Original topic: [求助]Tikv client中v2版本的 raw kv的编码实现方式疑问
|
username: TiDBer_SNvfY66C
Recently, while reviewing the master branch of the TiKV Go client code, I encountered a question related to the raw KV v2 API encoding:
Known facts:
- The key in the v2 API is encoded before being stored in the persistent layer. The encoding method involves adding a prefix to the key first, then encoding the prefixed key using memcomparable-format encoding. The final stored key on the server is the encoded key.
Question:
- In the Go client’s code, before the rawkv client sends an RPC request, it performs prefix encoding on the key in the request parameters (req), but does not perform memcomparable-format encoding. This means that memcomparable-format encoding is handled by the server side. My question is, why not implement both encoding steps entirely on the client side or entirely on the server side? Is there a specific reason for this?