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

Method readArrayValues

go/fory/slice_primitive_list.go:349–436  ·  view source on GitHub ↗
(buf *ByteBuffer, err *Error, value reflect.Value, length int)

Source from the content-addressed store, hash-verified

347}
348
349func (s primitiveListSerializer) readArrayValues(buf *ByteBuffer, err *Error, value reflect.Value, length int) {
350 switch s.type_.Elem().Kind() {
351 case reflect.Bool:
352 buf.Read(unsafe.Slice((*byte)(value.Addr().UnsafePointer()), length))
353 case reflect.Int8:
354 buf.Read(unsafe.Slice((*byte)(value.Addr().UnsafePointer()), length))
355 case reflect.Uint8:
356 buf.Read(unsafe.Slice((*byte)(value.Addr().UnsafePointer()), length))
357 case reflect.Int16:
358 for i := 0; i < length; i++ {
359 value.Index(i).SetInt(int64(buf.ReadInt16(err)))
360 }
361 case reflect.Uint16:
362 for i := 0; i < length; i++ {
363 value.Index(i).SetUint(uint64(uint16(buf.ReadInt16(err))))
364 }
365 case reflect.Int32:
366 for i := 0; i < length; i++ {
367 if s.elemTypeID == INT32 {
368 value.Index(i).SetInt(int64(buf.ReadInt32(err)))
369 } else {
370 value.Index(i).SetInt(int64(buf.ReadVarint32(err)))
371 }
372 }
373 case reflect.Uint32:
374 for i := 0; i < length; i++ {
375 if s.elemTypeID == UINT32 {
376 value.Index(i).SetUint(uint64(uint32(buf.ReadInt32(err))))
377 } else {
378 value.Index(i).SetUint(uint64(buf.ReadVarUint32(err)))
379 }
380 }
381 case reflect.Int64:
382 for i := 0; i < length; i++ {
383 switch s.elemTypeID {
384 case INT64:
385 value.Index(i).SetInt(buf.ReadInt64(err))
386 case TAGGED_INT64:
387 value.Index(i).SetInt(buf.ReadTaggedInt64(err))
388 default:
389 value.Index(i).SetInt(buf.ReadVarint64(err))
390 }
391 }
392 case reflect.Uint64:
393 for i := 0; i < length; i++ {
394 switch s.elemTypeID {
395 case UINT64:
396 value.Index(i).SetUint(uint64(buf.ReadInt64(err)))
397 case TAGGED_UINT64:
398 value.Index(i).SetUint(buf.ReadTaggedUint64(err))
399 default:
400 value.Index(i).SetUint(buf.ReadVarUint64(err))
401 }
402 }
403 case reflect.Int:
404 for i := 0; i < length; i++ {
405 if s.elemTypeID == INT32 {
406 value.Index(i).SetInt(int64(buf.ReadInt32(err)))

Callers 1

ReadDataMethod · 0.80

Calls 15

KindMethod · 0.80
SliceMethod · 0.80
ReadTaggedUint64Method · 0.80
ReadVarUint64Method · 0.80
ReadMethod · 0.65
int64Function · 0.50
uint64Function · 0.50
uint16Function · 0.50
uint32Function · 0.50
float64Function · 0.50
ReadInt16Method · 0.45
ReadInt32Method · 0.45

Tested by

no test coverage detected