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

Method ReadData

go/fory/array.go:373–399  ·  view source on GitHub ↗
(ctx *ReadContext, value reflect.Value)

Source from the content-addressed store, hash-verified

371}
372
373func (s byteArraySerializer) ReadData(ctx *ReadContext, value reflect.Value) {
374 buf := ctx.Buffer()
375 err := ctx.Err()
376 length := buf.ReadLength(err)
377 if ctx.HasError() {
378 return
379 }
380 if length != value.Len() {
381 ctx.SetError(DeserializationErrorf("array length %d does not match serialized binary length %d", value.Len(), length))
382 return
383 }
384 if !buf.CheckReadable(length, err) {
385 return
386 }
387 if length == 0 {
388 return
389 }
390 if value.CanAddr() {
391 buf.Read(value.Slice(0, length).Bytes())
392 return
393 }
394 data := make([]byte, length)
395 buf.Read(data)
396 for i := 0; i < length && i < value.Len(); i++ {
397 value.Index(i).SetUint(uint64(data[i]))
398 }
399}
400
401func (s byteArraySerializer) Read(ctx *ReadContext, refMode RefMode, readType bool, hasGenerics bool, value reflect.Value) {
402 done := readArrayRefAndType(ctx, refMode, readType, value)

Callers 1

ReadMethod · 0.95

Calls 12

DeserializationErrorfFunction · 0.85
ReadLengthMethod · 0.80
LenMethod · 0.80
CheckReadableMethod · 0.80
BytesMethod · 0.80
SliceMethod · 0.80
ReadMethod · 0.65
uint64Function · 0.50
BufferMethod · 0.45
ErrMethod · 0.45
HasErrorMethod · 0.45
SetErrorMethod · 0.45

Tested by

no test coverage detected