-
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.
Signed-off-by: Filip Petkovski <[email protected]>
- Loading branch information
1 parent
ec0d2c8
commit 66dd816
Showing
8 changed files
with
73 additions
and
62 deletions.
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
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
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
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
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,52 @@ | ||
package store | ||
|
||
import ( | ||
"github.com/prometheus/prometheus/model/labels" | ||
"golang.org/x/exp/slices" | ||
|
||
"github.com/thanos-io/thanos/pkg/store/labelpb" | ||
"github.com/thanos-io/thanos/pkg/store/storepb" | ||
) | ||
|
||
type resortingServer struct { | ||
storepb.Store_SeriesServer | ||
series []*storepb.Series | ||
} | ||
|
||
func (r *resortingServer) Send(response *storepb.SeriesResponse) error { | ||
if response.GetSeries() == nil { | ||
return r.Store_SeriesServer.Send(response) | ||
} | ||
|
||
series := response.GetSeries() | ||
lblsCopy := make([]labelpb.ZLabel, 0, len(series.Labels)) | ||
for _, l := range series.Labels { | ||
lblsCopy = append(lblsCopy, labelpb.ZLabel{ | ||
Name: copyString(l.Name), | ||
Value: copyString(l.Value), | ||
}) | ||
} | ||
series.Labels = lblsCopy | ||
|
||
r.series = append(r.series, series) | ||
return nil | ||
} | ||
|
||
func copyString(s string) string { | ||
return string([]byte(s)) | ||
} | ||
|
||
func (r *resortingServer) Flush() error { | ||
slices.SortFunc(r.series, func(a, b *storepb.Series) bool { | ||
return labels.Compare( | ||
labelpb.ZLabelsToPromLabels(a.Labels), | ||
labelpb.ZLabelsToPromLabels(b.Labels), | ||
) < 0 | ||
}) | ||
for _, response := range r.series { | ||
if err := r.Store_SeriesServer.Send(storepb.NewSeriesResponse(response)); err != nil { | ||
return err | ||
} | ||
} | ||
return nil | ||
} |
This file was deleted.
Oops, something went wrong.
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
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