MCPcopy Create free account
hub / github.com/apache/fory / ReadInt32Slice

Function ReadInt32Slice

go/fory/slice_primitive.go:837–864  ·  view source on GitHub ↗

ReadInt32Slice reads []int32 from buffer using ARRAY protocol

(buf *ByteBuffer, err *Error)

Source from the content-addressed store, hash-verified

835
836// ReadInt32Slice reads []int32 from buffer using ARRAY protocol
837func ReadInt32Slice(buf *ByteBuffer, err *Error) []int32 {
838 byteSize := buf.ReadLength(err)
839 if err.HasError() {
840 return nil
841 }
842 if byteSize%4 != 0 {
843 *err = DeserializationErrorf("array byte size %d is not aligned to element size %d", byteSize, 4)
844 return nil
845 }
846 if byteSize == 0 {
847 return make([]int32, 0)
848 }
849 if !buf.CheckReadable(byteSize, err) {
850 return nil
851 }
852 length := byteSize / 4
853 if isLittleEndian {
854 result := make([]int32, length)
855 buf.Read(unsafe.Slice((*byte)(unsafe.Pointer(&result[0])), byteSize))
856 return result
857 } else {
858 result := make([]int32, length)
859 for i := 0; i < length; i++ {
860 result[i] = buf.ReadInt32(err)
861 }
862 return result
863 }
864}
865
866// WriteInt64Slice writes []int64 to buffer using ARRAY protocol
867func WriteInt64Slice(buf *ByteBuffer, value []int64) {

Callers 3

ReadDataMethod · 0.85
ReadInt32SliceMethod · 0.85

Calls 7

DeserializationErrorfFunction · 0.85
ReadLengthMethod · 0.80
CheckReadableMethod · 0.80
SliceMethod · 0.80
ReadMethod · 0.65
HasErrorMethod · 0.45
ReadInt32Method · 0.45

Tested by 1