TODO(justin): these might be improved by making arrays into an interface and then introducing a ConcatenatedArray implementation which just references two existing arrays. This would optimize the common case of appending an element (or array) to an array from O(n) to O(1).
()
| 311 | // existing arrays. This would optimize the common case of appending an element |
| 312 | // (or array) to an array from O(n) to O(1). |
| 313 | func initArrayElementConcatenation() { |
| 314 | for _, t := range types.Scalar { |
| 315 | typ := t |
| 316 | addBinOp(treebin.Concat, &BinOp{ |
| 317 | LeftType: types.MakeArray(typ), |
| 318 | RightType: typ, |
| 319 | ReturnType: types.MakeArray(typ), |
| 320 | CalledOnNullInput: true, |
| 321 | EvalOp: &AppendToMaybeNullArrayOp{Typ: typ}, |
| 322 | Volatility: volatility.Immutable, |
| 323 | }, &BinOp{ |
| 324 | LeftType: typ, |
| 325 | RightType: types.MakeArray(typ), |
| 326 | ReturnType: types.MakeArray(typ), |
| 327 | CalledOnNullInput: true, |
| 328 | EvalOp: &PrependToMaybeNullArrayOp{Typ: typ}, |
| 329 | Volatility: volatility.Immutable, |
| 330 | }) |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | // ConcatArrays concatenates two arrays. |
| 335 | func ConcatArrays(typ *types.T, left Datum, right Datum) (Datum, error) { |