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

Function ReadStringSlice

go/fory/slice_primitive.go:1425–1450  ·  view source on GitHub ↗

ReadStringSlice reads []string from buffer using LIST protocol

(buf *ByteBuffer, err *Error)

Source from the content-addressed store, hash-verified

1423
1424// ReadStringSlice reads []string from buffer using LIST protocol
1425func ReadStringSlice(buf *ByteBuffer, err *Error) []string {
1426 length := buf.ReadLength(err)
1427 if length == 0 {
1428 return make([]string, 0)
1429 }
1430 collectFlag := buf.ReadInt8(err)
1431 if (collectFlag&CollectionIsSameType) != 0 && (collectFlag&CollectionIsDeclElementType) == 0 {
1432 _ = buf.ReadUint8(err) // Read and discard element type ID
1433 }
1434 if err.HasError() || !buf.CheckReadable(length, err) {
1435 return nil
1436 }
1437 result := make([]string, length)
1438 trackRefs := (collectFlag & CollectionTrackingRef) != 0
1439 hasNull := (collectFlag & CollectionHasNull) != 0
1440 for i := 0; i < length; i++ {
1441 if trackRefs || hasNull {
1442 rf := buf.ReadInt8(err)
1443 if rf == NullFlag {
1444 continue
1445 }
1446 }
1447 result[i] = readString(buf, err)
1448 }
1449 return result
1450}
1451
1452// ============================================================================
1453// bfloat16SliceSerializer - optimized []bfloat16.BFloat16 serialization

Callers 1

ReadStringSliceMethod · 0.85

Calls 6

readStringFunction · 0.85
ReadLengthMethod · 0.80
ReadUint8Method · 0.80
CheckReadableMethod · 0.80
ReadInt8Method · 0.45
HasErrorMethod · 0.45

Tested by

no test coverage detected