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

Method Call

runtime/vam/expr/function/nullif.go:17–42  ·  view source on GitHub ↗
(vecs ...vector.Any)

Source from the content-addressed store, hash-verified

15}
16
17func (n *NullIf) Call(vecs ...vector.Any) vector.Any {
18 if k := vecs[0].Kind(); k == vector.KindNull || k == vector.KindError {
19 return vecs[0]
20 }
21 if vecs[1].Kind() == vector.KindError {
22 return vecs[1]
23 }
24 result := n.compare.Compare(vecs[0], vecs[1])
25 if k := result.Kind(); k == vector.KindNull || k == vector.KindError {
26 return vecs[0]
27 }
28 var index []uint32
29 for i := range result.Len() {
30 if vector.BoolValue(result, i) {
31 index = append(index, i)
32 }
33 }
34 if len(index) == 0 {
35 return vecs[0]
36 }
37 nullsVec := vector.NewNull(uint32(len(index)))
38 if len(index) == int(vecs[0].Len()) {
39 return nullsVec
40 }
41 return vector.Combine(vector.ReversePick(vecs[0], index), index, nullsVec)
42}

Callers

nothing calls this directly

Calls 7

BoolValueFunction · 0.92
NewNullFunction · 0.92
CombineFunction · 0.92
ReversePickFunction · 0.92
KindMethod · 0.65
LenMethod · 0.65
CompareMethod · 0.45

Tested by

no test coverage detected