(loader *loader)
| 47 | } |
| 48 | |
| 49 | func (p *primitive) loadAnyWithLock(loader *loader) any { |
| 50 | bytes := make([]byte, p.meta.Location.MemLength) |
| 51 | if err := p.meta.Location.Read(loader.r, bytes); err != nil { |
| 52 | panic(err) |
| 53 | } |
| 54 | length := p.length() |
| 55 | it := scode.Iter(bytes) |
| 56 | switch p.meta.Typ.(type) { |
| 57 | case *super.TypeOfUint8, *super.TypeOfUint16, *super.TypeOfUint32, *super.TypeOfUint64, *super.TypeEnum: |
| 58 | values := make([]uint64, 0, length) |
| 59 | for range length { |
| 60 | values = append(values, super.DecodeUint(it.Next())) |
| 61 | } |
| 62 | return values |
| 63 | case *super.TypeOfInt8, *super.TypeOfInt16, *super.TypeOfInt32, *super.TypeOfInt64, *super.TypeOfDuration, *super.TypeOfTime: |
| 64 | values := make([]int64, 0, length) |
| 65 | for range length { |
| 66 | values = append(values, super.DecodeInt(it.Next())) |
| 67 | } |
| 68 | return values |
| 69 | case *super.TypeOfFloat16, *super.TypeOfFloat32, *super.TypeOfFloat64: |
| 70 | values := make([]float64, 0, length) |
| 71 | for range length { |
| 72 | values = append(values, super.DecodeFloat(it.Next())) |
| 73 | } |
| 74 | return values |
| 75 | case *super.TypeOfBool: |
| 76 | bits := bitvec.NewFalse(length) |
| 77 | for slot := range length { |
| 78 | if super.DecodeBool(it.Next()) { |
| 79 | bits.Set(slot) |
| 80 | } |
| 81 | } |
| 82 | return bits |
| 83 | case *super.TypeOfBytes, *super.TypeOfString, *super.TypeOfType: |
| 84 | var bytes []byte |
| 85 | // First offset is always zero. |
| 86 | offs := make([]uint32, 1, length+1) |
| 87 | for range length { |
| 88 | bytes = append(bytes, it.Next()...) |
| 89 | offs = append(offs, uint32(len(bytes))) |
| 90 | } |
| 91 | return vector.NewBytesTable(offs, bytes) |
| 92 | case *super.TypeOfIP: |
| 93 | values := make([]netip.Addr, 0, length) |
| 94 | for range length { |
| 95 | values = append(values, super.DecodeIP(it.Next())) |
| 96 | } |
| 97 | return values |
| 98 | case *super.TypeOfNet: |
| 99 | values := make([]netip.Prefix, 0, length) |
| 100 | for range length { |
| 101 | values = append(values, super.DecodeNet(it.Next())) |
| 102 | } |
| 103 | return values |
| 104 | case *super.TypeOfNull: |
| 105 | return nil |
| 106 | } |
no test coverage detected