@@ -345,7 +345,7 @@ func (q *blocksStoreQuerier) LabelNames(ctx context.Context, matchers ...*labels
345
345
346
346
var (
347
347
resMtx sync.Mutex
348
- resNameSets = [] []string {}
348
+ resNameSet = []string {}
349
349
resWarnings = annotations .Annotations (nil )
350
350
convertedMatchers = convertMatchersToLabelMatcher (matchers )
351
351
)
@@ -357,7 +357,7 @@ func (q *blocksStoreQuerier) LabelNames(ctx context.Context, matchers ...*labels
357
357
}
358
358
359
359
resMtx .Lock ()
360
- resNameSets = append ( resNameSets , nameSets ... )
360
+ resNameSet = strutil . MergeSlices ( resNameSet , nameSets )
361
361
resWarnings .Merge (warnings )
362
362
resMtx .Unlock ()
363
363
@@ -368,7 +368,7 @@ func (q *blocksStoreQuerier) LabelNames(ctx context.Context, matchers ...*labels
368
368
return nil , nil , err
369
369
}
370
370
371
- return strutil . MergeSlices ( resNameSets ... ) , resWarnings , nil
371
+ return resNameSet , resWarnings , nil
372
372
}
373
373
374
374
func (q * blocksStoreQuerier ) LabelValues (ctx context.Context , name string , matchers ... * labels.Matcher ) ([]string , annotations.Annotations , error ) {
@@ -383,7 +383,7 @@ func (q *blocksStoreQuerier) LabelValues(ctx context.Context, name string, match
383
383
minT , maxT := q .minT , q .maxT
384
384
385
385
var (
386
- resValueSets = [][] string {}
386
+ resValueSets = []string {}
387
387
resWarnings = annotations .Annotations (nil )
388
388
389
389
resultMtx sync.Mutex
@@ -396,7 +396,7 @@ func (q *blocksStoreQuerier) LabelValues(ctx context.Context, name string, match
396
396
}
397
397
398
398
resultMtx .Lock ()
399
- resValueSets = append (resValueSets , valueSets ... )
399
+ resValueSets = strutil . MergeSlices (resValueSets , valueSets )
400
400
resWarnings .Merge (warnings )
401
401
resultMtx .Unlock ()
402
402
@@ -407,7 +407,7 @@ func (q *blocksStoreQuerier) LabelValues(ctx context.Context, name string, match
407
407
return nil , nil , err
408
408
}
409
409
410
- return strutil . MergeSlices ( resValueSets ... ) , resWarnings , nil
410
+ return resValueSets , resWarnings , nil
411
411
}
412
412
413
413
func (q * blocksStoreQuerier ) Close () error {
@@ -819,12 +819,12 @@ func (q *blocksStoreQuerier) fetchLabelNamesFromStore(
819
819
minT int64 ,
820
820
maxT int64 ,
821
821
matchers []storepb.LabelMatcher ,
822
- ) ([][] string , annotations.Annotations , []ulid.ULID , error , error ) {
822
+ ) ([]string , annotations.Annotations , []ulid.ULID , error , error ) {
823
823
var (
824
824
reqCtx = grpc_metadata .AppendToOutgoingContext (ctx , cortex_tsdb .TenantIDExternalLabel , userID )
825
825
g , gCtx = errgroup .WithContext (reqCtx )
826
826
mtx = sync.Mutex {}
827
- nameSets = [] []string {}
827
+ nameSet = []string {}
828
828
warnings = annotations .Annotations (nil )
829
829
queriedBlocks = []ulid.ULID (nil )
830
830
spanLog = spanlogger .FromContext (ctx )
@@ -894,7 +894,7 @@ func (q *blocksStoreQuerier) fetchLabelNamesFromStore(
894
894
895
895
// Store the result.
896
896
mtx .Lock ()
897
- nameSets = append ( nameSets , namesResp .Names )
897
+ nameSet = strutil . MergeSlices ( nameSet , namesResp .Names )
898
898
for _ , w := range namesResp .Warnings {
899
899
warnings .Add (errors .New (w ))
900
900
}
@@ -910,7 +910,7 @@ func (q *blocksStoreQuerier) fetchLabelNamesFromStore(
910
910
return nil , nil , nil , err , merr .Err ()
911
911
}
912
912
913
- return nameSets , warnings , queriedBlocks , nil , merr .Err ()
913
+ return nameSet , warnings , queriedBlocks , nil , merr .Err ()
914
914
}
915
915
916
916
func (q * blocksStoreQuerier ) fetchLabelValuesFromStore (
@@ -921,12 +921,12 @@ func (q *blocksStoreQuerier) fetchLabelValuesFromStore(
921
921
minT int64 ,
922
922
maxT int64 ,
923
923
matchers ... * labels.Matcher ,
924
- ) ([][] string , annotations.Annotations , []ulid.ULID , error , error ) {
924
+ ) ([]string , annotations.Annotations , []ulid.ULID , error , error ) {
925
925
var (
926
926
reqCtx = grpc_metadata .AppendToOutgoingContext (ctx , cortex_tsdb .TenantIDExternalLabel , userID )
927
927
g , gCtx = errgroup .WithContext (reqCtx )
928
928
mtx = sync.Mutex {}
929
- valueSets = [] []string {}
929
+ valueSet = []string {}
930
930
warnings = annotations .Annotations (nil )
931
931
queriedBlocks = []ulid.ULID (nil )
932
932
spanLog = spanlogger .FromContext (ctx )
@@ -995,11 +995,13 @@ func (q *blocksStoreQuerier) fetchLabelValuesFromStore(
995
995
"queried blocks" , strings .Join (convertULIDsToString (myQueriedBlocks ), " " ))
996
996
997
997
// Values returned need not be sorted, but we need them to be sorted so we can merge.
998
- sort .Strings (valuesResp .Values )
998
+ if ! sort .StringsAreSorted (valuesResp .Values ) {
999
+ sort .Strings (valuesResp .Values )
1000
+ }
999
1001
1000
1002
// Store the result.
1001
1003
mtx .Lock ()
1002
- valueSets = append ( valueSets , valuesResp .Values )
1004
+ valueSet = strutil . MergeSlices ( valueSet , valuesResp .Values )
1003
1005
for _ , w := range valuesResp .Warnings {
1004
1006
warnings .Add (errors .New (w ))
1005
1007
}
@@ -1015,7 +1017,7 @@ func (q *blocksStoreQuerier) fetchLabelValuesFromStore(
1015
1017
return nil , nil , nil , err , merr .Err ()
1016
1018
}
1017
1019
1018
- return valueSets , warnings , queriedBlocks , nil , merr .Err ()
1020
+ return valueSet , warnings , queriedBlocks , nil , merr .Err ()
1019
1021
}
1020
1022
1021
1023
func createSeriesRequest (minT , maxT int64 , matchers []storepb.LabelMatcher , shardingInfo * storepb.ShardInfo , skipChunks bool , blockIDs []ulid.ULID ) (* storepb.SeriesRequest , error ) {
0 commit comments