ReadInt32Slice reads []int32 from buffer using ARRAY protocol
(buf *ByteBuffer, err *Error)
| 835 | |
| 836 | // ReadInt32Slice reads []int32 from buffer using ARRAY protocol |
| 837 | func 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 |
| 867 | func WriteInt64Slice(buf *ByteBuffer, value []int64) { |