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

Function ReadFloat64Slice

go/fory/slice_primitive.go:1107–1134  ·  view source on GitHub ↗

ReadFloat64Slice reads []float64 from buffer using ARRAY protocol

(buf *ByteBuffer, err *Error)

Source from the content-addressed store, hash-verified

1105
1106// ReadFloat64Slice reads []float64 from buffer using ARRAY protocol
1107func ReadFloat64Slice(buf *ByteBuffer, err *Error) []float64 {
1108 byteSize := buf.ReadLength(err)
1109 if err.HasError() {
1110 return nil
1111 }
1112 if byteSize%8 != 0 {
1113 *err = DeserializationErrorf("array byte size %d is not aligned to element size %d", byteSize, 8)
1114 return nil
1115 }
1116 if byteSize == 0 {
1117 return make([]float64, 0)
1118 }
1119 if !buf.CheckReadable(byteSize, err) {
1120 return nil
1121 }
1122 length := byteSize / 8
1123 if isLittleEndian {
1124 result := make([]float64, length)
1125 buf.Read(unsafe.Slice((*byte)(unsafe.Pointer(&result[0])), byteSize))
1126 return result
1127 } else {
1128 result := make([]float64, length)
1129 for i := 0; i < length; i++ {
1130 result[i] = buf.ReadFloat64(err)
1131 }
1132 return result
1133 }
1134}
1135
1136// ============================================================================
1137// float16SliceSerializer - optimized []float16.Float16 serialization

Callers 3

ReadDataMethod · 0.85
ReadFloat64SliceMethod · 0.85

Calls 7

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

Tested by 1