sliceHistograms assumes given histogram 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 histogram.
(histograms []SampleHistogramPair, minTs int64)
| 407 | // bigger than the given minTs. Empty slice is returned if minTs is bigger than all the |
| 408 | // timestamps in histogram. |
| 409 | func sliceHistograms(histograms []SampleHistogramPair, minTs int64) []SampleHistogramPair { |
| 410 | if len(histograms) <= 0 || minTs < histograms[0].GetTimestampMs() { |
| 411 | return histograms |
| 412 | } |
| 413 | |
| 414 | if len(histograms) > 0 && minTs > histograms[len(histograms)-1].GetTimestampMs() { |
| 415 | return histograms[len(histograms):] |
| 416 | } |
| 417 | |
| 418 | searchResult := sort.Search(len(histograms), func(i int) bool { |
| 419 | return histograms[i].GetTimestampMs() > minTs |
| 420 | }) |
| 421 | |
| 422 | return histograms[searchResult:] |
| 423 | } |