How to decode the value data queried using tikv-ctl raw-scan

How to decode the value data queried using tikv-ctl raw-scan

/export/tidb-deploy/tikv-20160/bin/tikv-ctl --data-dir /export/tidb-data/tikv-20160 raw-scan

key: “zt\200\000\000\000\000\000\000\377\246_r\200\000\000\001a\377\354\230+\000\000\000\000\000\372\372\006\313#vG\377\375”, value: “\200\000\031\000\000\000\002\003\004\005\006\007\010\t\n\013\014\r\016\017\020\021\022\023\024\025\026\027\030\031\032\r\000\016\000\022\000\026\000\027\000\030\000\031\000\032\000\033\000\034\000\035\000\036\000\037\000\022\001\022\001\022\001\032\001\033\001#\001$\001%\001&\001’\001(\001)\001sq-32935-jsxj\001\010\313\230\000\200Q\001\000\000\000\000\000\000\000\000\000\00010088930,10087612,10087612,10087610,10087610,10066481,10063455,10063455,10063453,10063453,10063444,10063444,10063436,10063436,10063337,10063337,10063335,10063335,10046507,10039314,10039311,10039279,10039278,10039277,10039276,10039275,10031656,\000\000\000\371\024N\253\031\000\000\000\000\000\000L\253\031\000\000\000\000\000\000”

key: “zt\200\000\000\000\000\000\000\377\246_r\200\000\000\001a\377\354\244\337\000\000\000\000\000\372\372\006\313#vG\377\375”, value: “\200\000\031\000\000\000\002\003\004\005\006\007\010\t\n\013\014\r\016\017\020\021\022\023\024\025\026\027\030\031\032\023\000\024\000\030\000\034\000\035\000\036\000\037\000 \000!\000”\000#\000$\000%\000\273\000\273\000\273\000\303\000\304\000\314\000\315\000\316\000\317\000\320\000\321\000\322\000yz-339736-wangxu489\001R\307\230\000\200Q\001\000\000\000\000\000\000\000\000\000\00010056302,10052808,10052661,10052659,10052657,10052655,10052653,10052640,10052570,10046558,10045552,10044455,10044453,10044449,10044446,10039913,45378,\000\000\000\003\025N\253\031\000\000\000\000\000\000L\253\031\000\000\000\000\000\000"

key: “zt\200\000\000\000\000\000\000\377\246_r\200\000\000\001a\377\354\326\247\000\000\000\000\000\372\372\006\313#kS\377\375”, value: “\200\000\031\000\000\000\002\003\004\005\006\007\010\t\n\013\014\r\016\017\020\021\022\023\024\025\026\027\030\031\032\n\000\022\000\026\000\032\000\034\000\036\000\037\000 \000!\000”\000#\000%\000&\000\306\000\306\000\306\000\316\000\317\000\327\000\330\000\340\000\350\000\352\000\353\000\354\000kunchi0547\314\027\000\000\001\000\000\000l\350\001\000\017\323\000\000q~I~\000\000\000)\000q~)103151736,102965533,102095063,101501247,101476926,101352509,101352354,101352347,101278483,101056191,101056190,101056188,100553517,100337934,100337933,100331664,\000\000\000\031\025N\253\031\000\000\000\000\000\000L\253\031\002\000\000\000\336rL\253\031\000\000\000{\016M\253\031I~)\000"

How are these value produced? Using TiKV TxnKV / RawKV API or using TiDB?

If they are produced with TiDB, without schema info from TiDB, it is impossible to decode data.

using TiDB

Query the table id to which the Region belongs

[root@tikv3 tmp]# /export/tidb-deploy/tikv-20160/bin/mok 7480000000000000FFA65F728000000161FFFDED670000000000FA
“7480000000000000FFA65F728000000161FFFDED670000000000FA”
└─## decode hex key
└─"t\200\000\000\000\000\000\000\377\246_r\200\000\000\001a\377\375\355g\000\000\000\000\000\372"
├─## decode mvcc key
│ └─"t\200\000\000\000\000\000\000\246_r\200\000\000\001a\375\355g"
│ ├─## table prefix
│ │ └─table: 166
│ └─## table row key
│ ├─table: 166
│ └─row: 5938998631
└─## table prefix
└─table: 255

Query table schema information

curl “http://xxx.xxx.xxx.xxx:10080/schema?table_id=166

[root@tikv3 tikv-20160]# curl “http://xxx.xxx.xxx.xxx:10080/schema?table_id=166
{
“id”: 166,
“name”: {
“O”: “day_workstatus”,
“L”: “day_workstatus”
},
“charset”: “utf8”,
“collate”: “utf8_bin”,
“cols”: [
{
“id”: 1,
“name”: {
“O”: “id”,
“L”: “id”
},
“offset”: 0,
“origin_default”: null,
“origin_default_bit”: null,
“default”: null,
“default_bit”: null,
“default_is_expr”: false,
“generated_expr_string”: “”,
“generated_stored”: false,
“dependences”: null,
“type”: {
“Tp”: 8,
“Flag”: 515,
“Flen”: 20,
“Decimal”: 0,
“Charset”: “binary”,
“Collate”: “binary”,
“Elems”: null
},
“state”: 5,
“comment”: “”,
“hidden”: false,
“change_state_info”: null,
“version”: 2
},

Next I don’t know how to decode value data

Is there any tool or method to decode ?