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

Method Compare

runtime/sam/expr/sort.go:132–144  ·  view source on GitHub ↗

Compare returns an interger comparing two values according to the receiver's configuration. The result will be 0 if a==b, -1 if a < b, and +1 if a > b.

(a, b super.Value)

Source from the content-addressed store, hash-verified

130// Compare returns an interger comparing two values according to the receiver's
131// configuration. The result will be 0 if a==b, -1 if a < b, and +1 if a > b.
132func (c *Comparator) Compare(a, b super.Value) int {
133 for _, k := range c.exprs {
134 aval := k.Eval(a)
135 bval := k.Eval(b)
136 if k.Order == order.Desc {
137 aval, bval = bval, aval
138 }
139 if v := compareValues(aval, bval, k.nullsMax()); v != 0 {
140 return v
141 }
142 }
143 return 0
144}
145
146func compareValues(a, b super.Value, nullsMax bool) int {
147 a = a.Under()

Callers 7

consumeMethod · 0.95
compareValuesFunction · 0.45
boolean.goFile · 0.45
EvalMethod · 0.45
compareNumbersFunction · 0.45
LessMethod · 0.45
nextResultFromSpillsMethod · 0.45

Calls 3

compareValuesFunction · 0.85
nullsMaxMethod · 0.80
EvalMethod · 0.65

Tested by

no test coverage detected