mergeExemplarSets merges and dedupes two sets of already sorted exemplar pairs. Both a and b should be lists of exemplars from the same series. Defined here instead of pkg/util to avoid a import cycle.
(a, b []cortexpb.Exemplar)
| 137 | // Both a and b should be lists of exemplars from the same series. |
| 138 | // Defined here instead of pkg/util to avoid a import cycle. |
| 139 | func mergeExemplarSets(a, b []cortexpb.Exemplar) []cortexpb.Exemplar { |
| 140 | result := make([]cortexpb.Exemplar, 0, len(a)+len(b)) |
| 141 | i, j := 0, 0 |
| 142 | for i < len(a) && j < len(b) { |
| 143 | if a[i].TimestampMs < b[j].TimestampMs { |
| 144 | result = append(result, a[i]) |
| 145 | i++ |
| 146 | } else if a[i].TimestampMs > b[j].TimestampMs { |
| 147 | result = append(result, b[j]) |
| 148 | j++ |
| 149 | } else { |
| 150 | result = append(result, a[i]) |
| 151 | i++ |
| 152 | j++ |
| 153 | } |
| 154 | } |
| 155 | // Add the rest of a or b. One of them is empty now. |
| 156 | result = append(result, a[i:]...) |
| 157 | result = append(result, b[j:]...) |
| 158 | return result |
| 159 | } |
| 160 | |
| 161 | // queryIngestersExemplars queries the ingesters for exemplars. |
| 162 | func (d *Distributor) queryIngestersExemplars(ctx context.Context, replicationSet ring.ReplicationSet, req *ingester_client.ExemplarQueryRequest) (*ingester_client.ExemplarQueryResponse, error) { |
no outgoing calls
no test coverage detected