mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/storage: fix the search for empty label name (#2991)
* lib/storage: fix the search for empty label name Signed-off-by: hagen1778 <roman@victoriametrics.com> * Apply suggestions from code review Signed-off-by: hagen1778 <roman@victoriametrics.com> Co-authored-by: Aliaksandr Valialkin <valyala@victoriametrics.com>
This commit is contained in:
parent
e3fd90e35e
commit
72342939d6
1 changed files with 5 additions and 2 deletions
|
@ -818,7 +818,7 @@ func (is *indexSearch) searchLabelNamesWithFiltersOnDate(qt *querytracer.Tracer,
|
||||||
if filter != nil && filter.Len() <= 100e3 {
|
if filter != nil && filter.Len() <= 100e3 {
|
||||||
// It is faster to obtain label names by metricIDs from the filter
|
// It is faster to obtain label names by metricIDs from the filter
|
||||||
// instead of scanning the inverted index for the matching filters.
|
// instead of scanning the inverted index for the matching filters.
|
||||||
// This hould help https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2978
|
// This would help https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2978
|
||||||
metricIDs := filter.AppendTo(nil)
|
metricIDs := filter.AppendTo(nil)
|
||||||
qt.Printf("sort %d metricIDs", len(metricIDs))
|
qt.Printf("sort %d metricIDs", len(metricIDs))
|
||||||
return is.getLabelNamesForMetricIDs(qt, metricIDs, lns, maxLabelNames)
|
return is.getLabelNamesForMetricIDs(qt, metricIDs, lns, maxLabelNames)
|
||||||
|
@ -1014,7 +1014,7 @@ func (is *indexSearch) searchLabelValuesWithFiltersOnDate(qt *querytracer.Tracer
|
||||||
if filter != nil && filter.Len() < 100e3 {
|
if filter != nil && filter.Len() < 100e3 {
|
||||||
// It is faster to obtain label values by metricIDs from the filter
|
// It is faster to obtain label values by metricIDs from the filter
|
||||||
// instead of scanning the inverted index for the matching filters.
|
// instead of scanning the inverted index for the matching filters.
|
||||||
// This hould help https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2978
|
// This would help https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2978
|
||||||
metricIDs := filter.AppendTo(nil)
|
metricIDs := filter.AppendTo(nil)
|
||||||
qt.Printf("sort %d metricIDs", len(metricIDs))
|
qt.Printf("sort %d metricIDs", len(metricIDs))
|
||||||
return is.getLabelValuesForMetricIDs(qt, lvs, labelName, metricIDs, maxLabelValues)
|
return is.getLabelValuesForMetricIDs(qt, lvs, labelName, metricIDs, maxLabelValues)
|
||||||
|
@ -1077,6 +1077,9 @@ func (is *indexSearch) searchLabelValuesWithFiltersOnDate(qt *querytracer.Tracer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (is *indexSearch) getLabelValuesForMetricIDs(qt *querytracer.Tracer, lvs map[string]struct{}, labelName string, metricIDs []uint64, maxLabelValues int) error {
|
func (is *indexSearch) getLabelValuesForMetricIDs(qt *querytracer.Tracer, lvs map[string]struct{}, labelName string, metricIDs []uint64, maxLabelValues int) error {
|
||||||
|
if labelName == "" {
|
||||||
|
labelName = "__name__"
|
||||||
|
}
|
||||||
var mn MetricName
|
var mn MetricName
|
||||||
foundLabelValues := 0
|
foundLabelValues := 0
|
||||||
var buf []byte
|
var buf []byte
|
||||||
|
|
Loading…
Reference in a new issue