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

Method ReadData

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

Source from the content-addressed store, hash-verified

316}
317
318func (s arrayDynSerializer) ReadData(ctx *ReadContext, value reflect.Value) {
319 // Create a temp slice to read into, then copy back to array
320 sliceType := reflect.SliceOf(value.Type().Elem())
321 tempSlice := reflect.MakeSlice(sliceType, value.Len(), value.Len())
322 s.sliceSerializer.readData(ctx, tempSlice, value.Len())
323 if ctx.HasError() {
324 return
325 }
326 // Copy elements from temp slice to array
327 copyLen := tempSlice.Len()
328 if copyLen > value.Len() {
329 copyLen = value.Len()
330 }
331 for i := 0; i < copyLen; i++ {
332 value.Index(i).Set(tempSlice.Index(i))
333 }
334}
335
336func (s arrayDynSerializer) Read(ctx *ReadContext, refMode RefMode, readType bool, hasGenerics bool, value reflect.Value) {
337 done := readArrayRefAndType(ctx, refMode, readType, value)

Callers 1

ReadMethod · 0.95

Calls 5

LenMethod · 0.80
TypeMethod · 0.45
readDataMethod · 0.45
HasErrorMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected