Skip to content

Commit

Permalink
check set key exist
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Ye <[email protected]>
  • Loading branch information
yeya24 committed Oct 5, 2020
1 parent 86d1478 commit a8dc6f6
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions pkg/queryfrontend/metadata_codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,20 @@ import (
"bytes"
"context"
"encoding/json"
"io/ioutil"
"net/http"
"net/url"
"sort"
"strconv"
"strings"

"github.com/cortexproject/cortex/pkg/querier/queryrange"
cortexutil "github.com/cortexproject/cortex/pkg/util"
"github.com/cortexproject/cortex/pkg/util/spanlogger"
"github.com/opentracing/opentracing-go"
otlog "github.com/opentracing/opentracing-go/log"
"github.com/weaveworks/common/httpgrpc"

queryv1 "github.com/thanos-io/thanos/pkg/api/query"
"github.com/weaveworks/common/httpgrpc"
"io/ioutil"
"net/http"
"net/url"
"sort"
"strconv"
"strings"
"time"
)

type metadataCodec struct {
Expand Down Expand Up @@ -47,7 +46,9 @@ func (c metadataCodec) MergeResponse(responses ...queryrange.Response) (queryran

for _, res := range responses {
for _, value := range res.(*ThanosLabelsResponse).Data {
set[value] = struct{}{}
if _, ok := set[value]; !ok {
set[value] = struct{}{}
}
}
}
labels := make([]string, 0, len(set))
Expand All @@ -69,6 +70,7 @@ func (c metadataCodec) MergeResponse(responses ...queryrange.Response) (queryran

return &ThanosSeriesResponse{
Status: queryrange.StatusSuccess,
// TODO: fix this
Data: metadataResponses[0].Data,
}, nil
default:
Expand Down Expand Up @@ -261,6 +263,7 @@ func (c metadataCodec) parseLabelsRequest(r *http.Request, op string) (queryrang
break
}
}
time.Now().UnixNano()

return &result, nil
}
Expand Down

0 comments on commit a8dc6f6

Please sign in to comment.