github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/ext/dsort/shard/shard_gen.go (about)

     1  // msgp -file <path to dsort/shard/shard.go> -tests=false -marshal=false -unexported
     2  // Code generated by the command above; see docs/msgp.md. DO NOT EDIT.
     3  package shard
     4  
     5  // Code generated by github.com/tinylib/msgp DO NOT EDIT.
     6  
     7  import (
     8  	"github.com/tinylib/msgp/msgp"
     9  )
    10  
    11  // DecodeMsg implements msgp.Decodable
    12  func (z *Shard) DecodeMsg(dc *msgp.Reader) (err error) {
    13  	var field []byte
    14  	_ = field
    15  	var zb0001 uint32
    16  	zb0001, err = dc.ReadMapHeader()
    17  	if err != nil {
    18  		err = msgp.WrapError(err)
    19  		return
    20  	}
    21  	for zb0001 > 0 {
    22  		zb0001--
    23  		field, err = dc.ReadMapKeyPtr()
    24  		if err != nil {
    25  			err = msgp.WrapError(err)
    26  			return
    27  		}
    28  		switch msgp.UnsafeString(field) {
    29  		case "s":
    30  			z.Size, err = dc.ReadInt64()
    31  			if err != nil {
    32  				err = msgp.WrapError(err, "Size")
    33  				return
    34  			}
    35  		case "r":
    36  			if dc.IsNil() {
    37  				err = dc.ReadNil()
    38  				if err != nil {
    39  					err = msgp.WrapError(err, "Records")
    40  					return
    41  				}
    42  				z.Records = nil
    43  			} else {
    44  				if z.Records == nil {
    45  					z.Records = new(Records)
    46  				}
    47  				err = z.Records.DecodeMsg(dc)
    48  				if err != nil {
    49  					err = msgp.WrapError(err, "Records")
    50  					return
    51  				}
    52  			}
    53  		case "n":
    54  			z.Name, err = dc.ReadString()
    55  			if err != nil {
    56  				err = msgp.WrapError(err, "Name")
    57  				return
    58  			}
    59  		default:
    60  			err = dc.Skip()
    61  			if err != nil {
    62  				err = msgp.WrapError(err)
    63  				return
    64  			}
    65  		}
    66  	}
    67  	return
    68  }
    69  
    70  // EncodeMsg implements msgp.Encodable
    71  func (z *Shard) EncodeMsg(en *msgp.Writer) (err error) {
    72  	// map header, size 3
    73  	// write "s"
    74  	err = en.Append(0x83, 0xa1, 0x73)
    75  	if err != nil {
    76  		return
    77  	}
    78  	err = en.WriteInt64(z.Size)
    79  	if err != nil {
    80  		err = msgp.WrapError(err, "Size")
    81  		return
    82  	}
    83  	// write "r"
    84  	err = en.Append(0xa1, 0x72)
    85  	if err != nil {
    86  		return
    87  	}
    88  	if z.Records == nil {
    89  		err = en.WriteNil()
    90  		if err != nil {
    91  			return
    92  		}
    93  	} else {
    94  		err = z.Records.EncodeMsg(en)
    95  		if err != nil {
    96  			err = msgp.WrapError(err, "Records")
    97  			return
    98  		}
    99  	}
   100  	// write "n"
   101  	err = en.Append(0xa1, 0x6e)
   102  	if err != nil {
   103  		return
   104  	}
   105  	err = en.WriteString(z.Name)
   106  	if err != nil {
   107  		err = msgp.WrapError(err, "Name")
   108  		return
   109  	}
   110  	return
   111  }
   112  
   113  // Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
   114  func (z *Shard) Msgsize() (s int) {
   115  	s = 1 + 2 + msgp.Int64Size + 2
   116  	if z.Records == nil {
   117  		s += msgp.NilSize
   118  	} else {
   119  		s += z.Records.Msgsize()
   120  	}
   121  	s += 2 + msgp.StringPrefixSize + len(z.Name)
   122  	return
   123  }