MCPcopy
hub / github.com/uber/aresdb / UpperBound

Method UpperBound

memstore/vectors/vector.go:237–255  ·  view source on GitHub ↗

UpperBound returns the index of the first element in vector[first, last) that is greater than the given value. The result is only valid if vector[first, last) is fully sorted in ascendant order. If all values in the given range is less than the given value, LowerBound returns last. Note that first/l

(first int, last int, value unsafe.Pointer)

Source from the content-addressed store, hash-verified

235// order. If all values in the given range is less than the given value, LowerBound returns last.
236// Note that first/last is not checked against vector bound.
237func (v *Vector) UpperBound(first int, last int, value unsafe.Pointer) int {
238 for first < last {
239 mid := (last + first) / 2
240
241 cmpRes := 0
242 if v.DataType == common.Bool {
243 cmpRes = common.CompareBool(v.GetBool(mid), *(*uint32)(value) != 0)
244 } else {
245 cmpRes = v.CmpFunc(v.GetValue(mid), value)
246 }
247
248 if cmpRes > 0 {
249 last = mid
250 } else {
251 first = mid + 1
252 }
253 }
254 return first
255}
256
257// GetSliceBytesAligned calculate the number of bytes of a slice of the vector,
258// represented by [lowerBound, upperBound),

Callers 5

GetDataValueByRowMethod · 0.80
SliceMethod · 0.80
SliceByValueMethod · 0.80
SliceIndexMethod · 0.80
vector_test.goFile · 0.80

Calls 3

GetBoolMethod · 0.95
GetValueMethod · 0.95
CompareBoolFunction · 0.92

Tested by

no test coverage detected