MCPcopy Create free account
hub / github.com/cockroachdb/cockroachdb-parser / initArrayElementConcatenation

Function initArrayElementConcatenation

pkg/sql/sem/tree/eval.go:313–332  ·  view source on GitHub ↗

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).

()

Source from the content-addressed store, hash-verified

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).
313func 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.
335func ConcatArrays(typ *types.T, left Datum, right Datum) (Datum, error) {

Callers 1

initFunction · 0.85

Calls 2

MakeArrayFunction · 0.92
addBinOpFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…