From 0522efb2d6678434e1292fc9f3b207de5765e042 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Thu, 11 Jul 2019 15:00:50 +0300 Subject: [PATCH] lib/storage: add missing tagFilter.Marshal func --- lib/storage/index_db.go | 4 ++-- lib/storage/tag_filters.go | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/storage/index_db.go b/lib/storage/index_db.go index 85928be6b5..f911f28323 100644 --- a/lib/storage/index_db.go +++ b/lib/storage/index_db.go @@ -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 diff --git a/lib/storage/tag_filters.go b/lib/storage/tag_filters.go index c0c1fbc664..e084193a98 100644 --- a/lib/storage/tag_filters.go +++ b/lib/storage/tag_filters.go @@ -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 {