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

Method Call

runtime/vam/expr/function/math.go:147–173  ·  view source on GitHub ↗
(args ...vector.Any)

Source from the content-addressed store, hash-verified

145}
146
147func (l *Log) Call(args ...vector.Any) vector.Any {
148 if vec, ok := expr.CheckForNullThenError(args); ok {
149 return vec
150 }
151 arg := vector.Under(args[0])
152 if !super.IsNumber(arg.Type().ID()) {
153 return vector.NewWrappedError(l.sctx, "log: not a number", arg)
154 }
155 // No error casting number to float so no need to Apply.
156 vec := cast.To(l.sctx, arg, super.TypeFloat64)
157 var errs []uint32
158 var floats []float64
159 for i := range vec.Len() {
160 v := vector.FloatValue(vec, i)
161 if v <= 0 {
162 errs = append(errs, i)
163 continue
164 }
165 floats = append(floats, math.Log(v))
166 }
167 out := vector.NewFloat(super.TypeFloat64, floats)
168 if len(errs) > 0 {
169 err := vector.NewWrappedError(l.sctx, "log: illegal argument", vector.Pick(arg, errs))
170 return vector.Combine(out, errs, err)
171 }
172 return out
173}
174
175type Pow struct {
176 sctx *super.Context

Callers

nothing calls this directly

Calls 12

CheckForNullThenErrorFunction · 0.92
UnderFunction · 0.92
IsNumberFunction · 0.92
NewWrappedErrorFunction · 0.92
ToFunction · 0.92
FloatValueFunction · 0.92
NewFloatFunction · 0.92
PickFunction · 0.92
CombineFunction · 0.92
IDMethod · 0.65
TypeMethod · 0.65
LenMethod · 0.65

Tested by

no test coverage detected