-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: EdricCua <[email protected]>
- Loading branch information
Showing
16 changed files
with
1,137 additions
and
315 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0 | ||
|
||
package api | ||
|
||
import "github.com/valkey-io/valkey-glide/go/glide/api/options" | ||
|
||
// Supports commands and transactions for the "Bitmap" group of commands for standalone and cluster clients. | ||
// | ||
// See [valkey.io] for details. | ||
// | ||
// [valkey.io]: https://valkey.io/commands/#bitmap | ||
type BitmapCommands interface { | ||
SetBit(key string, offset int64, value int64) (int64, error) | ||
|
||
GetBit(key string, offset int64) (int64, error) | ||
|
||
BitCount(key string) (int64, error) | ||
|
||
BitCountWithOptions(key string, options *options.BitCountOptions) (int64, error) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0 | ||
|
||
package options | ||
|
||
import ( | ||
"github.com/valkey-io/valkey-glide/go/glide/utils" | ||
) | ||
|
||
type BitmapIndexType string | ||
|
||
const ( | ||
BYTE BitmapIndexType = "BYTE" | ||
BIT BitmapIndexType = "BIT" | ||
) | ||
|
||
// Optional arguments to `BitCount` in [BitMapCommands] | ||
type BitCountOptions struct { | ||
start *int64 | ||
end *int64 | ||
bitMapIndexType BitmapIndexType | ||
} | ||
|
||
func NewBitCountOptionsBuilder() *BitCountOptions { | ||
return &BitCountOptions{} | ||
} | ||
|
||
// SetStart defines start byte to calculate bitcount in bitcount command. | ||
func (options *BitCountOptions) SetStart(start int64) *BitCountOptions { | ||
options.start = &start | ||
return options | ||
} | ||
|
||
// SetEnd defines start byte to calculate bitcount in bitcount command. | ||
func (options *BitCountOptions) SetEnd(end int64) *BitCountOptions { | ||
options.end = &end | ||
return options | ||
} | ||
|
||
// SetBitmapIndexType to specify start and end are in BYTE or BIT | ||
func (options *BitCountOptions) SetBitmapIndexType(bitMapIndexType BitmapIndexType) *BitCountOptions { | ||
options.bitMapIndexType = bitMapIndexType | ||
return options | ||
} | ||
|
||
// ToArgs converts the options to a list of arguments. | ||
func (opts *BitCountOptions) ToArgs() ([]string, error) { | ||
args := []string{} | ||
var err error | ||
|
||
if opts.start != nil { | ||
args = append(args, utils.IntToString(*opts.start)) | ||
if opts.end != nil { | ||
args = append(args, utils.IntToString(*opts.end)) | ||
if opts.bitMapIndexType != "" { | ||
if opts.bitMapIndexType == BIT || opts.bitMapIndexType == BYTE { | ||
args = append(args, string(opts.bitMapIndexType)) | ||
} | ||
} | ||
} | ||
} | ||
|
||
return args, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.