Skip to content

Commit

Permalink
Add HLL commands
Browse files Browse the repository at this point in the history
Signed-off-by: Chaitanya Munukutla <[email protected]>
  • Loading branch information
c16a committed Aug 24, 2024
1 parent 447a7d0 commit ba0c133
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
43 changes: 43 additions & 0 deletions sdk/commands/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,49 @@ func NewSMembersCommand(line LineMessage) (*SMembersCommand, error) {
}, nil
}

type PFAddCommand struct {
Key string
Values []string
LineMessage
}

func NewPFAddCommand(line LineMessage) (*PFAddCommand, error) {
parts := strings.Split(line.String(), ":")
return &PFAddCommand{
Key: parts[1],
Values: parts[2:],
LineMessage: line,
}, nil
}

type PFCountCommand struct {
Key string
LineMessage
}

func NewPFCountCommand(line LineMessage) (*PFCountCommand, error) {
parts := strings.Split(line.String(), " ")
return &PFCountCommand{
Key: parts[1],
LineMessage: line,
}, nil
}

type PFMergeCommand struct {
DestKey string
SourceKeys []string
LineMessage
}

func NewPFMergeCommand(line LineMessage) (*PFMergeCommand, error) {
parts := strings.Split(line.String(), ":")
return &PFMergeCommand{
DestKey: parts[1],
SourceKeys: parts[2:],
LineMessage: line,
}, nil
}

type GetCommand struct {
Key string
LineMessage
Expand Down
10 changes: 10 additions & 0 deletions sdk/commands/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ const (
BFInfo MessageType = "BF.INFO" // Returns information about a Bloom Filter.
BFReserve MessageType = "BF.RESERVE" // Creates a new Bloom Filter.

PFAdd MessageType = "PFADD"
PFCount MessageType = "PFCOUNT"
PFMerge MessageType = "PFMERGE"

AuthChallengeResponse MessageType = "AUTH.CHALLENGE.RES"
AuthChallengeRequest MessageType = "AUTH.CHALLENGE.REQ"

Expand Down Expand Up @@ -98,6 +102,12 @@ func ParseStringIntoCommand(s string) (Command, error) {
return NewSIsMemberCommand(lineMessage)
case string(SMembers):
return NewSMembersCommand(lineMessage)
case string(PFAdd):
return NewPFAddCommand(lineMessage)
case string(PFCount):
return NewPFCountCommand(lineMessage)
case string(PFMerge):
return NewPFMergeCommand(lineMessage)
default:
return nil, ErrInvalidCommand
}
Expand Down

0 comments on commit ba0c133

Please sign in to comment.