MCPcopy Create free account
hub / github.com/brimdata/super / newArray

Function newArray

runtime/sam/expr/agg/collect.go:39–63  ·  view source on GitHub ↗

newArray returns an array of vals. If vals is empty, newArray returns super.Null.

(sctx *super.Context, vals []super.Value)

Source from the content-addressed store, hash-verified

37// newArray returns an array of vals. If vals is empty, newArray returns
38// super.Null.
39func newArray(sctx *super.Context, vals []super.Value) super.Value {
40 if len(vals) == 0 {
41 return super.Null
42 }
43 var types []super.Type
44 for _, val := range vals {
45 types = append(types, val.Type())
46 }
47 types = super.UniqueTypes(types)
48 var b scode.Builder
49 var typ super.Type
50 if len(types) == 1 {
51 for _, val := range vals {
52 b.Append(val.Bytes())
53 }
54 typ = types[0]
55 } else {
56 union := sctx.LookupTypeUnion(types)
57 for _, val := range vals {
58 super.BuildUnion(&b, union.TagOf(val.Type()), val.Bytes())
59 }
60 typ = union
61 }
62 return super.NewValue(sctx.LookupTypeArray(typ), b.Bytes())
63}
64
65func (c *Collect) ConsumeAsPartial(val super.Value) {
66 if val.IsNull() {

Callers 2

DistinctResultAsPartialFunction · 0.70
ResultMethod · 0.70

Calls 10

AppendMethod · 0.95
BytesMethod · 0.95
UniqueTypesFunction · 0.92
BuildUnionFunction · 0.92
NewValueFunction · 0.92
LookupTypeUnionMethod · 0.80
TagOfMethod · 0.80
LookupTypeArrayMethod · 0.80
TypeMethod · 0.65
BytesMethod · 0.45

Tested by

no test coverage detected