DecodeHandleInIndexValue decodes handle in unqiue index value.
(value []byte)
| 1073 | |
| 1074 | // DecodeHandleInIndexValue decodes handle in unqiue index value. |
| 1075 | func DecodeHandleInIndexValue(value []byte) (handle kv.Handle, err error) { |
| 1076 | if len(value) <= MaxOldEncodeValueLen { |
| 1077 | return DecodeIntHandleInIndexValue(value), nil |
| 1078 | } |
| 1079 | seg := SplitIndexValue(value) |
| 1080 | if len(seg.IntHandle) != 0 { |
| 1081 | handle = DecodeIntHandleInIndexValue(seg.IntHandle) |
| 1082 | } |
| 1083 | if len(seg.CommonHandle) != 0 { |
| 1084 | handle, err = kv.NewCommonHandle(seg.CommonHandle) |
| 1085 | if err != nil { |
| 1086 | return nil, err |
| 1087 | } |
| 1088 | } |
| 1089 | if len(seg.PartitionID) != 0 { |
| 1090 | _, pid, err := codec.DecodeInt(seg.PartitionID) |
| 1091 | if err != nil { |
| 1092 | return nil, err |
| 1093 | } |
| 1094 | handle = kv.NewPartitionHandle(pid, handle) |
| 1095 | } |
| 1096 | return handle, nil |
| 1097 | } |
| 1098 | |
| 1099 | // DecodeIntHandleInIndexValue uses to decode index value as int handle id. |
| 1100 | func DecodeIntHandleInIndexValue(data []byte) kv.Handle { |