Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement unique keys counting using hll #4652

Merged
merged 1 commit into from
Feb 24, 2025
Merged

feat: implement unique keys counting using hll #4652

merged 1 commit into from
Feb 24, 2025

Conversation

romange
Copy link
Collaborator

@romange romange commented Feb 24, 2025

HyperLogLog is an efficient data structure for approximate counting of unique elements. We use it to sample the traffic via "DEBUG KEYS ON/OFF" command.

@romange romange requested a review from BorysTheDev February 24, 2025 11:52
@@ -1301,9 +1301,10 @@ int convertSparseToDenseHll(struct HllBufferPtr in_hll, struct HllBufferPtr out_
return C_OK;
}

int pfadd_sparse(sds* hll_ptr, unsigned char* value, size_t size, int* promoted) {
int pfadd_sparse(sds* hll_ptr, const unsigned char* value,
Copy link
Collaborator Author

@romange romange Feb 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed the interface to accept const unsigned char. unfortunately the internal utilities still require a mutable buffer, so I remove const below.

HyperLogLog is an efficient data structure for approximate counting of unique elements.
We use it to sample the traffic via "DEBUG KEYS ON/OFF" command.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
struct hllhdr* hdr = (struct hllhdr*)(*hll_ptr);
int retval = hllSparseAdd(hll_ptr, value, size, promoted);
int retval = hllSparseAdd(hll_ptr, (unsigned char*)value, size, promoted);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const _cast?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a c file

@romange romange merged commit fa95690 into main Feb 24, 2025
10 checks passed
@romange romange deleted the Pr7 branch February 24, 2025 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants