[Help] Questions about the implementation of raw kv encoding in v2 version of Tikv client

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:

  1. 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:

  1. 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?
| username: TiDBer_SNvfY66C | Original post link

Send RPC request code: client-go/internal/client/client.go at dc130aa0d3b1cdd4eeb8b26caa3299d4fafb4a30 · tikv/client-go · GitHub

Encode request parameters code: client-go/internal/client/api_version.go at dc130aa0d3b1cdd4eeb8b26caa3299d4fafb4a30 · tikv/client-go · GitHub

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.