Skip to content

Commit 46f7465

Browse files
committed
improve parse_tags
Signed-off-by: hwassman <[email protected]>
1 parent 4b7430a commit 46f7465

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

source/collector.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from utils import classattributes
3333

3434

35-
local_cache = []
35+
local_cache = set()
3636

3737

3838
class TimeSeries(object):
@@ -56,7 +56,7 @@ def parse_tags(self, filtersMap):
5656
'Single ts identifiers', ', '.join(ident)))
5757
found = False
5858
for filtersDict in filtersMap:
59-
if all((value in filtersDict.values()) for value in ident):
59+
if set(filtersDict.values()) == set(ident):
6060
logger.trace(MSG['ReceivAttrValues'].format(
6161
'filtersKeys', ', '.join(filtersDict.keys())))
6262
if len(self.columnInfo.keys) == 1:
@@ -68,17 +68,16 @@ def parse_tags(self, filtersMap):
6868
break
6969
# detected zimon key, do we need refresh local TOPO?
7070
if not found:
71-
already_reported = False
72-
for cache_item in local_cache:
73-
if set(cache_item) == set(ident):
74-
logger.trace(MSG['NewKeyAlreadyReported'].format(ident))
75-
already_reported = True
76-
break
77-
if not already_reported:
71+
cache_size = len(local_cache)
72+
local_cache.union(ident)
73+
updated_size = len(local_cache)
74+
if updated_size > cache_size:
7875
logger.trace(MSG['NewKeyDetected'].format(ident))
7976
local_cache.append(ident)
8077
md = MetadataHandler()
8178
Thread(name='AdHocMetaDataUpdate', target=md.update).start()
79+
else:
80+
logger.trace(MSG['NewKeyAlreadyReported'].format(ident))
8281

8382
for _key, _values in tagsDict.items():
8483
if len(_values) > 1:

0 commit comments

Comments
 (0)