-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
store: don't create intermediate labels (#7762)
Just compare labelpb.Label directly instead of creating promlabels from them. Signed-off-by: Giedrius Statkevičius <[email protected]>
- Loading branch information
Showing
2 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) The Thanos Authors. | ||
// Licensed under the Apache License 2.0. | ||
|
||
package labelpb | ||
|
||
func CompareLabels(a, b []*Label) int { | ||
l := len(a) | ||
if len(b) < l { | ||
l = len(b) | ||
} | ||
|
||
for i := 0; i < l; i++ { | ||
if a[i].Name != b[i].Name { | ||
if a[i].Name < b[i].Name { | ||
return -1 | ||
} | ||
return 1 | ||
} | ||
if a[i].Value != b[i].Value { | ||
if a[i].Value < b[i].Value { | ||
return -1 | ||
} | ||
return 1 | ||
} | ||
} | ||
// If all labels so far were in common, the set with fewer labels comes first. | ||
return len(a) - len(b) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters