MCPcopy Create free account
hub / github.com/pingcap/tidb / DecodeToDatumMap

Method DecodeToDatumMap

pkg/util/rowcodec/decoder.go:71–100  ·  view source on GitHub ↗

DecodeToDatumMap decodes byte slices to datum map.

(rowData []byte, row map[int64]types.Datum)

Source from the content-addressed store, hash-verified

69
70// DecodeToDatumMap decodes byte slices to datum map.
71func (decoder *DatumMapDecoder) DecodeToDatumMap(rowData []byte, row map[int64]types.Datum) (map[int64]types.Datum, error) {
72 if row == nil {
73 row = make(map[int64]types.Datum, len(decoder.columns))
74 }
75 err := decoder.fromBytes(rowData)
76 if err != nil {
77 return nil, err
78 }
79 for i := range decoder.columns {
80 col := &decoder.columns[i]
81 idx, isNil, notFound := decoder.row.findColID(col.ID)
82 if !notFound && !isNil {
83 colData := decoder.getData(idx)
84 d, err := decoder.decodeColDatum(col, colData)
85 if err != nil {
86 return nil, err
87 }
88 row[col.ID] = d
89 continue
90 }
91
92 if isNil {
93 var d types.Datum
94 d.SetNull()
95 row[col.ID] = d
96 continue
97 }
98 }
99 return row, nil
100}
101
102func (decoder *DatumMapDecoder) decodeColDatum(col *ColInfo, colData []byte) (types.Datum, error) {
103 var d types.Datum

Callers 7

DecodeRowWithMapNewFunction · 0.95
TestDecodeRowWithHandleFunction · 0.95
TestTypesNewRowCodecFunction · 0.95
TestNilAndDefaultFunction · 0.95
Test65535BugFunction · 0.95

Calls 5

decodeColDatumMethod · 0.95
SetNullMethod · 0.95
fromBytesMethod · 0.80
findColIDMethod · 0.80
getDataMethod · 0.80

Tested by 6

TestDecodeRowWithHandleFunction · 0.76
TestTypesNewRowCodecFunction · 0.76
TestNilAndDefaultFunction · 0.76
Test65535BugFunction · 0.76