code: func DecodeOne(b []byte) (remain []byte, d types.Datum, err error) {
  	if len(b) < 1 {
  		return nil, d, errors.New("invalid encoded key")
  	}
  	flag := b[0]
  	b = b[1:]
  	switch flag {
  	case intFlag:
  		var v int64
  		b, v, err = DecodeInt(b)
  		d.SetInt64(v)
  	case uintFlag:
  		var v uint64
  		b, v, err = DecodeUint(b)
  		d.SetUint64(v)
  	case varintFlag:
  		var v int64
  		b, v, err = DecodeVarint(b)
  		d.SetInt64(v)
  	case uvarintFlag:
  		var v uint64
  		b, v, err = DecodeUvarint(b)
  		d.SetUint64(v)
  	case floatFlag:
  		var v float64
  		b, v, err = DecodeFloat(b)
  		d.SetFloat64(v)
  	case bytesFlag:
  		var v []byte
  		b, v, err = DecodeBytes(b)
  		d.SetBytes(v)
  	case compactBytesFlag:
  		var v []byte
  		b, v, err = DecodeCompactBytes(b)
  		d.SetBytes(v)
  	case decimalFlag:
  		b, d, err = DecodeDecimal(b)
  	case durationFlag:
  		var r int64
  		b, r, err = DecodeInt(b)
  		if err == nil {
  			// use max fsp, let outer to do round manually.
  			v := types.Duration{Duration: time.Duration(r), Fsp: types.MaxFsp}
  			d.SetValue(v)
  		}
  	case NilFlag:
  	default:
  		return b, d, errors.Errorf("invalid encoded key flag %v", flag)
  	}
  	if err != nil {
  		return b, d, errors.Trace(err)
  	}
  	return b, d, nil
  }
docs: // DecodeOne decodes on datum from a byte slice generated with EncodeKey or EncodeValue.