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

Method WriteData

go/fory/array_primitive.go:770–789  ·  view source on GitHub ↗
(ctx *WriteContext, value reflect.Value)

Source from the content-addressed store, hash-verified

768}
769
770func (s float16ArraySerializer) WriteData(ctx *WriteContext, value reflect.Value) {
771 buf := ctx.Buffer()
772 length := value.Len()
773 size := length * 2
774 buf.WriteLength(size)
775 if length > 0 {
776 if value.CanAddr() && isLittleEndian {
777 ptr := value.Addr().UnsafePointer()
778 buf.WriteBinary(unsafe.Slice((*byte)(ptr), size))
779 } else {
780 for i := 0; i < length; i++ {
781 // We can't easily cast the whole array if not addressable/little-endian
782 // So we iterate.
783 // value.Index(i) is Float16, we cast to uint16
784 val := value.Index(i).Interface().(float16.Float16)
785 buf.WriteUint16(val.Bits())
786 }
787 }
788 }
789}
790
791func (s float16ArraySerializer) Write(ctx *WriteContext, refMode RefMode, writeType bool, hasGenerics bool, value reflect.Value) {
792 writeArrayRefAndType(ctx, refMode, writeType, value, FLOAT16_ARRAY)

Callers 1

WriteMethod · 0.95

Calls 7

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

Tested by

no test coverage detected