MCPcopy
hub / github.com/pingcap/tidb / appendBinaryArray

Function appendBinaryArray

pkg/types/json_binary.go:816–832  ·  view source on GitHub ↗
(buf []byte, array []any)

Source from the content-addressed store, hash-verified

814}
815
816func appendBinaryArray(buf []byte, array []any) ([]byte, error) {
817 docOff := len(buf)
818 buf = appendUint32(buf, uint32(len(array)))
819 buf = appendZero(buf, dataSizeOff)
820 valEntryBegin := len(buf)
821 buf = appendZero(buf, len(array)*valEntrySize)
822 for i, val := range array {
823 var err error
824 buf, err = appendBinaryValElem(buf, docOff, valEntryBegin+i*valEntrySize, val)
825 if err != nil {
826 return nil, errors.Trace(err)
827 }
828 }
829 docSize := len(buf) - docOff
830 jsonEndian.PutUint32(buf[docOff+dataSizeOff:], uint32(docSize))
831 return buf, nil
832}
833
834func appendBinaryValElem(buf []byte, docOff, valEntryOff int, val any) ([]byte, error) {
835 var typeCode JSONTypeCode

Callers 1

appendBinaryJSONFunction · 0.85

Calls 3

appendUint32Function · 0.85
appendZeroFunction · 0.85
appendBinaryValElemFunction · 0.85

Tested by

no test coverage detected