sliceSamples assumes given samples are sorted by timestamp in ascending order and return a sub slice whose first element's is the smallest timestamp that is strictly bigger than the given minTs. Empty slice is returned if minTs is bigger than all the timestamps in samples. If the given samples slice
(samples []cortexpb.Sample, minTs int64)
| 387 | // timestamps in samples. |
| 388 | // If the given samples slice is not sorted then unexpected samples would be returned. |
| 389 | func sliceSamples(samples []cortexpb.Sample, minTs int64) []cortexpb.Sample { |
| 390 | if len(samples) == 0 || minTs < samples[0].TimestampMs { |
| 391 | return samples |
| 392 | } |
| 393 | |
| 394 | if len(samples) > 0 && minTs > samples[len(samples)-1].TimestampMs { |
| 395 | return samples[len(samples):] |
| 396 | } |
| 397 | |
| 398 | searchResult := sort.Search(len(samples), func(i int) bool { |
| 399 | return samples[i].TimestampMs > minTs |
| 400 | }) |
| 401 | |
| 402 | return samples[searchResult:] |
| 403 | } |
| 404 | |
| 405 | // sliceHistograms assumes given histogram are sorted by timestamp in ascending order and |
| 406 | // return a sub slice whose first element's is the smallest timestamp that is strictly |
no outgoing calls