Skip to content

Incorrest hash counting of CountMinSketch #48

@awen-li

Description

@awen-li

Description

During using the lib CountMinSketch, the counting is unexpected when the item number is larger than the table size.

Steps/Code/Corpus to Reproduce

'''
from bounter import CountMinSketch

Cms = None
LogCounting = None

def setUp(LogCounting = None):
return CountMinSketch(1, width=2, depth=2, log_counting=LogCounting)

Cms = setUp ()

Loop = 8
ItemNum=8

print ("Loop = ", Loop)
for i in range (0, Loop):
for s in range (0, ItemNum):
Cms.increment(str (s))

for s in range (0, 8):
print ("Cms[%d] = %d" %(s, Cms[str (s)]))

'''

Expected Results

Cms[0] = 8
Cms[1] = 8
Cms[2] = 0
Cms[3] = 0
Cms[4] = 0
Cms[5] = 0
Cms[6] = 0
Cms[7] = 0

Actual Results

Cms[0] = 22
Cms[1] = 22
Cms[2] = 22
Cms[3] = 24
Cms[4] = 24
Cms[5] = 23
Cms[6] = 23
Cms[7] = 24

Versions

the main branch

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions