mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Avoid divide-by-zero in CardinalityCounter::Size
This commit is contained in:
parent
bde2dec685
commit
bf82f8afc1
2 changed files with 6 additions and 1 deletions
|
@ -134,6 +134,10 @@ void CardinalityCounter::AddElement(uint64_t hash) {
|
|||
**/
|
||||
double CardinalityCounter::Size() const {
|
||||
double answer = 0;
|
||||
|
||||
if ( m == 0 )
|
||||
return -1.0;
|
||||
|
||||
for ( unsigned int i = 0; i < m; i++ )
|
||||
answer += pow(2, -((int)buckets[i]));
|
||||
|
||||
|
|
|
@ -75,7 +75,8 @@ public:
|
|||
* Get the current estimated number of elements in the data
|
||||
* structure
|
||||
*
|
||||
* @return Estimated number of elements
|
||||
* @return Estimated number of elements. Returns -1.0 if there are
|
||||
* zero buckets.
|
||||
**/
|
||||
double Size() const;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue