(vecs ...vector.Any)
| 20 | } |
| 21 | |
| 22 | func (m *mapCall) eval(vecs ...vector.Any) vector.Any { |
| 23 | if vec, ok := CheckForNullThenError(vecs); ok { |
| 24 | return vec |
| 25 | } |
| 26 | vec := vector.Under(vecs[0]) |
| 27 | var index []uint32 |
| 28 | if view, ok := vec.(*vector.View); ok { |
| 29 | index = view.Index |
| 30 | vec = view.Any |
| 31 | } |
| 32 | inner, offsets, ok := elements(vec) |
| 33 | if !ok { |
| 34 | return vector.NewWrappedError(m.sctx, "map: expected array or set value", vecs[0]) |
| 35 | } |
| 36 | inner = m.lambda.Eval(inner) |
| 37 | if d, ok := inner.(*vector.Dynamic); ok { |
| 38 | var typs []super.Type |
| 39 | for _, vec := range d.Values { |
| 40 | typs = append(typs, vec.Type()) |
| 41 | } |
| 42 | utyp := m.sctx.LookupTypeUnion(super.UniqueTypes(typs)) |
| 43 | inner = vector.NewUnion(utyp, d.Tags, d.Values) |
| 44 | } |
| 45 | var out vector.Any |
| 46 | switch vec := vec.(type) { |
| 47 | case *vector.Array: |
| 48 | typ := m.sctx.LookupTypeArray(inner.Type()) |
| 49 | out = vector.NewArray(typ, offsets, inner) |
| 50 | case *vector.Set: |
| 51 | typ := m.sctx.LookupTypeSet(inner.Type()) |
| 52 | out = vector.NewSet(typ, offsets, inner) |
| 53 | default: |
| 54 | panic(vec) |
| 55 | } |
| 56 | if index != nil { |
| 57 | out = vector.Pick(out, index) |
| 58 | } |
| 59 | return out |
| 60 | } |
| 61 | |
| 62 | func elements(vec vector.Any) (vector.Any, []uint32, bool) { |
| 63 | switch vec := vec.(type) { |
nothing calls this directly
no test coverage detected