lib/storage: add missing tagFilter.Marshal func

This commit is contained in:
Aliaksandr Valialkin 2019-07-11 15:00:50 +03:00
parent 12b1d67b41
commit 0522efb2d6
2 changed files with 8 additions and 2 deletions

View File

@ -1345,7 +1345,7 @@ func (is *indexSearch) getTagFilterWithMinMetricIDsCount(tfs *TagFilters, maxMet
kb.B = append(kb.B[:0], uselessSingleTagFilterKeyPrefix)
kb.B = encoding.MarshalUint64(kb.B[:0], uint64(maxMetrics))
kb.B = tf.Marshal(kb.B)
kb.B = tf.Marshal(kb.B, tfs.accountID, tfs.projectID)
if len(is.db.uselessTagFiltersCache.Get(nil, kb.B)) > 0 {
// Skip useless work below, since the tf matches at least maxMetrics metrics.
uselessTagFilters++
@ -1364,7 +1364,7 @@ func (is *indexSearch) getTagFilterWithMinMetricIDsCount(tfs *TagFilters, maxMet
// The tf matches at least maxMetrics. Skip it
kb.B = append(kb.B[:0], uselessSingleTagFilterKeyPrefix)
kb.B = encoding.MarshalUint64(kb.B[:0], uint64(maxMetrics))
kb.B = tf.Marshal(kb.B)
kb.B = tf.Marshal(kb.B, tfs.accountID, tfs.projectID)
is.db.uselessTagFiltersCache.Set(kb.B, uselessTagFilterCacheValue)
uselessTagFilters++
continue

View File

@ -128,6 +128,12 @@ func (tf *tagFilter) String() string {
return bb.String()
}
func (tf *tagFilter) Marshal(dst []byte, accountID, projectID uint32) []byte {
dst = encoding.MarshalUint32(dst, accountID)
dst = encoding.MarshalUint32(dst, projectID)
return tf.MarshalNoAccountIDProjectID(dst)
}
// MarshalNoAccountIDProjectID appends marshaled tf to dst
// and returns the result.
func (tf *tagFilter) MarshalNoAccountIDProjectID(dst []byte) []byte {