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

Method WriteData

go/fory/slice_primitive.go:1458–1475  ·  view source on GitHub ↗
(ctx *WriteContext, value reflect.Value)

Source from the content-addressed store, hash-verified

1456type bfloat16SliceSerializer struct{}
1457
1458func (s bfloat16SliceSerializer) WriteData(ctx *WriteContext, value reflect.Value) {
1459 // Cast to []bfloat16.BFloat16
1460 v := value.Interface().([]bfloat16.BFloat16)
1461 buf := ctx.Buffer()
1462 length := len(v)
1463 size := length * 2
1464 buf.WriteLength(size)
1465 if length > 0 {
1466 ptr := unsafe.Pointer(&v[0])
1467 if isLittleEndian {
1468 buf.WriteBinary(unsafe.Slice((*byte)(ptr), size))
1469 } else {
1470 for i := 0; i < length; i++ {
1471 buf.WriteUint16(v[i].Bits())
1472 }
1473 }
1474 }
1475}
1476
1477func (s bfloat16SliceSerializer) Write(ctx *WriteContext, refMode RefMode, writeType bool, hasGenerics bool, value reflect.Value) {
1478 done := writeSliceRefAndType(ctx, refMode, writeType, value, BFLOAT16_ARRAY)

Callers 1

WriteMethod · 0.95

Calls 6

SliceMethod · 0.80
WriteUint16Method · 0.80
BufferMethod · 0.45
WriteLengthMethod · 0.45
WriteBinaryMethod · 0.45
BitsMethod · 0.45

Tested by

no test coverage detected