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

Method ReadData

go/fory/slice_primitive.go:1501–1534  ·  view source on GitHub ↗
(ctx *ReadContext, value reflect.Value)

Source from the content-addressed store, hash-verified

1499}
1500
1501func (s bfloat16SliceSerializer) ReadData(ctx *ReadContext, value reflect.Value) {
1502 buf := ctx.Buffer()
1503 ctxErr := ctx.Err()
1504 size := ctx.ReadBinaryLength()
1505 if ctx.HasError() {
1506 return
1507 }
1508 if size%2 != 0 {
1509 ctx.SetError(DeserializationErrorf("bfloat16 array byte length %d is not aligned to element size 2", size))
1510 return
1511 }
1512 length := size / 2
1513
1514 ptr := (*[]bfloat16.BFloat16)(value.Addr().UnsafePointer())
1515 if length == 0 {
1516 *ptr = make([]bfloat16.BFloat16, 0)
1517 return
1518 }
1519
1520 if !buf.CheckReadable(size, ctxErr) {
1521 return
1522 }
1523 result := make([]bfloat16.BFloat16, length)
1524
1525 if isLittleEndian {
1526 targetPtr := unsafe.Pointer(&result[0])
1527 buf.Read(unsafe.Slice((*byte)(targetPtr), size))
1528 } else {
1529 for i := 0; i < length; i++ {
1530 result[i] = bfloat16.BFloat16FromBits(buf.ReadUint16(ctxErr))
1531 }
1532 }
1533 *ptr = result
1534}

Callers 1

ReadMethod · 0.95

Calls 10

DeserializationErrorfFunction · 0.85
ReadBinaryLengthMethod · 0.80
CheckReadableMethod · 0.80
SliceMethod · 0.80
ReadUint16Method · 0.80
ReadMethod · 0.65
BufferMethod · 0.45
ErrMethod · 0.45
HasErrorMethod · 0.45
SetErrorMethod · 0.45

Tested by

no test coverage detected