(vec, fromVec, toVec vector.Any, base1 bool)
| 66 | } |
| 67 | |
| 68 | func (s *sliceExpr) evalArrayOrSlice(vec, fromVec, toVec vector.Any, base1 bool) vector.Any { |
| 69 | from, constFrom := sliceIsConstIndex(fromVec) |
| 70 | to, constTo := sliceIsConstIndex(toVec) |
| 71 | slowPath := !constFrom || !constTo |
| 72 | var index []uint32 |
| 73 | n := vec.Len() |
| 74 | if view, ok := vec.(*vector.View); ok { |
| 75 | vec, index = view.Any, view.Index |
| 76 | } |
| 77 | offsets, inner := arrayOrSetContents(vec) |
| 78 | newOffsets := []uint32{0} |
| 79 | var innerIndex []uint32 |
| 80 | for i := range n { |
| 81 | idx := i |
| 82 | if index != nil { |
| 83 | idx = index[i] |
| 84 | } |
| 85 | off := offsets[idx] |
| 86 | size := int(offsets[idx+1] - off) |
| 87 | start, end := 0, size |
| 88 | if fromVec != nil { |
| 89 | if slowPath { |
| 90 | from = int(vector.IntValue(fromVec, i)) |
| 91 | } |
| 92 | start = sliceIndex(from, size, base1) |
| 93 | } |
| 94 | if toVec != nil { |
| 95 | if slowPath { |
| 96 | to = int(vector.IntValue(toVec, i)) |
| 97 | } |
| 98 | end = sliceIndex(to, size, base1) |
| 99 | } |
| 100 | start, end = expr.FixSliceBounds(start, end, size) |
| 101 | newOffsets = append(newOffsets, newOffsets[len(newOffsets)-1]+uint32(end-start)) |
| 102 | for k := start; k < end; k++ { |
| 103 | innerIndex = append(innerIndex, off+uint32(k)) |
| 104 | } |
| 105 | } |
| 106 | inner = vector.Pick(inner, innerIndex) |
| 107 | if vec.Kind() == vector.KindArray { |
| 108 | return vector.NewArray(vec.Type().(*super.TypeArray), newOffsets, inner) |
| 109 | } |
| 110 | return vector.NewSet(vec.Type().(*super.TypeSet), newOffsets, inner) |
| 111 | } |
| 112 | |
| 113 | func (s *sliceExpr) evalStringOrBytes(vec, fromVec, toVec vector.Any, base1 bool) vector.Any { |
| 114 | constFrom, isConstFrom := sliceIsConstIndex(fromVec) |
no test coverage detected