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

ft: Add support for PFDEBUG command #1216

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

neverwannafly
Copy link

Description

This PR adds support for PFDEBUG command in dicedb.

Progress

  • Code refactoring
  • Adding tests
  • Handling one subcommand

Copy link
Collaborator

@JyotinderSingh JyotinderSingh left a comment

Choose a reason for hiding this comment

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

Thanks for this change. There are some merge conflicts, could you please resolve them? Also, please add tests for the commands you have added.

}

sparseField := reflect.ValueOf(hll).Elem().FieldByName("sparseList")
sparseFieldValue := reflect.NewAt(sparseField.Type(), unsafe.Pointer(sparseField.UnsafeAddr())).Elem()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a way we can avoid usage of unsafe pointers?

Copy link
Author

Choose a reason for hiding this comment

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

one thing we can do, convert the hyperloglog structure to binary, the third byte is 0/1 depending on sparse/dense notation. I'll use that instead.


obj := store.Get(key)
if obj == nil {
return diceerrors.NewErrWithMessage("Key does not exist")
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should match the message returned by redis, and ideally be defined as a constant string in the constants file.

Copy link
Author

Choose a reason for hiding this comment

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

yeah, matches the message. Will define as constant

}

switch subcommand {
case "GETREG":
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use a constant to define this string in the constants file. Same for other cases.

// For call to GETREG, encoding is converted from sparse to dense.
// We'll merge a sparse and an empty dense HLL to get a dense HLL
// with values of sparse HLL.
if encoding == "sparse" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Define this string in a constant. It would also be good to be consistent with the casing of these constants.

@apoorvyadav1111
Copy link
Contributor

Hi @neverwannafly , Thanks for addressing the comments. Could you please rebase the PR and re-request for review?

Thanks

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.

4 participants