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

Method decodeToBytesInternal

pkg/util/rowcodec/decoder.go:401–446  ·  view source on GitHub ↗
(outputOffset map[int64]int, handle kv.Handle, value []byte, cacheBytes []byte)

Source from the content-addressed store, hash-verified

399}
400
401func (decoder *BytesDecoder) decodeToBytesInternal(outputOffset map[int64]int, handle kv.Handle, value []byte, cacheBytes []byte) ([][]byte, error) {
402 var r row
403 err := r.fromBytes(value)
404 if err != nil {
405 return nil, err
406 }
407 values := make([][]byte, len(outputOffset))
408 for i := range decoder.columns {
409 col := &decoder.columns[i]
410 tp := fieldType2Flag(col.Ft.ArrayType().GetType(), col.Ft.GetFlag()&mysql.UnsignedFlag == 0)
411 colID := col.ID
412 offset := outputOffset[colID]
413 idx, isNil, notFound := r.findColID(colID)
414 if !notFound && !isNil {
415 val := r.getData(idx)
416 values[offset] = decoder.encodeOldDatum(tp, val)
417 continue
418 }
419
420 // Only try to decode handle when there is no corresponding column in the value.
421 // This is because the information in handle may be incomplete in some cases.
422 // For example, prefixed clustered index like 'primary key(col1(1))' only store the leftmost 1 char in the handle.
423 if decoder.tryDecodeHandle(values, offset, col, handle, cacheBytes) {
424 continue
425 }
426
427 if isNil {
428 values[offset] = []byte{NilFlag}
429 continue
430 }
431
432 if decoder.defBytes != nil {
433 defVal, err := decoder.defBytes(i)
434 if err != nil {
435 return nil, err
436 }
437 if len(defVal) > 0 {
438 values[offset] = defVal
439 continue
440 }
441 }
442
443 values[offset] = []byte{NilFlag}
444 }
445 return values, nil
446}
447
448func (decoder *BytesDecoder) tryDecodeHandle(values [][]byte, offset int, col *ColInfo,
449 handle kv.Handle, cacheBytes []byte) bool {

Callers 2

DecodeToBytesNoHandleMethod · 0.95
DecodeToBytesMethod · 0.95

Calls 9

fromBytesMethod · 0.95
findColIDMethod · 0.95
getDataMethod · 0.95
encodeOldDatumMethod · 0.95
tryDecodeHandleMethod · 0.95
fieldType2FlagFunction · 0.85
ArrayTypeMethod · 0.80
GetTypeMethod · 0.65
GetFlagMethod · 0.65

Tested by

no test coverage detected