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

Method ReadData

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

Source from the content-addressed store, hash-verified

645}
646
647func (s stringSliceSerializer) ReadData(ctx *ReadContext, value reflect.Value) {
648 buf := ctx.Buffer()
649 ctxErr := ctx.Err()
650 length := ctx.ReadCollectionLength()
651 if ctx.HasError() {
652 return
653 }
654 ptr := (*[]string)(value.Addr().UnsafePointer())
655 if length == 0 {
656 *ptr = make([]string, 0)
657 return
658 }
659
660 // Read collection flags
661 collectFlag := buf.ReadInt8(ctxErr)
662 if ctx.HasError() {
663 return
664 }
665
666 // Read element type info if present (when CollectionIsSameType but not CollectionIsDeclElementType)
667 if (collectFlag&CollectionIsSameType) != 0 && (collectFlag&CollectionIsDeclElementType) == 0 {
668 _ = buf.ReadUint8(ctxErr) // Read and discard type ID (we know it's STRING)
669 }
670 if ctx.HasError() {
671 return
672 }
673 if !buf.CheckReadable(length, ctxErr) {
674 return
675 }
676
677 result := make([]string, length)
678
679 // Check if remote sent with ref tracking (handle both cases for compatibility)
680 trackRefs := (collectFlag & CollectionTrackingRef) != 0
681
682 // Read elements
683 for i := 0; i < length; i++ {
684 if trackRefs {
685 refFlag := buf.ReadInt8(ctxErr)
686 if refFlag == NullFlag {
687 continue // null string, leave as zero value
688 }
689 }
690 result[i] = readString(buf, ctxErr)
691 }
692 *ptr = result
693}
694
695func stringSliceValue(value reflect.Value) []string {
696 if value.CanAddr() {

Callers 1

ReadMethod · 0.95

Calls 8

readStringFunction · 0.85
ReadCollectionLengthMethod · 0.80
ReadUint8Method · 0.80
CheckReadableMethod · 0.80
BufferMethod · 0.45
ErrMethod · 0.45
HasErrorMethod · 0.45
ReadInt8Method · 0.45

Tested by

no test coverage detected