before_code stringlengths 30 149k | reviewer_comment stringlengths 16 20.6k | after_code stringlengths 30 163k | diff_context stringlengths 0 22.4k | file_path stringlengths 6 155 | comment_line int64 0 26 | language stringclasses 19
values | quality_score float64 0.07 1 | comment_type stringclasses 9
values | comment_length int64 16 20.6k | before_lines int64 2 4.61k | after_lines int64 2 4.4k | is_negative bool 2
classes | pr_title stringlengths 7 140 | pr_number int64 18 61.2k | repo_name stringclasses 29
values | repo_stars int64 321 56k | repo_language stringclasses 14
values | reviewer_username stringclasses 378
values | author_username stringclasses 739
values | user stringlengths 361 200k | assistant stringlengths 16 20.6k | system stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
{
name: "Increment string representing integers",
commands: []string{
"SET str_int1 42",
"INCR str_int1",
"SET str_int2 -10",
"INCR str_int2",
"SET str_int2 0",
"INCR str_int3",
},
expected: []interface{}{
"OK", 43, "OK", -9, "OK", 1,
},
},
}
// Clean up keys before each... | remove this code. we are by default invoking FLUSHDB so there will not be any existence of any key or stray data. | // Copyright (c) 2022-present, DiceDB contributors
// All rights reserved. Licensed under the BSD 3-Clause License. See LICENSE file in the project root for full license information.
package ironhawk
import (
"fmt"
"math"
"testing"
)
func TestINCR(t *testing.T) {
client := getLocalConnection()
defer client.Clos... | @@ -6,165 +6,111 @@ package ironhawk
import (
"fmt"
"math"
+ "strconv"
"testing"
- "time"
- "github.com/dicedb/dice/internal/server/utils"
- "github.com/stretchr/testify/assert"
+ "github.com/dicedb/dicedb-go/wire"
)
func TestINCR(t *testing.T) {
client := getLocalConnection()
defer client.Close()
- ... | tests/commands/ironhawk/incr_test.go | 26 | Go | 0.429 | refactor | 113 | 51 | 100 | false | Integration tests fixes - INCRBY & INCR | 1,516 | DiceDB/dice | 10,326 | C | arpitbbhayani | bipoool | Review this pull request change.
Language: Go
File: tests/commands/ironhawk/incr_test.go
PR Title: Integration tests fixes - INCRBY & INCR
BEFORE CODE: {
name: "Increment string representing integers",
commands: []string{
"SET str_int1 42",
"INCR str_int1",
"SET str_int2 -10",
"INCR str_int2... | remove this code. we are by default invoking FLUSHDB so there will not be any existence of any key or stray data. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
"SET str_int2 -10",
"INCR str_int2",
"SET str_int2 0",
"INCR str_int3",
},
expected: []interface{}{
"OK", 43, "OK", -9, "OK", 1,
},
},
}
// Clean up keys before each test case
keys := []string{
"key1", "key2", "max_int", "min_int", "float_key", "string_key", "bool_key",
"non_existe... | move this to a new file `incrby_test.go` | // Copyright (c) 2022-present, DiceDB contributors
// All rights reserved. Licensed under the BSD 3-Clause License. See LICENSE file in the project root for full license information.
package ironhawk
import (
"fmt"
"math"
"testing"
)
func TestINCR(t *testing.T) {
client := getLocalConnection()
defer client.Clos... | @@ -6,165 +6,111 @@ package ironhawk
import (
"fmt"
"math"
+ "strconv"
"testing"
- "time"
- "github.com/dicedb/dice/internal/server/utils"
- "github.com/stretchr/testify/assert"
+ "github.com/dicedb/dicedb-go/wire"
)
func TestINCR(t *testing.T) {
client := getLocalConnection()
defer client.Close()
- ... | tests/commands/ironhawk/incr_test.go | 26 | Go | 0.286 | refactor | 40 | 51 | 100 | false | Integration tests fixes - INCRBY & INCR | 1,516 | DiceDB/dice | 10,326 | C | arpitbbhayani | bipoool | Review this pull request change.
Language: Go
File: tests/commands/ironhawk/incr_test.go
PR Title: Integration tests fixes - INCRBY & INCR
BEFORE CODE: "SET str_int2 -10",
"INCR str_int2",
"SET str_int2 0",
"INCR str_int3",
},
expected: []interface{}{
"OK", 43, "OK", -9, "OK", 1,
},
}... | move this to a new file `incrby_test.go` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
commands: []string{
"SET key " + strconv.FormatInt(math.MinInt64+1, 10),
"INCRBY key -1",
"INCRBY key -1",
"GET key",
},
expected: []interface{}{
"OK", math.MinInt64, math.MaxInt64, math.MaxInt64,
},
},
{
name: "edge case with string values",
commands: []string{
"SET key 1"... | we don';t need these as we FLUSH the database every time. | // Copyright (c) 2022-present, DiceDB contributors
// All rights reserved. Licensed under the BSD 3-Clause License. See LICENSE file in the project root for full license information.
package ironhawk
import (
"fmt"
"math"
"testing"
)
func TestINCR(t *testing.T) {
client := getLocalConnection()
defer client.Clos... | @@ -188,118 +134,83 @@ func TestINCRBY(t *testing.T) {
expectedVal int64
}
- testCases := []struct {
- name string
- setCommands []SetCommand
- incrByCommands []IncrByCommand
- getCommands []GetCommand
- }{
+ testCases := []TestCase{
{
name: "happy flow",
- setCommands: []SetCommand{... | tests/commands/ironhawk/incr_test.go | 26 | Go | 0.214 | suggestion | 57 | 31 | 100 | false | Integration tests fixes - INCRBY & INCR | 1,516 | DiceDB/dice | 10,326 | C | arpitbbhayani | bipoool | Review this pull request change.
Language: Go
File: tests/commands/ironhawk/incr_test.go
PR Title: Integration tests fixes - INCRBY & INCR
BEFORE CODE: commands: []string{
"SET key " + strconv.FormatInt(math.MinInt64+1, 10),
"INCRBY key -1",
"INCRBY key -1",
"GET key",
},
expected: []interf... | we don';t need these as we FLUSH the database every time. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
// Copyright (c) 2022-present, DiceDB contributors
// All rights reserved. Licensed under the BSD 3-Clause License. See LICENSE file in the project root for full license information.
package ironhawk
import (
"fmt"
"math"
"strconv"
"testing"
"github.com/dicedb/dicedb-go/wire"
)
func TestINCR(t *testing.T) {
c... | Also, please check the `name` of the tests. They seem pretty basic. [stretch] | // Copyright (c) 2022-present, DiceDB contributors
// All rights reserved. Licensed under the BSD 3-Clause License. See LICENSE file in the project root for full license information.
package ironhawk
import (
"fmt"
"math"
"testing"
)
func TestINCR(t *testing.T) {
client := getLocalConnection()
defer client.Clos... | @@ -6,165 +6,111 @@ package ironhawk
import (
"fmt"
"math" | tests/commands/ironhawk/incr_test.go | 8 | Go | 0.357 | suggestion | 77 | 33 | 33 | false | Integration tests fixes - INCRBY & INCR | 1,516 | DiceDB/dice | 10,326 | C | arpitbbhayani | bipoool | Review this pull request change.
Language: Go
File: tests/commands/ironhawk/incr_test.go
PR Title: Integration tests fixes - INCRBY & INCR
BEFORE CODE: // Copyright (c) 2022-present, DiceDB contributors
// All rights reserved. Licensed under the BSD 3-Clause License. See LICENSE file in the project root for full li... | Also, please check the `name` of the tests. They seem pretty basic. [stretch] | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
return fmt.Sprintf("%s %s", c.C.Cmd, strings.Join(c.C.Args, " "))
}
func (c *Cmd) Fingerprint() uint32 {
return farm.Fingerprint32([]byte(c.String()))
}
func (c *Cmd) Key() string {
if len(c.C.Args) > 0 {
return c.C.Args[0]
}
return ""
}
func (c *Cmd) Execute(sm *shardmanager.ShardManager) (*CmdRes, error) {
... | Instead of having this `else`, we can just use the above `if` to populate `Meta` and either throw the error if the command is not found or make sure `Meta` is populated.
This way, we can get rid of `else` and can directly invoke `Execute`. This makes the code more readable. | return fmt.Sprintf("%s %s", c.C.Cmd, strings.Join(c.C.Args, " "))
}
func (c *Cmd) Fingerprint() uint32 {
return farm.Fingerprint32([]byte(c.String()))
}
func (c *Cmd) Key() string {
if len(c.C.Args) > 0 {
return c.C.Args[0]
}
return ""
}
func (c *Cmd) Execute(sm *shardmanager.ShardManager) (*CmdRes, error) {
... | @@ -43,16 +44,21 @@ func (c *Cmd) Key() string {
}
func (c *Cmd) Execute(sm *shardmanager.ShardManager) (*CmdRes, error) {
+
+ res := cmdResNil
+ err := errors.ErrUnknownCmd(c.C.Cmd)
start := time.Now()
if c.Meta == nil {
for _, meta := range CommandRegistry.CommandMetas {
if meta.Name == c.C.Cmd {
... | internal/cmd/cmds.go | 26 | Go | 0.786 | suggestion | 277 | 51 | 51 | false | Fix for Command Meta | 1,529 | DiceDB/dice | 10,326 | C | arpitbbhayani | bipoool | Review this pull request change.
Language: Go
File: internal/cmd/cmds.go
PR Title: Fix for Command Meta
BEFORE CODE: return fmt.Sprintf("%s %s", c.C.Cmd, strings.Join(c.C.Args, " "))
}
func (c *Cmd) Fingerprint() uint32 {
return farm.Fingerprint32([]byte(c.String()))
}
func (c *Cmd) Key() string {
if len(c.C.A... | Instead of having this `else`, we can just use the above `if` to populate `Meta` and either throw the error if the command is not found or make sure `Meta` is populated.
This way, we can get rid of `else` and can directly invoke `Execute`. This makes the code more readable. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
start := time.Now()
if c.Meta == nil {
meta, found := findCommandMeta(c.C.Cmd)
if !found {
return res, err
}
c.Meta = meta
}
res, err = c.Meta.Execute(c, sm)
slog.Debug("command executed",
slog.Any("cmd", c.String()),
slog.String("client_id", c.ClientID),
slog.String("mode", c.Mode),
slog.Any("t... | I do not understand the rationale behind having a function that is executed just once. This would well have been inline.
I would rather recommend optimizing this for loop with a map call so that the lookups are O(1) and not O(n). | start := time.Now()
if c.Meta == nil {
meta, ok := CommandRegistry.CommandMetas[c.C.Cmd]
if !ok {
return res, err
}
c.Meta = meta
}
res, err = c.Meta.Execute(c, sm)
slog.Debug("command executed",
slog.Any("cmd", c.String()),
slog.String("client_id", c.ClientID),
slog.String("mode", c.Mode),
slog... | @@ -61,6 +64,15 @@ func (c *Cmd) Execute(sm *shardmanager.ShardManager) (*CmdRes, error) {
return res, err
}
+func findCommandMeta(cmdName string) (*CommandMeta, bool) {
+ for _, meta := range CommandRegistry.CommandMetas {
+ if meta.Name == cmdName {
+ return meta, true
+ }
+ }
+ return nil, false
+}
+ | internal/cmd/cmds.go | 26 | Go | 0.429 | performance | 232 | 51 | 51 | false | Fix for Command Meta | 1,529 | DiceDB/dice | 10,326 | C | arpitbbhayani | bipoool | Review this pull request change.
Language: Go
File: internal/cmd/cmds.go
PR Title: Fix for Command Meta
BEFORE CODE: start := time.Now()
if c.Meta == nil {
meta, found := findCommandMeta(c.C.Cmd)
if !found {
return res, err
}
c.Meta = meta
}
res, err = c.Meta.Execute(c, sm)
slog.Debug("command execu... | I do not understand the rationale behind having a function that is executed just once. This would well have been inline.
I would rather recommend optimizing this for loop with a map call so that the lookups are O(1) and not O(n). | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
Session *auth.Session
}
func NewIOThread(clientFD int) (*IOThread, error) {
io, err := NewIOHandler(clientFD)
if err != nil {
slog.Error("Failed to create new IOHandler for clientFD", slog.Int("client-fd", clientFD), slog.Any("error", err))
return nil, err
}
return &IOThread{
IoHandler: io,
Session: a... | I think we should also set `_meta` here so that we need to lookup the meta when we are executing. | Session *auth.Session
}
func NewIOThread(clientFD int) (*IOThread, error) {
io, err := NewIOHandler(clientFD)
if err != nil {
slog.Error("Failed to create new IOHandler for clientFD", slog.Int("client-fd", clientFD), slog.Any("error", err))
return nil, err
}
return &IOThread{
IoHandler: io,
Session: a... | @@ -42,19 +41,11 @@ func (t *IOThread) StartSync(ctx context.Context, shardManager *shardmanager.Sha
}
// TODO: Replace this iteration with a HashTable lookup.
- var _meta *cmd.CommandMeta
- for _, _meta = range cmd.CommandRegistry.CommandMetas {
- if _meta.Name == c.Cmd {
- break
- }
+ _c := &cmd.Cmd... | internal/server/ironhawk/iothread.go | 26 | Go | 0.429 | suggestion | 97 | 51 | 51 | false | Fix for Command Meta | 1,529 | DiceDB/dice | 10,326 | C | arpitbbhayani | bipoool | Review this pull request change.
Language: Go
File: internal/server/ironhawk/iothread.go
PR Title: Fix for Command Meta
BEFORE CODE: Session *auth.Session
}
func NewIOThread(clientFD int) (*IOThread, error) {
io, err := NewIOHandler(clientFD)
if err != nil {
slog.Error("Failed to create new IOHandler for cl... | I think we should also set `_meta` here so that we need to lookup the meta when we are executing. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
res := cmdResNil
err := errors.ErrUnknownCmd(c.C.Cmd)
start := time.Now()
if c.Meta == nil {
meta, found := findCommandMeta(c.C.Cmd)
if !found {
return res, err
}
c.Meta = meta
}
res, err = c.Meta.Execute(c, sm)
slog.Debug("command executed",
slog.Any("cmd", c.String()),
slog.String("client_id", ... | I think (and remember) there is one more place where we are having a similar for loop. So I think creating a function makes sense if the logic is complicated enough. If it is just a Map lookup then we need not have a function call. |
res := cmdResNil
err := errors.ErrUnknownCmd(c.C.Cmd)
start := time.Now()
if c.Meta == nil {
meta, ok := CommandRegistry.CommandMetas[c.C.Cmd]
if !ok {
return res, err
}
c.Meta = meta
}
res, err = c.Meta.Execute(c, sm)
slog.Debug("command executed",
slog.Any("cmd", c.String()),
slog.String("clien... | @@ -61,6 +64,15 @@ func (c *Cmd) Execute(sm *shardmanager.ShardManager) (*CmdRes, error) {
return res, err
}
+func findCommandMeta(cmdName string) (*CommandMeta, bool) {
+ for _, meta := range CommandRegistry.CommandMetas {
+ if meta.Name == cmdName {
+ return meta, true
+ }
+ } | internal/cmd/cmds.go | 26 | Go | 0.429 | suggestion | 231 | 51 | 51 | false | Fix for Command Meta | 1,529 | DiceDB/dice | 10,326 | C | arpitbbhayani | bipoool | Review this pull request change.
Language: Go
File: internal/cmd/cmds.go
PR Title: Fix for Command Meta
BEFORE CODE:
res := cmdResNil
err := errors.ErrUnknownCmd(c.C.Cmd)
start := time.Now()
if c.Meta == nil {
meta, found := findCommandMeta(c.C.Cmd)
if !found {
return res, err
}
c.Meta = meta
}
re... | I think (and remember) there is one more place where we are having a similar for loop. So I think creating a function makes sense if the logic is complicated enough. If it is just a Map lookup then we need not have a function call. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
{
name: "Test EXISTS an expired key",
commands: []string{"SET key value ex 1", "EXISTS key", "EXISTS key"},
expected: []interface{}{"OK", 1, 0},
delay: []time.Duration{0, 0, 2 * time.Second},
},
{
name: "Test EXISTS with multiple keys and expired key",
commands: []string{"SET key valu... | I think the result should be 3 even if `key` is used twice, we would still count it in existing keys | {
name: "Test EXISTS an expired key",
commands: []string{"SET key value ex 1", "EXISTS key", "EXISTS key"},
expected: []interface{}{"OK", 1, 0},
delay: []time.Duration{0, 0, 2 * time.Second},
},
{
name: "Test EXISTS with multiple keys and expired key",
commands: []string{"SET key valu... | @@ -40,6 +40,16 @@ func TestExists(t *testing.T) {
commands: []string{"EXISTS"},
expected: []interface{}{0},
},
+ {
+ name: "EXISTS with duplicate keys",
+ commands: []string{"SET key value", "EXISTS key key"},
+ expected: []interface{}{"OK", 1},
+ },
+ {
+ name: "EXISTS with duplicate key... | tests/commands/ironhawk/exists_test.go | 26 | Go | 0.571 | suggestion | 100 | 32 | 37 | false | fix result for multiple keys in exists command | 1,598 | DiceDB/dice | 10,326 | C | apoorvyadav1111 | Abhijeetsng97 | Review this pull request change.
Language: Go
File: tests/commands/ironhawk/exists_test.go
PR Title: fix result for multiple keys in exists command
BEFORE CODE: {
name: "Test EXISTS an expired key",
commands: []string{"SET key value ex 1", "EXISTS key", "EXISTS key"},
expected: []interface{}{"OK", 1,... | I think the result should be 3 even if `key` is used twice, we would still count it in existing keys | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
}
func init() {
CommandRegistry.AddCommand(cEXISTS)
}
// TODO: EXISTS command is actually a multi-key command so this needs
// to be scattered and gathered one step before this.
func evalEXISTS(c *Cmd, s *dstore.Store) (*CmdRes, error) {
if len(c.C.Args) < 1 {
return cmdResNil, errors.ErrWrongArgumentCount("EXIS... | sorry. not keen on making cmdResInt a function. Let this become a problem i.e. let us find a case where it would benefit us. | Execute: executeEXISTS,
}
func init() {
CommandRegistry.AddCommand(cEXISTS)
}
// TODO: EXISTS command is actually a multi-key command so this needs
// to be scattered and gathered one step before this.
func evalEXISTS(c *Cmd, s *dstore.Store) (*CmdRes, error) {
if len(c.C.Args) < 1 {
return cmdResNil, errors.Er... | @@ -49,9 +48,7 @@ func evalEXISTS(c *Cmd, s *dstore.Store) (*CmdRes, error) {
}
// Return the count as a response
- return &CmdRes{R: &wire.Response{
- Value: &wire.Response_VInt{VInt: count},
- }}, nil
+ return cmdResInt(count), nil | internal/cmd/cmd_exists.go | 26 | Go | 0.357 | suggestion | 124 | 43 | 50 | false | Migrate ZADD | 1,613 | DiceDB/dice | 10,326 | C | arpitbbhayani | vivekkothari | Review this pull request change.
Language: Go
File: internal/cmd/cmd_exists.go
PR Title: Migrate ZADD
BEFORE CODE: }
func init() {
CommandRegistry.AddCommand(cEXISTS)
}
// TODO: EXISTS command is actually a multi-key command so this needs
// to be scattered and gathered one step before this.
func evalEXISTS(c *... | sorry. not keen on making cmdResInt a function. Let this become a problem i.e. let us find a case where it would benefit us. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
// Copyright (c) 2022-present, DiceDB contributors
// All rights reserved. Licensed under the BSD 3-Clause License. See LICENSE file in the project root for full license information.
package cmd
import (
"github.com/dicedb/dice/internal/errors"
"github.com/dicedb/dice/internal/shardmanager"
dstore "github.com/dice... | sorry. not keen on making cmdResInt a function. Let this become a problem i.e. let us find a case where it would benefit us. | }
// Return the count as a response
return cmdResInt(count), nil
}
func executeEXISTS(c *Cmd, sm *shardmanager.ShardManager) (*CmdRes, error) {
if len(c.C.Args) < 1 {
return cmdResNil, errors.ErrWrongArgumentCount("EXISTS")
}
var count int64
var shardMap = make(map[*shard.Shard][]string)
for _, key := range... | @@ -67,7 +64,5 @@ func executeEXISTS(c *Cmd, sm *shardmanager.ShardManager) (*CmdRes, error) {
}
count += r.R.GetVInt()
}
- return &CmdRes{R: &wire.Response{
- Value: &wire.Response_VInt{VInt: count},
- }}, nil
+ return cmdResInt(count), nil | internal/cmd/cmd_exists.go | 26 | Go | 0.357 | suggestion | 124 | 69 | 28 | false | Migrate ZADD | 1,613 | DiceDB/dice | 10,326 | C | arpitbbhayani | vivekkothari | Review this pull request change.
Language: Go
File: internal/cmd/cmd_exists.go
PR Title: Migrate ZADD
BEFORE CODE: // Copyright (c) 2022-present, DiceDB contributors
// All rights reserved. Licensed under the BSD 3-Clause License. See LICENSE file in the project root for full license information.
package cmd
impo... | sorry. not keen on making cmdResInt a function. Let this become a problem i.e. let us find a case where it would benefit us. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
"LT": false,
"GT": false,
"CH": false,
"INCR": false,
}
for i := 0; i < len(args); i++ {
switch strings.ToUpper(args[i]) {
case "NX":
parsedFlags["NX"] = true
case "XX":
parsedFlags["XX"] = true
case "LT":
parsedFlags["LT"] = true
case "GT":
parsedFlags["GT"] = true
case "CH":
... | Refer to the `cmd_set.go` file and let's reuse the flags parsing logic from there. | if len(c.C.Args) < 3 {
return cmdResNil, errors.ErrWrongArgumentCount("ZADD")
}
shard := sm.GetShardForKey(c.C.Args[0])
return evalZADD(c, shard.Thread.Store())
}
func getOrCreateSortedSet(store *dsstore.Store, key string) (*sortedset.Set, error) {
obj := store.Get(key)
if obj != nil {
sortedSet, err := sor... | @@ -0,0 +1,207 @@
+package cmd
+
+import (
+ "math"
+ "strconv"
+ "strings"
+
+ "github.com/dicedb/dice/internal/errors"
+ "github.com/dicedb/dice/internal/eval/sortedset"
+ "github.com/dicedb/dice/internal/object"
+ "github.com/dicedb/dice/internal/shardmanager"
+ dsstore "github.com/dicedb/dice/internal/store"
+)
+
+... | internal/cmd/cmd_zadd.go | 26 | Go | 0.429 | suggestion | 82 | 51 | 51 | false | Migrate ZADD | 1,613 | DiceDB/dice | 10,326 | C | arpitbbhayani | vivekkothari | Review this pull request change.
Language: Go
File: internal/cmd/cmd_zadd.go
PR Title: Migrate ZADD
BEFORE CODE: "LT": false,
"GT": false,
"CH": false,
"INCR": false,
}
for i := 0; i < len(args); i++ {
switch strings.ToUpper(args[i]) {
case "NX":
parsedFlags["NX"] = true
case "XX":
parse... | Refer to the `cmd_set.go` file and let's reuse the flags parsing logic from there. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
case "INCR":
parsedFlags["INCR"] = true
default:
return parsedFlags, i + 1
}
}
return parsedFlags, len(args) + 1
}
// only valid combination of options works
func validateFlagsAndArgs(args []string, flags map[string]bool) error {
if len(args)%2 != 0 {
return errors.ErrGeneral("syntax error")
}
if f... | refer to the above comment and structure the code as it has been done in `cmd_set.go`. | return sortedset.New(), nil
}
// processMembersWithFlags processes the members and scores while handling flags.
func processMembersWithFlags(params map[float64]string, sortedSet *sortedset.Set, store *dsstore.Store, key string, flags map[string]bool) (*CmdRes, error) {
added, updated := 0, 0
for score, member := r... | @@ -0,0 +1,207 @@
+package cmd
+
+import (
+ "math"
+ "strconv"
+ "strings"
+
+ "github.com/dicedb/dice/internal/errors"
+ "github.com/dicedb/dice/internal/eval/sortedset"
+ "github.com/dicedb/dice/internal/object"
+ "github.com/dicedb/dice/internal/shardmanager"
+ dsstore "github.com/dicedb/dice/internal/store"
+)
+
+... | internal/cmd/cmd_zadd.go | 26 | Go | 0.357 | suggestion | 86 | 51 | 51 | false | Migrate ZADD | 1,613 | DiceDB/dice | 10,326 | C | arpitbbhayani | vivekkothari | Review this pull request change.
Language: Go
File: internal/cmd/cmd_zadd.go
PR Title: Migrate ZADD
BEFORE CODE: case "INCR":
parsedFlags["INCR"] = true
default:
return parsedFlags, i + 1
}
}
return parsedFlags, len(args) + 1
}
// only valid combination of options works
func validateFlagsAndArgs(arg... | refer to the above comment and structure the code as it has been done in `cmd_set.go`. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
score += currentScore
} else {
score = 0.0 + score
}
// Now check GT and LT conditions based on the incremented score and return accordingly
if (flags["GT"] && exists && score <= currentScore) ||
(flags["LT"] && exists && score >= currentScore) {
return nil, nil
}
}
// Check if the ... | This is a pretty convoluted logic. Please refer to the logic used in EXPIRE and TTL commands, you can find it in `internal/cmd/**`. | // Store the updated sorted set in the store
storeUpdatedSet(store, key, sortedSet)
if flags["CH"] {
return cmdResInt(int64(added + updated)), nil
}
// Return only the count of added members
return cmdResInt(int64(added)), nil
}
// shouldSkipMember determines if a member should be skipped based on flags.
fun... | @@ -0,0 +1,207 @@
+package cmd
+
+import (
+ "math"
+ "strconv"
+ "strings"
+
+ "github.com/dicedb/dice/internal/errors"
+ "github.com/dicedb/dice/internal/eval/sortedset"
+ "github.com/dicedb/dice/internal/object"
+ "github.com/dicedb/dice/internal/shardmanager"
+ dsstore "github.com/dicedb/dice/internal/store"
+)
+
+... | internal/cmd/cmd_zadd.go | 26 | Go | 0.571 | suggestion | 131 | 51 | 32 | false | Migrate ZADD | 1,613 | DiceDB/dice | 10,326 | C | arpitbbhayani | vivekkothari | Review this pull request change.
Language: Go
File: internal/cmd/cmd_zadd.go
PR Title: Migrate ZADD
BEFORE CODE: score += currentScore
} else {
score = 0.0 + score
}
// Now check GT and LT conditions based on the incremented score and return accordingly
if (flags["GT"] && exists && score <= cur... | This is a pretty convoluted logic. Please refer to the logic used in EXPIRE and TTL commands, you can find it in `internal/cmd/**`. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
}
// only valid flags works
if err := validateFlagsAndArgs(c.C.Args[nextIndex:], flags); err != nil {
return cmdResNil, err
}
// all processing takes place here
return processMembersWithFlags(c.C.Args[nextIndex:], sortedSet, s, key, flags)
}
func executeZADD(c *Cmd, sm *shardmanager.ShardManager) (*CmdRes, err... | Shall we move these before L47? Once all parsing and validations are done we can call `getOrCreateSortedSet`? | case "XX", "NX", "LT", "GT", "CH", "INCR":
flags[arg] = true
default:
// This should be a float repesneting the score. If its not, its a problem.
score, err := strconv.ParseFloat(arg, 64)
if err != nil || math.IsNaN(score) {
return cmdResNil, errors.ErrInvalidNumberFormat
}
if i+1 >= len(c.C.A... | @@ -0,0 +1,207 @@
+package cmd
+
+import (
+ "math"
+ "strconv"
+ "strings"
+
+ "github.com/dicedb/dice/internal/errors"
+ "github.com/dicedb/dice/internal/eval/sortedset"
+ "github.com/dicedb/dice/internal/object"
+ "github.com/dicedb/dice/internal/shardmanager"
+ dsstore "github.com/dicedb/dice/internal/store"
+)
+
+... | internal/cmd/cmd_zadd.go | 26 | Go | 0.571 | question | 109 | 51 | 51 | false | Migrate ZADD | 1,613 | DiceDB/dice | 10,326 | C | lucifercr07 | vivekkothari | Review this pull request change.
Language: Go
File: internal/cmd/cmd_zadd.go
PR Title: Migrate ZADD
BEFORE CODE: }
// only valid flags works
if err := validateFlagsAndArgs(c.C.Args[nextIndex:], flags); err != nil {
return cmdResNil, err
}
// all processing takes place here
return processMembersWithFlags(c.C... | Shall we move these before L47? Once all parsing and validations are done we can call `getOrCreateSortedSet`? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
- XX: Only update existing elements and do not add new elements
- CH: Modify the return value from the number of new elements added, to the total number of elements changed
- INCR: When this option is specified, the elements are treated as increments to the score of the existing elements
- GT: Only add new elements if ... | Nit: Shall we use `nextIndex` to avoid the processing of flags?
> If nextIndex is 1 (which would be the position right after the key in the command arguments), that means no flag arguments were processed and we can skip the flag parsing entirely. | - XX: Only update existing elements and do not add new elements
- CH: Modify the return value from the number of new elements added, to the total number of elements changed
- INCR: When this option is specified, the elements are treated as increments to the score of the existing elements
- GT: Only add new elements if ... | @@ -0,0 +1,207 @@
+package cmd
+
+import (
+ "math"
+ "strconv"
+ "strings"
+
+ "github.com/dicedb/dice/internal/errors"
+ "github.com/dicedb/dice/internal/eval/sortedset"
+ "github.com/dicedb/dice/internal/object"
+ "github.com/dicedb/dice/internal/shardmanager"
+ dsstore "github.com/dicedb/dice/internal/store"
+)
+
+... | internal/cmd/cmd_zadd.go | 26 | Go | 0.643 | nitpick | 247 | 51 | 51 | false | Migrate ZADD | 1,613 | DiceDB/dice | 10,326 | C | lucifercr07 | vivekkothari | Review this pull request change.
Language: Go
File: internal/cmd/cmd_zadd.go
PR Title: Migrate ZADD
BEFORE CODE: - XX: Only update existing elements and do not add new elements
- CH: Modify the return value from the number of new elements added, to the total number of elements changed
- INCR: When this option is sp... | Nit: Shall we use `nextIndex` to avoid the processing of flags?
> If nextIndex is 1 (which would be the position right after the key in the command arguments), that means no flag arguments were processed and we can skip the flag parsing entirely. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
// GetFingerprint returns a 32-bit fingerprint of the command and its arguments.
func (cmd *DiceDBCmd) Fingerprint() uint32 {
return farm.Fingerprint32([]byte(cmd.Repr()))
}
// Key Returns the key which the command operates on.
//
// TODO: This is a naive implementation which assumes that the first argument is the k... | Why this function? why can't we reuse `cmdResNil`? | }
// GetFingerprint returns a 32-bit fingerprint of the command and its arguments.
func (cmd *DiceDBCmd) Fingerprint() uint32 {
return farm.Fingerprint32([]byte(cmd.Repr()))
}
// Key Returns the key which the command operates on.
//
// TODO: This is a naive implementation which assumes that the first argument is the... | @@ -151,6 +152,12 @@ func (cmd *DiceDBCmd) Key() string {
return c
}
+func GetNilRes() *CmdRes {
+ return &CmdRes{R: &wire.Response{
+ Value: &wire.Response_VNil{VNil: true},
+ }}
+}
+ | internal/cmd/cmds.go | 26 | Go | 0.429 | question | 50 | 43 | 50 | false | Fix concurrent client connections watch mode | 1,651 | DiceDB/dice | 10,326 | C | arpitbbhayani | lucifercr07 | Review this pull request change.
Language: Go
File: internal/cmd/cmds.go
PR Title: Fix concurrent client connections watch mode
BEFORE CODE:
// GetFingerprint returns a 32-bit fingerprint of the command and its arguments.
func (cmd *DiceDBCmd) Fingerprint() uint32 {
return farm.Fingerprint32([]byte(cmd.Repr()))
}... | Why this function? why can't we reuse `cmdResNil`? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
// TODO: If the key gets deleted from the database
// delete the subscriptions against that key from all the places.
}
func (w *WatchManager) CleanupThreadWatchSubscriptions(t *IOThread) {
w.mu.Lock()
defer w.mu.Unlock()
// Delete the mapping of Watch thread to client id
delete(w.clientWatchThreadMap, t.Client... | This change should significantly improve the through put of notifications on watches as RLocks can be acquired concurrently. The earlier code would only allow either one writer or reader to be processed at the same time.
With this change, concurrent users can read but only one writer to be processed. | // TODO: If the key gets deleted from the database
// delete the subscriptions against that key from all the places.
}
func (w *WatchManager) CleanupThreadWatchSubscriptions(t *IOThread) {
w.mu.Lock()
defer w.mu.Unlock()
// Delete the mapping of Watch thread to client id
delete(w.clientWatchThreadMap, t.ClientI... | @@ -130,8 +131,9 @@ func (w *WatchManager) CleanupThreadWatchSubscriptions(t *IOThread) {
}
func (w *WatchManager) NotifyWatchers(c *cmd.Cmd, shardManager *shardmanager.ShardManager, t *IOThread) {
- w.mu.Lock()
- defer w.mu.Unlock()
+ // Use RLock instead as we are not really modifying any shared maps here.
+ w.mu... | internal/server/ironhawk/watch_manager.go | 26 | Go | 0.5 | suggestion | 304 | 51 | 51 | false | Reduce scope of locks | 1,668 | DiceDB/dice | 10,326 | C | vivekkothari | vivekkothari | Review this pull request change.
Language: Go
File: internal/server/ironhawk/watch_manager.go
PR Title: Reduce scope of locks
BEFORE CODE:
// TODO: If the key gets deleted from the database
// delete the subscriptions against that key from all the places.
}
func (w *WatchManager) CleanupThreadWatchSubscriptions... | This change should significantly improve the through put of notifications on watches as RLocks can be acquired concurrently. The earlier code would only allow either one writer or reader to be processed at the same time.
With this change, concurrent users can read but only one writer to be processed. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
var cGET = &CommandMeta{
Name: "GET",
Syntax: "GET key",
HelpShort: "GET returns the value as a string for the key in args",
HelpLong: `
GET returns the value as a string for the key in args.
The command returns an empty string if the key does not exist.
`,
Examples: `
localhost:7379> SET k1 v1
OK
localh... | We do not want to return `error` from this function. Create a CmdRes object instead. | var cGET = &CommandMeta{
Name: "GET",
Syntax: "GET key",
HelpShort: "GET returns the value as a string for the key in args",
HelpLong: `
GET returns the value as a string for the key in args.
The command returns an empty string if the key does not exist.
`,
Examples: `
localhost:7379> SET k1 v1
OK
localh... | @@ -38,22 +38,26 @@ func init() {
CommandRegistry.AddCommand(cGET)
}
-func newGETRes(obj *object.Obj) *CmdRes {
+func newGETRes(obj *object.Obj) (*CmdRes, error) { | internal/cmd/cmd_get.go | 26 | Go | 0.571 | suggestion | 84 | 51 | 51 | false | Server doesn't crash if Obj Type is not present and float support in GET Command | 1,703 | DiceDB/dice | 10,326 | C | arpitbbhayani | Abhijeetsng97 | Review this pull request change.
Language: Go
File: internal/cmd/cmd_get.go
PR Title: Server doesn't crash if Obj Type is not present and float support in GET Command
BEFORE CODE: var cGET = &CommandMeta{
Name: "GET",
Syntax: "GET key",
HelpShort: "GET returns the value as a string for the key in args",
... | We do not want to return `error` from this function. Create a CmdRes object instead. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
func newZCARDWATCHRes() *CmdRes {
return &CmdRes{
Rs: &wire.Result{
Message: "OK",
Status: wire.Status_OK,
Response: &wire.Result_ZCARDWATCHRes{},
},
}
}
var (
ZCARDWATCHResNilRes = newZCARDWATCHRes()
)
func evalZCARDWATCH(c *Cmd, s *dstore.Store) (*CmdRes, error) {
r, err := evalZCARD(c, s)
if e... | `==0` is correct. For `.watch` commands the check on arguments is handled at primary command level. This way, we need not make changes at two places when we support other args. Revert this change. | func newZCARDWATCHRes() *CmdRes {
return &CmdRes{
Rs: &wire.Result{
Message: "OK",
Status: wire.Status_OK,
Response: &wire.Result_ZCARDWATCHRes{},
},
}
}
var (
ZCARDWATCHResNilRes = newZCARDWATCHRes()
)
func evalZCARDWATCH(c *Cmd, s *dstore.Store) (*CmdRes, error) {
r, err := evalZCARD(c, s)
if e... | @@ -69,7 +69,7 @@ func evalZCARDWATCH(c *Cmd, s *dstore.Store) (*CmdRes, error) {
}
func executeZCARDWATCH(c *Cmd, sm *shardmanager.ShardManager) (*CmdRes, error) {
- if len(c.C.Args) == 0 {
+ if len(c.C.Args) != 1 { | internal/cmd/cmd_zcard_watch.go | 26 | Go | 0.714 | suggestion | 196 | 32 | 32 | false | Fixed z-* Commands & Tests | 1,726 | DiceDB/dice | 10,326 | C | arpitbbhayani | bipoool | Review this pull request change.
Language: Go
File: internal/cmd/cmd_zcard_watch.go
PR Title: Fixed z-* Commands & Tests
BEFORE CODE: func newZCARDWATCHRes() *CmdRes {
return &CmdRes{
Rs: &wire.Result{
Message: "OK",
Status: wire.Status_OK,
Response: &wire.Result_ZCARDWATCHRes{},
},
}
}
var (
ZC... | `==0` is correct. For `.watch` commands the check on arguments is handled at primary command level. This way, we need not make changes at two places when we support other args. Revert this change. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
func newZCOUNTWATCHRes() *CmdRes {
return &CmdRes{
Rs: &wire.Result{
Message: "OK",
Status: wire.Status_OK,
Response: &wire.Result_ZCOUNTWATCHRes{},
},
}
}
var (
ZCOUNTWATCHResNilRes = newZCOUNTWATCHRes()
)
func evalZCOUNTWATCH(c *Cmd, s *dstore.Store) (*CmdRes, error) {
r, err := evalZCOUNT(c, s)... | `==0` is correct. For `.watch` commands the check on arguments is handled at primary command level. This way, we need not make changes at two places when we support other args. Revert this change. | func newZCOUNTWATCHRes() *CmdRes {
return &CmdRes{
Rs: &wire.Result{
Message: "OK",
Status: wire.Status_OK,
Response: &wire.Result_ZCOUNTWATCHRes{},
},
}
}
var (
ZCOUNTWATCHResNilRes = newZCOUNTWATCHRes()
)
func evalZCOUNTWATCH(c *Cmd, s *dstore.Store) (*CmdRes, error) {
r, err := evalZCOUNT(c, s)... | @@ -69,7 +69,7 @@ func evalZCOUNTWATCH(c *Cmd, s *dstore.Store) (*CmdRes, error) {
}
func executeZCOUNTWATCH(c *Cmd, sm *shardmanager.ShardManager) (*CmdRes, error) {
- if len(c.C.Args) == 0 { | internal/cmd/cmd_zcount_watch.go | 26 | Go | 0.714 | suggestion | 196 | 32 | 32 | false | Fixed z-* Commands & Tests | 1,726 | DiceDB/dice | 10,326 | C | arpitbbhayani | bipoool | Review this pull request change.
Language: Go
File: internal/cmd/cmd_zcount_watch.go
PR Title: Fixed z-* Commands & Tests
BEFORE CODE: func newZCOUNTWATCHRes() *CmdRes {
return &CmdRes{
Rs: &wire.Result{
Message: "OK",
Status: wire.Status_OK,
Response: &wire.Result_ZCOUNTWATCHRes{},
},
}
}
var (
... | `==0` is correct. For `.watch` commands the check on arguments is handled at primary command level. This way, we need not make changes at two places when we support other args. Revert this change. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
func newZRANGEWATCHRes() *CmdRes {
return &CmdRes{
Rs: &wire.Result{
Message: "OK",
Status: wire.Status_OK,
Response: &wire.Result_ZRANGEWATCHRes{},
},
}
}
var (
ZRANGEWATCHResNilRes = newZRANGEWATCHRes()
)
func evalZRANGEWATCH(c *Cmd, s *dstore.Store) (*CmdRes, error) {
r, err := evalZRANGE(c, s)... | `==0` is correct. For `.watch` commands the check on arguments is handled at primary command level. This way, we need not make changes at two places when we support other args. Revert this change. | func newZRANGEWATCHRes() *CmdRes {
return &CmdRes{
Rs: &wire.Result{
Message: "OK",
Status: wire.Status_OK,
Response: &wire.Result_ZRANGEWATCHRes{},
},
}
}
var (
ZRANGEWATCHResNilRes = newZRANGEWATCHRes()
)
func evalZRANGEWATCH(c *Cmd, s *dstore.Store) (*CmdRes, error) {
r, err := evalZRANGE(c, s)... | @@ -73,7 +73,7 @@ func evalZRANGEWATCH(c *Cmd, s *dstore.Store) (*CmdRes, error) {
}
func executeZRANGEWATCH(c *Cmd, sm *shardmanager.ShardManager) (*CmdRes, error) {
- if len(c.C.Args) == 0 { | internal/cmd/cmd_zrange_watch.go | 26 | Go | 0.714 | suggestion | 196 | 32 | 32 | false | Fixed z-* Commands & Tests | 1,726 | DiceDB/dice | 10,326 | C | arpitbbhayani | bipoool | Review this pull request change.
Language: Go
File: internal/cmd/cmd_zrange_watch.go
PR Title: Fixed z-* Commands & Tests
BEFORE CODE: func newZRANGEWATCHRes() *CmdRes {
return &CmdRes{
Rs: &wire.Result{
Message: "OK",
Status: wire.Status_OK,
Response: &wire.Result_ZRANGEWATCHRes{},
},
}
}
var (
... | `==0` is correct. For `.watch` commands the check on arguments is handled at primary command level. This way, we need not make changes at two places when we support other args. Revert this change. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
func newZRANKWATCHRes() *CmdRes {
return &CmdRes{
Rs: &wire.Result{
Message: "OK",
Status: wire.Status_OK,
Response: &wire.Result_ZRANKWATCHRes{},
},
}
}
var (
ZRANKWATCHResNilRes = newZRANKWATCHRes()
)
func evalZRANKWATCH(c *Cmd, s *dstore.Store) (*CmdRes, error) {
r, err := evalZRANK(c, s)
if e... | `==0` is correct. For `.watch` commands the check on arguments is handled at primary command level. This way, we need not make changes at two places when we support other args. Revert this change. | func newZRANKWATCHRes() *CmdRes {
return &CmdRes{
Rs: &wire.Result{
Message: "OK",
Status: wire.Status_OK,
Response: &wire.Result_ZRANKWATCHRes{},
},
}
}
var (
ZRANKWATCHResNilRes = newZRANKWATCHRes()
)
func evalZRANKWATCH(c *Cmd, s *dstore.Store) (*CmdRes, error) {
r, err := evalZRANK(c, s)
if e... | @@ -72,7 +72,7 @@ func evalZRANKWATCH(c *Cmd, s *dstore.Store) (*CmdRes, error) {
}
func executeZRANKWATCH(c *Cmd, sm *shardmanager.ShardManager) (*CmdRes, error) {
- if len(c.C.Args) == 0 { | internal/cmd/cmd_zrank_watch.go | 26 | Go | 0.714 | suggestion | 196 | 32 | 32 | false | Fixed z-* Commands & Tests | 1,726 | DiceDB/dice | 10,326 | C | arpitbbhayani | bipoool | Review this pull request change.
Language: Go
File: internal/cmd/cmd_zrank_watch.go
PR Title: Fixed z-* Commands & Tests
BEFORE CODE: func newZRANKWATCHRes() *CmdRes {
return &CmdRes{
Rs: &wire.Result{
Message: "OK",
Status: wire.Status_OK,
Response: &wire.Result_ZRANKWATCHRes{},
},
}
}
var (
ZR... | `==0` is correct. For `.watch` commands the check on arguments is handled at primary command level. This way, we need not make changes at two places when we support other args. Revert this change. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
}
selectStmt, ok := stmt.(*sqlparser.Select)
if !ok {
return DSQLQuery{}, newUnsupportedSqlStatementError(stmt)
}
// Ensure no unsupported clauses are present
if err := checkUnsupportedClauses(selectStmt); err != nil {
return DSQLQuery{}, err
}
querySelection, err := parseSelectExpressions(selectStmt)
i... | No issues found. | }
selectStmt, ok := stmt.(*sqlparser.Select)
if !ok {
return DSQLQuery{}, newUnsupportedSqlStatementError(stmt)
}
// Ensure no unsupported clauses are present
if err := checkUnsupportedClauses(selectStmt); err != nil {
return DSQLQuery{}, err
}
querySelection, err := parseSelectExpressions(selectStmt)
i... | @@ -1,15 +1,22 @@
-// This file contains the core logic for parsing DSQL queries. DSQL stands for
-// Dice SQL, and is a simple SQL-like language that is used to query data from
-// DiceDB.
-
package core
import (
"fmt"
+ "strconv"
+ "strings"
"github.com/xwb1989/sqlparser"
)
+// Constants for custom synta... | core/dsql.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | Supporting wildcard FROM, ORDER BY $value and LIMIT in DSQL | 124 | DiceDB/dice | 10,326 | C | JyotinderSingh | Review this pull request change.
Language: Go
File: core/dsql.go
PR Title: Supporting wildcard FROM, ORDER BY $value and LIMIT in DSQL
BEFORE CODE: }
selectStmt, ok := stmt.(*sqlparser.Select)
if !ok {
return DSQLQuery{}, newUnsupportedSqlStatementError(stmt)
}
// Ensure no unsupported clauses are present
... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
a bloom filter. If the filter does not exists, it will create a new one
with default parameters.`,
Eval: evalBFADD,
}
bfexistsCmdMeta = DiceCmdMeta{
Name: "BFEXISTS",
Info: `BFEXISTS checks existance of an element in a bloom filter.`,
Eval: evalBFEXISTS,
}
bfinfoCmdMeta = DiceCmdMeta{
Name: "BFINFO",
... | No issues found. | a bloom filter. If the filter does not exists, it will create a new one
with default parameters.`,
Eval: evalBFADD,
}
bfexistsCmdMeta = DiceCmdMeta{
Name: "BFEXISTS",
Info: `BFEXISTS checks existance of an element in a bloom filter.`,
Eval: evalBFEXISTS,
}
bfinfoCmdMeta = DiceCmdMeta{
Name: "BFINFO",
... | @@ -303,6 +303,11 @@ var (
Info: "Quit the server",
Eval: nil,
}
+ commandCmdMeta = DiceCmdMeta{
+ Name: "COMMAND <subcommand>",
+ Info: "Evaluates COMMAND <subcommand> command based on subcommand",
+ Eval: evalCommand,
+ }
)
func init() {
@@ -346,4 +351,5 @@ func init() {
diceCmds["EXEC"] = execCmdMet... | core/commands.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | #145 : Added support for COMMAND COUNT command | 153 | DiceDB/dice | 10,326 | C | VipinRaiP | Review this pull request change.
Language: Go
File: core/commands.go
PR Title: #145 : Added support for COMMAND COUNT command
BEFORE CODE: a bloom filter. If the filter does not exists, it will create a new one
with default parameters.`,
Eval: evalBFADD,
}
bfexistsCmdMeta = DiceCmdMeta{
Name: "BFEXISTS",... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
package core
// WildCardMatch checks if the key matches the pattern using * and ? as wildcards using two pointer approach
func WildCardMatch(pattern, key string) bool {
patternLen := len(pattern)
keyLen := len(key)
patternIndex := 0
keyIndex := 0
starIndex := -1
kIndex := -1
for keyIndex < keyLen {
if patter... | No issues found. | package core
// WildCardMatch checks if the key matches the pattern using * and ? as wildcards using two pointer approach
func WildCardMatch(pattern, key string) bool {
patternLen := len(pattern)
keyLen := len(key)
patternIndex := 0
keyIndex := 0
starIndex := -1
kIndex := -1
for keyIndex < keyLen {
if patter... | @@ -1,23 +1,34 @@
package core
-import (
- "regexp"
- "strings"
-)
+// WildCardMatch checks if the key matches the pattern using * and ? as wildcards using two pointer approach
+func WildCardMatch(pattern, key string) bool {
+ patternLen := len(pattern)
+ keyLen := len(key)
+ patternIndex := 0
+ keyIndex := 0
+ star... | core/regex.go | 0 | Go | 1 | none | 16 | 35 | 35 | true | Added wildcard matching for DSQL query | 169 | DiceDB/dice | 10,326 | C | Dev79844 | Review this pull request change.
Language: Go
File: core/regex.go
PR Title: Added wildcard matching for DSQL query
BEFORE CODE: package core
// WildCardMatch checks if the key matches the pattern using * and ? as wildcards using two pointer approach
func WildCardMatch(pattern, key string) bool {
patternLen := len... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
obj := Get(args[0])
if obj == nil {
return RESP_NIL
}
if err := assertType(obj.TypeEncoding, OBJ_TYPE_BYTELIST); err != nil {
return Encode(err, false)
}
if err := assertEncoding(obj.TypeEncoding, OBJ_ENCODING_STACKINT); err != nil {
return Encode(err, false)
}
s := obj.Value.(*StackInt)
x, err := s.... | No issues found. |
obj := Get(args[0])
if obj == nil {
return RESP_NIL
}
if err := assertType(obj.TypeEncoding, OBJ_TYPE_BYTELIST); err != nil {
return Encode(err, false)
}
if err := assertEncoding(obj.TypeEncoding, OBJ_ENCODING_STACKINT); err != nil {
return Encode(err, false)
}
s := obj.Value.(*StackInt)
x, err := s.... | @@ -6,6 +6,7 @@ import (
"fmt"
"log"
"strconv"
+ "strings"
"syscall"
"time"
@@ -864,98 +865,36 @@ func evalQWATCH(args []string, c *Client) []byte {
}
func executeCommand(cmd *RedisCmd, c *Client) []byte {
- switch cmd.Cmd {
- case "PING":
- return evalPING(cmd.Args)
- case "SET":
- return evalSET(cmd... | core/eval.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | #182: Refactor command handling for maintainability | 170 | DiceDB/dice | 10,326 | C | kakdeykaushik | Review this pull request change.
Language: Go
File: core/eval.go
PR Title: #182: Refactor command handling for maintainability
BEFORE CODE:
obj := Get(args[0])
if obj == nil {
return RESP_NIL
}
if err := assertType(obj.TypeEncoding, OBJ_TYPE_BYTELIST); err != nil {
return Encode(err, false)
}
if err :=... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
}
if retrievedUser != user {
t.Error("Users.Get() returned a different user than the one added")
}
}
func TestUserSetPassword(t *testing.T) {
user := &User{Username: "testuser"}
password := "testpassword"
err := user.SetPassword(password)
if err != nil {
t.Errorf("User.SetPassword() returned an error: %v",... | No issues found. | }
if retrievedUser != user {
t.Error("Users.Get() returned a different user than the one added")
}
}
func TestUserSetPassword(t *testing.T) {
user := &User{Username: "testuser"}
password := "testpassword"
err := user.SetPassword(password)
if err != nil {
t.Errorf("User.SetPassword() returned an error: %v",... | @@ -0,0 +1,151 @@
+package core
+
+import (
+ "testing"
+ "time"
+
+ "github.com/dicedb/dice/config"
+)
+
+func TestNewUsers(t *testing.T) {
+ users := NewUsersStore()
+ if users == nil {
+ t.Error("NewUsers() returned nil")
+ }
+ if users != nil && users.store == nil {
+ t.Error("NewUsers() created Users with nil st... | core/session_test.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | Add support for Basic Auth | 179 | DiceDB/dice | 10,326 | C | gsarmaonline | Review this pull request change.
Language: Go
File: core/session_test.go
PR Title: Add support for Basic Auth
BEFORE CODE: }
if retrievedUser != user {
t.Error("Users.Get() returned a different user than the one added")
}
}
func TestUserSetPassword(t *testing.T) {
user := &User{Username: "testuser"}
passwor... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
Name: "BFINIT",
Info: `BFINIT command initializes a new bloom filter and allocation it's relevant parameters based on given inputs.
If no params are provided, it uses defaults.`,
Eval: evalBFINIT,
}
bfaddCmdMeta = DiceCmdMeta{
Name: "BFADD",
Info: `BFADD adds an element to
a bloom filter. If the filter ... | No issues found. | Name: "BFINIT",
Info: `BFINIT command initializes a new bloom filter and allocation it's relevant parameters based on given inputs.
If no params are provided, it uses defaults.`,
Eval: evalBFINIT,
}
bfaddCmdMeta = DiceCmdMeta{
Name: "BFADD",
Info: `BFADD adds an element to
a bloom filter. If the filter ... | @@ -34,6 +34,23 @@ var (
GET returns RESP_NIL if key is expired or it does not exist`,
Eval: evalGET,
}
+ jsonsetCmdMeta = DiceCmdMeta{
+ Name: "JSON.SET",
+ Info: `JSON.SET key path json-string
+ Sets a JSON value at the specified key.
+ Returns OK if successful.
+ Returns encoded error message if the num... | core/commands.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | Add support for JSON | 181 | DiceDB/dice | 10,326 | C | Maveric-k07 | Review this pull request change.
Language: Go
File: core/commands.go
PR Title: Add support for JSON
BEFORE CODE: Name: "BFINIT",
Info: `BFINIT command initializes a new bloom filter and allocation it's relevant parameters based on given inputs.
If no params are provided, it uses defaults.`,
Eval: evalBFINI... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
if err := assertType(obj.TypeEncoding, OBJ_TYPE_BYTELIST); err != nil {
return Encode(err, false)
}
if err := assertEncoding(obj.TypeEncoding, OBJ_ENCODING_QREF); err != nil {
return Encode(err, false)
}
Put(args[0], obj)
q := obj.Value.(*QueueRef)
if q.Insert(args[1]) {
return Encode(1, false)
}
ret... | No issues found. |
if err := assertType(obj.TypeEncoding, OBJ_TYPE_BYTELIST); err != nil {
return Encode(err, false)
}
if err := assertEncoding(obj.TypeEncoding, OBJ_ENCODING_QREF); err != nil {
return Encode(err, false)
}
Put(args[0], obj)
q := obj.Value.(*QueueRef)
if q.Insert(args[1]) {
return Encode(1, false)
}
ret... | @@ -1306,6 +1306,22 @@ func evalCommand(args []string) []byte {
}
}
+// evalKeys returns the list of keys that match the pattern
+// The pattern should be the only param in args
+func evalKeys(args []string) []byte {
+ if len(args) != 1 {
+ return Encode(errors.New("ERR wrong number of arguments for 'keys' comman... | core/eval.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | feat: support KEYS command | 197 | DiceDB/dice | 10,326 | C | mingo023 | Review this pull request change.
Language: Go
File: core/eval.go
PR Title: feat: support KEYS command
BEFORE CODE:
if err := assertType(obj.TypeEncoding, OBJ_TYPE_BYTELIST); err != nil {
return Encode(err, false)
}
if err := assertEncoding(obj.TypeEncoding, OBJ_ENCODING_QREF); err != nil {
return Encode(er... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
func TestDecodeOneCrossProtocolScripting(t *testing.T) {
mockRW := &MockReadWriter{ReadChunks: [][]byte{[]byte("GET / HTTP/1.1\r\n\r\n")}}
parser := NewRESPParser(mockRW)
_, err := parser.DecodeOne()
if err == nil || err.Error() != "possible cross protocol scripting attack detected" {
t.Fatalf("Expected cross pro... | No issues found. | func TestDecodeOneCrossProtocolScripting(t *testing.T) {
mockRW := &MockReadWriter{ReadChunks: [][]byte{[]byte("GET / HTTP/1.1\r\n\r\n")}}
parser := NewRESPParser(mockRW)
_, err := parser.DecodeOne()
if err == nil || err.Error() != "possible cross protocol scripting attack detected" {
t.Fatalf("Expected cross pro... | @@ -189,3 +189,18 @@ func TestDecodeOneVeryLargeMessage(t *testing.T) {
t.Fatalf("Expected large string, got %v", result)
}
}
+
+
+func TestDecodeOneNoDataRead(t *testing.T) {
+ mockRW := &MockReadWriter{
+ ReadChunks: [][]byte{
+ []byte(""), // Empty read chunk
+ },
+ }
+ parser := NewRESPParser(mockRW)
+
... | core/io_test.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | #196: Fixed DiceDB server reconnection error. | 208 | DiceDB/dice | 10,326 | C | cam4phor | Review this pull request change.
Language: Go
File: core/io_test.go
PR Title: #196: Fixed DiceDB server reconnection error.
BEFORE CODE: func TestDecodeOneCrossProtocolScripting(t *testing.T) {
mockRW := &MockReadWriter{ReadChunks: [][]byte{[]byte("GET / HTTP/1.1\r\n\r\n")}}
parser := NewRESPParser(mockRW)
_, er... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
package tests
import (
"testing"
"time"
"gotest.tools/v3/assert"
)
type DDelayTestCase struct {
InCmds []string
Out []interface{}
Delay []time.Duration
}
func TestGet(t *testing.T) {
conn := getLocalConnection()
defer conn.Close()
for _, tcase := range []DDelayTestCase{
{
InCmds: []string{"SET k v... | No issues found. | package tests
import (
"testing"
"time"
"gotest.tools/v3/assert"
)
type DDelayTestCase struct {
InCmds []string
Out []interface{}
Delay []time.Duration
}
func TestGet(t *testing.T) {
conn := getLocalConnection()
defer conn.Close()
for _, tcase := range []DDelayTestCase{
{
InCmds: []string{"SET k v... | @@ -0,0 +1,35 @@
+package tests
+
+import (
+ "testing"
+ "time"
+
+ "gotest.tools/v3/assert"
+)
+
+type DDelayTestCase struct {
+ InCmds []string
+ Out []interface{}
+ Delay []time.Duration
+}
+
+func TestGet(t *testing.T) {
+ conn := getLocalConnection()
+ defer conn.Close()
+ for _, tcase := range []DDelayTestCa... | tests/get_test.go | 0 | Go | 1 | none | 16 | 36 | 36 | true | #201: Fix for expired key crash | 209 | DiceDB/dice | 10,326 | C | apoorvyadav1111 | Review this pull request change.
Language: Go
File: tests/get_test.go
PR Title: #201: Fix for expired key crash
BEFORE CODE: package tests
import (
"testing"
"time"
"gotest.tools/v3/assert"
)
type DDelayTestCase struct {
InCmds []string
Out []interface{}
Delay []time.Duration
}
func TestGet(t *testing... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
<-done
}
loadedOps, err := aof.Load()
if err != nil {
t.Fatalf("Failed to load after concurrent writes: %v", err)
}
if len(loadedOps) != concurrentOps+4 { // +4 for previous operations
t.Errorf("Unexpected number of operations. Got %d, want %d", len(loadedOps), concurrentOps+4)
}
})
}
func Test... | No issues found. | <-done
}
loadedOps, err := aof.Load()
if err != nil {
t.Fatalf("Failed to load after concurrent writes: %v", err)
}
if len(loadedOps) != concurrentOps+4 { // +4 for previous operations
t.Errorf("Unexpected number of operations. Got %d, want %d", len(loadedOps), concurrentOps+4)
}
})
}
func Test... | @@ -4,7 +4,9 @@ import (
"fmt"
"os"
"reflect"
+ "strconv"
"testing"
+ "time"
)
func TestAOF(t *testing.T) {
@@ -122,3 +124,153 @@ func TestAOF(t *testing.T) {
}
})
}
+
+func TestAOFWithExat(t *testing.T) {
+ testFile := "test.aof"
+
+ defer os.Remove(testFile)
+
+ t.Run("Create and Write with EXAT", f... | core/aof_test.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | Add support for EXAT in SET command | 218 | DiceDB/dice | 10,326 | C | colommar | Review this pull request change.
Language: Go
File: core/aof_test.go
PR Title: Add support for EXAT in SET command
BEFORE CODE: <-done
}
loadedOps, err := aof.Load()
if err != nil {
t.Fatalf("Failed to load after concurrent writes: %v", err)
}
if len(loadedOps) != concurrentOps+4 { // +4 for previ... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
}
if err := assertEncoding(obj.TypeEncoding, OBJ_ENCODING_QINT); err != nil {
return Encode(err, false)
}
q := obj.Value.(*QueueInt)
x, err := q.Remove()
if err == ErrQueueEmpty {
return RESP_NIL
}
return Encode(x, false)
}
// evalSTACKINTPOP pops the element from the STACKINT identified by key
// firs... | No issues found. | }
if err := assertEncoding(obj.TypeEncoding, OBJ_ENCODING_QINT); err != nil {
return Encode(err, false)
}
q := obj.Value.(*QueueInt)
x, err := q.Remove()
if err == ErrQueueEmpty {
return RESP_NIL
}
return Encode(x, false)
}
// evalSTACKINTPOP pops the element from the STACKINT identified by key
// firs... | @@ -87,6 +87,15 @@ func evalSET(args []string) []byte {
return Encode(errors.New("ERR value is not an integer or out of range"), false)
}
exDurationMs = exDurationSec * 1000
+ case "XX", "xx":
+ // Get the key from the hash table
+ obj := Get(key)
+
+ // if key does not exist, return RESP encoded ni... | core/eval.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | #205: Add support for XX in SET command | 220 | DiceDB/dice | 10,326 | C | sanuj96 | Review this pull request change.
Language: Go
File: core/eval.go
PR Title: #205: Add support for XX in SET command
BEFORE CODE: }
if err := assertEncoding(obj.TypeEncoding, OBJ_ENCODING_QINT); err != nil {
return Encode(err, false)
}
q := obj.Value.(*QueueInt)
x, err := q.Remove()
if err == ErrQueueEmpty... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
// returns 0 otherwise
func evalQREFINS(args []string) []byte {
if len(args) != 2 {
return Encode(errors.New("ERR invalid number of arguments for `QREFINS` command"), false)
}
obj := Get(args[0])
if obj == nil {
obj = NewObj(NewQueueRef(), -1, OBJ_TYPE_BYTELIST, OBJ_ENCODING_QREF)
}
if err := assertType(obj... | No issues found. | // returns 0 otherwise
func evalQREFINS(args []string) []byte {
if len(args) != 2 {
return Encode(errors.New("ERR invalid number of arguments for `QREFINS` command"), false)
}
obj := Get(args[0])
if obj == nil {
obj = NewObj(NewQueueRef(), -1, OBJ_TYPE_BYTELIST, OBJ_ENCODING_QREF)
}
if err := assertType(obj... | @@ -121,6 +121,11 @@ func evalSET(args []string) []byte {
if obj == nil {
return RESP_NIL
}
+ case "NX", "nx":
+ obj := Get(key);
+ if obj != nil {
+ return RESP_NIL;
+ }
default:
return Encode(errors.New("ERR syntax error"), false)
} | core/eval.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | Added support NX for SET command | 227 | DiceDB/dice | 10,326 | C | chanducheryala | Review this pull request change.
Language: Go
File: core/eval.go
PR Title: Added support NX for SET command
BEFORE CODE: // returns 0 otherwise
func evalQREFINS(args []string) []byte {
if len(args) != 2 {
return Encode(errors.New("ERR invalid number of arguments for `QREFINS` command"), false)
}
obj := Get(ar... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
func NewQueueRef() *QueueRef {
return &QueueRef{
qi: NewQueueInt(),
}
}
func (q *QueueRef) Size() int64 {
return q.qi.Size()
}
// Insert inserts reference of the key in the QueueRef q.
// returns false if key does not exist
func (q *QueueRef) Insert(key string) bool {
var x unsafe.Pointer
var ok bool
withLoc... | No issues found. | func NewQueueRef() *QueueRef {
return &QueueRef{
qi: NewQueueInt(),
}
}
func (q *QueueRef) Size() int64 {
return q.qi.Size()
}
// Insert inserts reference of the key in the QueueRef q.
// returns false if key does not exist
func (q *QueueRef) Insert(key string) bool {
var x unsafe.Pointer
var ok bool
withLoc... | @@ -73,3 +73,8 @@ func (q *QueueRef) Iterate(n int) []*QueueElement {
}
return elements
}
+
+// Returns the length of the queue
+func (q *QueueRef) Length() int64 {
+ return q.qi.Length
+} | core/queueref.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | #184 : Test cases and benchmarking for queueref remove | 229 | DiceDB/dice | 10,326 | C | VipinRaiP | Review this pull request change.
Language: Go
File: core/queueref.go
PR Title: #184 : Test cases and benchmarking for queueref remove
BEFORE CODE: func NewQueueRef() *QueueRef {
return &QueueRef{
qi: NewQueueInt(),
}
}
func (q *QueueRef) Size() int64 {
return q.qi.Size()
}
// Insert inserts reference of the ... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
package testutils
import (
"encoding/json"
"reflect"
"testing"
"gotest.tools/v3/assert"
)
func IsJSONResponse(s string) bool {
return (len(s) > 0 && (s[0] == '{' || s[0] == '['))
}
func AssertJSONEqual(t *testing.T, expected, actual string) {
var expectedJSON, actualJSON interface{}
err := json.Unmarshal([]... | No issues found. | package testutils
import (
"encoding/json"
"reflect"
"testing"
"gotest.tools/v3/assert"
)
func IsJSONResponse(s string) bool {
return (len(s) > 0 && (s[0] == '{' || s[0] == '['))
}
func AssertJSONEqual(t *testing.T, expected, actual string) {
var expectedJSON, actualJSON interface{}
err := json.Unmarshal([]... | @@ -0,0 +1,45 @@
+package testutils
+
+import (
+ "encoding/json"
+ "reflect"
+ "testing"
+
+ "gotest.tools/v3/assert"
+)
+
+func IsJSONResponse(s string) bool {
+ return (len(s) > 0 && (s[0] == '{' || s[0] == '['))
+}
+
+func AssertJSONEqual(t *testing.T, expected, actual string) {
+ var expectedJSON, actualJSON inter... | testutils/json.go | 0 | Go | 1 | none | 16 | 46 | 46 | true | #166: Adds JSONPath Support | 235 | DiceDB/dice | 10,326 | C | Maveric-k07 | Review this pull request change.
Language: Go
File: testutils/json.go
PR Title: #166: Adds JSONPath Support
BEFORE CODE: package testutils
import (
"encoding/json"
"reflect"
"testing"
"gotest.tools/v3/assert"
)
func IsJSONResponse(s string) bool {
return (len(s) > 0 && (s[0] == '{' || s[0] == '['))
}
func ... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
}
}
func getLocalSdk() *redis.Client {
return redis.NewClient(&redis.Options{
Addr: fmt.Sprintf(":%d", config.Port),
DialTimeout: 10 * time.Second,
ReadTimeout: 30 * time.Second,
WriteTimeout: 30 * time.Second,
ContextTimeoutEnabled: true,
MaxRetries: -1,
PoolSize: ... | No issues found. | }
}
func getLocalSdk() *redis.Client {
return redis.NewClient(&redis.Options{
Addr: fmt.Sprintf(":%d", config.Port),
DialTimeout: 10 * time.Second,
ReadTimeout: 30 * time.Second,
WriteTimeout: 30 * time.Second,
ContextTimeoutEnabled: true,
MaxRetries: -1,
PoolSize: ... | @@ -4,7 +4,6 @@ import (
"fmt"
"io"
"net"
- "strings"
"sync"
"time"
@@ -13,6 +12,7 @@ import (
"github.com/dicedb/dice/config"
"github.com/dicedb/dice/core"
"github.com/dicedb/dice/server"
+ "github.com/dicedb/dice/testutils"
redis "github.com/dicedb/go-dice"
)
@@ -50,7 +50,7 @@ func getLocalSdk(... | tests/setup.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | adding px option for SET command | 236 | DiceDB/dice | 10,326 | C | SyedMa3 | Review this pull request change.
Language: Go
File: tests/setup.go
PR Title: adding px option for SET command
BEFORE CODE: }
}
func getLocalSdk() *redis.Client {
return redis.NewClient(&redis.Options{
Addr: fmt.Sprintf(":%d", config.Port),
DialTimeout: 10 * time.Second,
ReadTimeout: 30... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
import (
"gotest.tools/v3/assert"
"strconv"
"testing"
"time"
)
type testCase struct {
input []string
output []byte
}
func TestEval(t *testing.T) {
testCases := map[string]func(*testing.T){
"SET": testEvalSET,
}
for name, testFunc := range testCases {
t.Run(name, testFunc)
}
}
func testEvalSET(t *tes... | No issues found. |
import (
"gotest.tools/v3/assert"
"strconv"
"testing"
"time"
)
type testCase struct {
input []string
output []byte
}
func TestEval(t *testing.T) {
testCases := map[string]func(*testing.T){
"SET": testEvalSET,
}
for name, testFunc := range testCases {
t.Run(name, testFunc)
}
}
func testEvalSET(t *tes... | @@ -0,0 +1,52 @@
+package core
+
+import (
+ "gotest.tools/v3/assert"
+ "strconv"
+ "testing"
+ "time"
+)
+
+type testCase struct {
+ input []string
+ output []byte
+}
+
+func TestEval(t *testing.T) {
+ testCases := map[string]func(*testing.T){
+ "SET": testEvalSET,
+ }
+
+ for name, testFunc := range testCases {
+ ... | core/eval_test.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | feat: [GH-203] Add support for PXAT in SET command | 237 | DiceDB/dice | 10,326 | C | lucifercr07 | Review this pull request change.
Language: Go
File: core/eval_test.go
PR Title: feat: [GH-203] Add support for PXAT in SET command
BEFORE CODE:
import (
"gotest.tools/v3/assert"
"strconv"
"testing"
"time"
)
type testCase struct {
input []string
output []byte
}
func TestEval(t *testing.T) {
testCases := m... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
// returns the array of integers as the response.
// if the key does not exist, then we return an empty array
func evalQINTPEEK(args []string) []byte {
var num int64 = 5
var err error
if len(args) > 2 {
return Encode(errors.New("ERR invalid number of arguments for `QINTPEEK` command"), false)
}
if len(args) ==... | No issues found. | // returns the array of integers as the response.
// if the key does not exist, then we return an empty array
func evalQINTPEEK(args []string) []byte {
var num int64 = 5
var err error
if len(args) > 2 {
return Encode(errors.New("ERR invalid number of arguments for `QINTPEEK` command"), false)
}
if len(args) ==... | @@ -1588,6 +1588,21 @@ func evalCommandGetKeys(args []string) []byte {
return Encode(keys, false)
}
+func evalEXISTS(args []string) []byte {
+ if len(args) == 0 {
+ return Encode(errors.New("ERR wrong number of arguments for 'exists' command"), false)
+ }
+
+ var count int
+ for _, key := range args {
+ if GetNo... | core/eval.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | New feature: EXISTS k1, k2..Kn | 245 | DiceDB/dice | 10,326 | C | apoorvyadav1111 | Review this pull request change.
Language: Go
File: core/eval.go
PR Title: New feature: EXISTS k1, k2..Kn
BEFORE CODE: // returns the array of integers as the response.
// if the key does not exist, then we return an empty array
func evalQINTPEEK(args []string) []byte {
var num int64 = 5
var err error
if len(ar... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
package tests
import (
"testing"
"gotest.tools/v3/assert"
)
func TestMset(t *testing.T) {
conn := getLocalConnection()
defer conn.Close()
testCases := []struct {
name string
commands []string
expected []interface{}
}{
{
name: "MSET with one key-value pair",
commands: []string{"MSET k1 v1... | No issues found. | package tests
import (
"testing"
"gotest.tools/v3/assert"
)
func TestMset(t *testing.T) {
conn := getLocalConnection()
defer conn.Close()
testCases := []struct {
name string
commands []string
expected []interface{}
}{
{
name: "MSET with one key-value pair",
commands: []string{"MSET k1 v1... | @@ -0,0 +1,44 @@
+package tests
+
+import (
+ "testing"
+
+ "gotest.tools/v3/assert"
+)
+
+func TestMset(t *testing.T) {
+ conn := getLocalConnection()
+ defer conn.Close()
+
+ testCases := []struct {
+ name string
+ commands []string
+ expected []interface{}
+ }{
+ {
+ name: "MSET with one key-value pair... | tests/mset_test.go | 0 | Go | 1 | none | 16 | 45 | 45 | true | added mset command | 261 | DiceDB/dice | 10,326 | C | SyedMa3 | Review this pull request change.
Language: Go
File: tests/mset_test.go
PR Title: added mset command
BEFORE CODE: package tests
import (
"testing"
"gotest.tools/v3/assert"
)
func TestMset(t *testing.T) {
conn := getLocalConnection()
defer conn.Close()
testCases := []struct {
name string
commands []s... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
defer keypoolMutex.Unlock()
if ok := delOperation(k); ok {
return true
}
return false
}
func DelByPtr(ptr unsafe.Pointer) bool {
storeMutex.Lock()
defer storeMutex.Unlock()
keypoolMutex.Lock()
defer keypoolMutex.Unlock()
if obj, ok := store[ptr]; ok {
delete(store, ptr)
delete(expires, obj)
delete(k... | No issues found. | defer keypoolMutex.Unlock()
if ok := delOperation(k); ok {
return true
}
return false
}
func DelByPtr(ptr unsafe.Pointer) bool {
storeMutex.Lock()
defer storeMutex.Unlock()
keypoolMutex.Lock()
defer keypoolMutex.Unlock()
if obj, ok := store[ptr]; ok {
delete(store, ptr)
delete(expires, obj)
delete(k... | @@ -66,24 +66,7 @@ func Put(k string, obj *Obj) {
keypoolMutex.Lock()
defer keypoolMutex.Unlock()
- if len(store) >= config.KeysLimit {
- evict()
- }
- obj.LastAccessedAt = getCurrentClock()
-
- ptr, ok := keypool[k]
- if !ok {
- keypool[k] = unsafe.Pointer(&k)
- ptr = unsafe.Pointer(&k)
- }
-
- store[ptr] = o... | core/store.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | #253: added RENAME Command | 262 | DiceDB/dice | 10,326 | C | rkarthick15 | Review this pull request change.
Language: Go
File: core/store.go
PR Title: #253: added RENAME Command
BEFORE CODE: defer keypoolMutex.Unlock()
if ok := delOperation(k); ok {
return true
}
return false
}
func DelByPtr(ptr unsafe.Pointer) bool {
storeMutex.Lock()
defer storeMutex.Unlock()
keypoolMutex.Loc... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
store.keypool[key] = unsafe.Pointer(obj)
},
input: []string{"EXISTING_KEY", "$.language"},
output: []byte("$5\r\narray\r\n"),
},
"string type value": {
setup: func() {
key := "EXISTING_KEY"
value := "{\"a\":\"test\"}"
var rootData interface{}
_ = sonic.Unmarshal([]byte(value), &roo... | No issues found. | store.keypool[key] = unsafe.Pointer(obj)
},
input: []string{"EXISTING_KEY", "$.language"},
output: []byte("$5\r\narray\r\n"),
},
"string type value": {
setup: func() {
key := "EXISTING_KEY"
value := "{\"a\":\"test\"}"
var rootData interface{}
_ = sonic.Unmarshal([]byte(value), &roo... | @@ -180,7 +180,6 @@ func testEvalGET(t *testing.T, store *Store) {
runEvalTests(t, tests, evalGET, store)
}
-
func testEvalEXPIRE(t *testing.T, store *Store) {
tests := map[string]evalTestCase{
"nil value": {
@@ -424,12 +423,12 @@ func testEvalJSONGET(t *testing.T, store *Store) {
"nil value": {
setup... | core/eval_test.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | #248: Standardize error messages across codebase | 288 | DiceDB/dice | 10,326 | C | lucifercr07 | Review this pull request change.
Language: Go
File: core/eval_test.go
PR Title: #248: Standardize error messages across codebase
BEFORE CODE: store.keypool[key] = unsafe.Pointer(obj)
},
input: []string{"EXISTING_KEY", "$.language"},
output: []byte("$5\r\narray\r\n"),
},
"string type value": {
... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
return Encode(s.Iterate(int(num)), false)
}
// evalQREFINS inserts the reference of the provided key identified by key
// first argument will be the key, that should be of type `QREF`
// second argument will be the key that needs to be added to the queueref
// if the queue does not exist, evalQREFINS will also create... | No issues found. | return Encode(s.Iterate(int(num)), false)
}
// evalQREFINS inserts the reference of the provided key identified by key
// first argument will be the key, that should be of type `QREF`
// second argument will be the key that needs to be added to the queueref
// if the queue does not exist, evalQREFINS will also create... | @@ -1768,3 +1768,111 @@ func evalPersist(args []string) []byte {
return RESP_ONE
}
+
+// GETEX key [EX seconds | PX milliseconds | EXAT unix-time-seconds |
+// PXAT unix-time-milliseconds | PERSIST]
+// Get the value of key and optionally set its expiration.
+// GETEX is similar to GET, but is a write command with... | core/eval.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | #275: Feature added: getex command with args support | 290 | DiceDB/dice | 10,326 | C | apoorvyadav1111 | Review this pull request change.
Language: Go
File: core/eval.go
PR Title: #275: Feature added: getex command with args support
BEFORE CODE: return Encode(s.Iterate(int(num)), false)
}
// evalQREFINS inserts the reference of the provided key identified by key
// first argument will be the key, that should be of t... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
import (
"testing"
"github.com/dicedb/dice/testutils"
"gotest.tools/v3/assert"
)
func TestMGET(t *testing.T) {
conn := getLocalConnection()
defer conn.Close()
testCases := []struct {
name string
commands []string
expected []interface{}
}{
{
name: "MGET With non-existing keys",
commands: [... | No issues found. | import (
"testing"
"github.com/dicedb/dice/testutils"
"gotest.tools/v3/assert"
)
func TestMGET(t *testing.T) {
conn := getLocalConnection()
defer conn.Close()
testCases := []struct {
name string
commands []string
expected []interface{}
}{
{
name: "MGET With non-existing keys",
commands: [... | @@ -0,0 +1,53 @@
+package tests
+
+import (
+ "testing"
+
+ "github.com/dicedb/dice/testutils"
+ "gotest.tools/v3/assert"
+)
+
+func TestMGET(t *testing.T) {
+ conn := getLocalConnection()
+ defer conn.Close()
+ testCases := []struct {
+ name string
+ commands []string
+ expected []interface{}
+ }{
+ {
+ name... | tests/mget_test.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | #251: Added support for MGET command. | 292 | DiceDB/dice | 10,326 | C | chanducheryala | Review this pull request change.
Language: Go
File: tests/mget_test.go
PR Title: #251: Added support for MGET command.
BEFORE CODE: import (
"testing"
"github.com/dicedb/dice/testutils"
"gotest.tools/v3/assert"
)
func TestMGET(t *testing.T) {
conn := getLocalConnection()
defer conn.Close()
testCases := []st... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
result, err := core.ExecuteQuery(query)
assert.NilError(t, err)
assert.Equal(t, len(result), 1, "Expected 1 result for comparison between key and value")
assert.Equal(t, result[0].Key, "k")
assert.DeepEqual(t, result[0].Value.Value, "k")
})
}
func TestExecuteQueryWithIncompatibleTypes(t *testing.T) {
set... | No issues found. |
result, err := core.ExecuteQuery(query)
assert.NilError(t, err)
assert.Equal(t, len(result), 1, "Expected 1 result for comparison between key and value")
assert.Equal(t, result[0].Key, "k")
assert.DeepEqual(t, result[0].Value.Value, "k")
})
}
func TestExecuteQueryWithIncompatibleTypes(t *testing.T) {
set... | @@ -1,9 +1,11 @@
package core_test
import (
+ "fmt"
"sort"
"testing"
+ "github.com/bytedance/sonic"
"github.com/dicedb/dice/core"
"github.com/dicedb/dice/internal/constants"
"github.com/xwb1989/sqlparser"
@@ -384,3 +386,162 @@ func TestExecuteQueryWithEdgeCases(t *testing.T) {
assert.Equal(t, len(res... | core/executor_test.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | #189 Add JSON Support to where clause | 300 | DiceDB/dice | 10,326 | C | YahyaHaq | Review this pull request change.
Language: Go
File: core/executor_test.go
PR Title: #189 Add JSON Support to where clause
BEFORE CODE:
result, err := core.ExecuteQuery(query)
assert.NilError(t, err)
assert.Equal(t, len(result), 1, "Expected 1 result for comparison between key and value")
assert.Equal(t, r... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
testCases := []struct {
name string
commands []string
expected []interface{}
}{
{
name: "COPY when source key doesn't exist",
commands: []string{"COPY k1 k2"},
expected: []interface{}{int64(0)},
},
{
name: "COPY with no REPLACE",
commands: []string{"SET k1 v1", "COPY k1 k2", "G... | No issues found. |
testCases := []struct {
name string
commands []string
expected []interface{}
}{
{
name: "COPY when source key doesn't exist",
commands: []string{"COPY k1 k2"},
expected: []interface{}{int64(0)},
},
{
name: "COPY with no REPLACE",
commands: []string{"SET k1 v1", "COPY k1 k2", "G... | @@ -0,0 +1,76 @@
+package tests
+
+import (
+ "testing"
+
+ "gotest.tools/v3/assert"
+)
+
+func TestCopy(t *testing.T) {
+ conn := getLocalConnection()
+ defer conn.Close()
+
+ simpleJSON := `{"name":"John","age":30}`
+
+ testCases := []struct {
+ name string
+ commands []string
+ expected []interface{}
+ }{
+ ... | tests/copy_test.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | Closes #277 Support for COPY command | 305 | DiceDB/dice | 10,326 | C | srivastava-yash | Review this pull request change.
Language: Go
File: tests/copy_test.go
PR Title: Closes #277 Support for COPY command
BEFORE CODE:
testCases := []struct {
name string
commands []string
expected []interface{}
}{
{
name: "COPY when source key doesn't exist",
commands: []string{"COPY k1 k2"},
... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
},
{
name: "NX on non-existing key",
commands: []string{"DEL k", "SET k v NX", "GET k"},
expected: []interface{}{int64(0), "OK", "v"},
},
{
name: "NX on existing key",
commands: []string{"DEL k", "SET k v NX", "GET k", "SET k v NX"},
expected: []interface{}{int64(0), "OK", "v", "(nil)"... | No issues found. | },
{
name: "NX on non-existing key",
commands: []string{"DEL k", "SET k v NX", "GET k"},
expected: []interface{}{int64(0), "OK", "v"},
},
{
name: "NX on existing key",
commands: []string{"DEL k", "SET k v NX", "GET k", "SET k v NX"},
expected: []interface{}{int64(0), "OK", "v", "(nil)"... | @@ -8,15 +8,17 @@ import (
"gotest.tools/v3/assert"
)
+type TestCase struct {
+ name string
+ commands []string
+ expected []interface{}
+}
+
func TestSet(t *testing.T) {
conn := getLocalConnection()
defer conn.Close()
- testCases := []struct {
- name string
- commands []string
- expected []inter... | tests/set_test.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | [Dice-206]: support `KEEPTTL` option for `SET` command | 318 | DiceDB/dice | 10,326 | C | kolharsam | Review this pull request change.
Language: Go
File: tests/set_test.go
PR Title: [Dice-206]: support `KEEPTTL` option for `SET` command
BEFORE CODE: },
{
name: "NX on non-existing key",
commands: []string{"DEL k", "SET k v NX", "GET k"},
expected: []interface{}{int64(0), "OK", "v"},
},
{
name... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
},
input: []string{"EXISTING_KEY"},
output: []byte("-the operation is not permitted on this type\r\n"),
},
"key exists value": {
setup: func() {
key := "EXISTING_KEY"
value := "{\"a\":2}"
var rootData interface{}
_ = sonic.Unmarshal([]byte(value), &rootData)
obj := NewObj(rootData, ... | No issues found. | },
input: []string{"EXISTING_KEY"},
output: []byte("-the operation is not permitted on this type\r\n"),
},
"key exists value": {
setup: func() {
key := "EXISTING_KEY"
value := "{\"a\":2}"
var rootData interface{}
_ = sonic.Unmarshal([]byte(value), &rootData)
obj := NewObj(rootData, ... | @@ -50,6 +50,7 @@ func TestEval(t *testing.T) {
"DEL": testEvalDel,
"PERSIST": TestEvalPersist,
"EXPIRETIME": testEvalEXPIRETIME,
+ "DBSIZE": testEvalDbsize,
}
for name, testFunc := range testCases {
@@ -476,6 +477,58 @@ func TestEvalPersist(t *testing.T) {
runEvalTests(t, tests, evalPer... | core/eval_test.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | #278: Add support for command `DBSIZE` | 328 | DiceDB/dice | 10,326 | C | raknay | Review this pull request change.
Language: Go
File: core/eval_test.go
PR Title: #278: Add support for command `DBSIZE`
BEFORE CODE: },
input: []string{"EXISTING_KEY"},
output: []byte("-the operation is not permitted on this type\r\n"),
},
"key exists value": {
setup: func() {
key := "EXISTING_K... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
},
expected: []interface{}{"OK", int64(1)},
delay: []time.Duration{0, 0},
},
{
name: "Check if key is nil after expiration",
setup: "SET test_key test_value",
commands: []string{
"EXPIREAT test_key " + strconv.FormatInt(time.Now().Unix()+1, 10),
"GET test_key",
},
expected: []int... | No issues found. | },
expected: []interface{}{"OK", int64(1)},
delay: []time.Duration{0, 0},
},
{
name: "Check if key is nil after expiration",
setup: "SET test_key test_value",
commands: []string{
"EXPIREAT test_key " + strconv.FormatInt(time.Now().Unix()+1, 10),
"GET test_key",
},
expected: []int... | @@ -0,0 +1,104 @@
+package tests
+
+import (
+ "strconv"
+ "testing"
+ "time"
+
+ "gotest.tools/v3/assert"
+)
+
+func TestExpireat(t *testing.T) {
+ conn := getLocalConnection()
+ defer conn.Close()
+
+ testCases := []struct {
+ name string
+ setup string
+ commands []string
+ expected []interface{}
+ delay... | tests/expireat_test.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | #283: Add support for command EXPIREAT | 338 | DiceDB/dice | 10,326 | C | ashwaniYDV | Review this pull request change.
Language: Go
File: tests/expireat_test.go
PR Title: #283: Add support for command EXPIREAT
BEFORE CODE: },
expected: []interface{}{"OK", int64(1)},
delay: []time.Duration{0, 0},
},
{
name: "Check if key is nil after expiration",
setup: "SET test_key test_value... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
},
"null type value": {
setup: func() {
key := "EXISTING_KEY"
value := "{\"price\":3.14}"
var rootData interface{}
_ = sonic.Unmarshal([]byte(value), &rootData)
obj := NewObj(rootData, -1, ObjTypeJSON, ObjEncodingJSON)
store[unsafe.Pointer(obj)] = obj
keypool[key] = unsafe.Pointer(obj... | No issues found. | },
"null type value": {
setup: func() {
key := "EXISTING_KEY"
value := "{\"price\":3.14}"
var rootData interface{}
_ = sonic.Unmarshal([]byte(value), &rootData)
obj := NewObj(rootData, -1, ObjTypeJSON, ObjEncodingJSON)
store[unsafe.Pointer(obj)] = obj
keypool[key] = unsafe.Pointer(obj... | @@ -44,6 +44,7 @@ func TestEval(t *testing.T) {
"HELLO": testEvalHELLO,
"SET": testEvalSET,
"GET": testEvalGET,
+ "JSONTYPE": testEvalJSONTYPE,
"JSONGET": testEvalJSONGET,
"JSONSET": testEvalJSONSET,
"TTL": testEvalTTL,
@@ -224,6 +225,126 @@ func testEvalEXPIRETIME(t... | core/eval_test.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | #342: feat: add support for json.type command | 344 | DiceDB/dice | 10,326 | C | jujiale | Review this pull request change.
Language: Go
File: core/eval_test.go
PR Title: #342: feat: add support for json.type command
BEFORE CODE: },
"null type value": {
setup: func() {
key := "EXISTING_KEY"
value := "{\"price\":3.14}"
var rootData interface{}
_ = sonic.Unmarshal([]byte(value), &roo... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
expected: []interface{}{"OK", int64(1)},
delay: []time.Duration{0, 0},
},
{
name: "Check if key is nil after expiration",
setup: "SET test_key test_value",
commands: []string{
"EXPIRE test_key 1",
"GET test_key",
},
expected: []interface{}{int64(1), "(nil)"},
delay: []time.Dur... | No issues found. | expected: []interface{}{"OK", int64(1)},
delay: []time.Duration{0, 0},
},
{
name: "Check if key is nil after expiration",
setup: "SET test_key test_value",
commands: []string{
"EXPIRE test_key 1",
"GET test_key",
},
expected: []interface{}{int64(1), "(nil)"},
delay: []time.Dur... | @@ -0,0 +1,103 @@
+package tests
+
+import (
+ "testing"
+ "time"
+
+ "gotest.tools/v3/assert"
+)
+
+func TestExpire(t *testing.T) {
+ conn := getLocalConnection()
+ defer conn.Close()
+
+ testCases := []struct {
+ name string
+ setup string
+ commands []string
+ expected []interface{}
+ delay []time.Dur... | tests/expire_test.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | #361: Added unit test and integration test for EXPIRE, EXPIRETIME commands | 362 | DiceDB/dice | 10,326 | C | ashwaniYDV | Review this pull request change.
Language: Go
File: tests/expire_test.go
PR Title: #361: Added unit test and integration test for EXPIRE, EXPIRETIME commands
BEFORE CODE: expected: []interface{}{"OK", int64(1)},
delay: []time.Duration{0, 0},
},
{
name: "Check if key is nil after expiration",
set... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
"gotest.tools/v3/assert"
)
func IsJSONResponse(s string) bool {
return (s != constants.EmptyStr && (sonic.ValidString(s)))
}
func AssertJSONEqual(t *testing.T, expected, actual string) {
if !compareJSONs(t, expected, actual) {
t.Errorf("JSON not equal.\nExpected: %s\nActual: %s", expected, actual)
}
}
func Ass... | No issues found. | "gotest.tools/v3/assert"
)
func IsJSONResponse(s string) bool {
return (s != constants.EmptyStr && (sonic.ValidString(s)))
}
func AssertJSONEqual(t *testing.T, expected, actual string) {
if !compareJSONs(t, expected, actual) {
t.Errorf("JSON not equal.\nExpected: %s\nActual: %s", expected, actual)
}
}
func Ass... | @@ -10,10 +10,30 @@ import (
)
func IsJSONResponse(s string) bool {
- return (s != constants.EmptyStr && (s[0] == '{' || s[0] == '['))
+ return (s != constants.EmptyStr && (sonic.ValidString(s)))
}
func AssertJSONEqual(t *testing.T, expected, actual string) {
+ if !compareJSONs(t, expected, actual) {
+ t.Error... | testutils/json.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | Fixed flaky tests due to json ordering | 365 | DiceDB/dice | 10,326 | C | VedWhat | Review this pull request change.
Language: Go
File: testutils/json.go
PR Title: Fixed flaky tests due to json ordering
BEFORE CODE: "gotest.tools/v3/assert"
)
func IsJSONResponse(s string) bool {
return (s != constants.EmptyStr && (sonic.ValidString(s)))
}
func AssertJSONEqual(t *testing.T, expected, actual str... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
var rootData interface{}
_ = sonic.Unmarshal([]byte(value), &rootData)
obj := store.NewObj(rootData, -1, ObjTypeJSON, ObjEncodingJSON)
store.store[key] = obj
store.keypool[key] = &key
},
input: []string{"EXISTING_KEY", "$.a"},
output: []byte("*1\r\n$6\r\nstring\r\n"),
},
"boolean type... | No issues found. | var rootData interface{}
_ = sonic.Unmarshal([]byte(value), &rootData)
obj := store.NewObj(rootData, -1, ObjTypeJSON, ObjEncodingJSON)
store.store[key] = obj
store.keypool[key] = &key
},
input: []string{"EXISTING_KEY", "$.a"},
output: []byte("*1\r\n$6\r\nstring\r\n"),
},
"boolean type... | @@ -4,13 +4,14 @@ import (
"bytes"
"errors"
"fmt"
- "github.com/bytedance/sonic"
- "github.com/dicedb/dice/internal/constants"
- "gotest.tools/v3/assert"
"strconv"
"strings"
"testing"
"time"
+
+ "github.com/bytedance/sonic"
+ "github.com/dicedb/dice/internal/constants"
+ "gotest.tools/v3/assert"
)
typ... | core/eval_test.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | #255: Implement `HSET` command | 373 | DiceDB/dice | 10,326 | C | kolharsam | Review this pull request change.
Language: Go
File: core/eval_test.go
PR Title: #255: Implement `HSET` command
BEFORE CODE: var rootData interface{}
_ = sonic.Unmarshal([]byte(value), &rootData)
obj := store.NewObj(rootData, -1, ObjTypeJSON, ObjEncodingJSON)
store.store[key] = obj
store.keypool[... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
"time"
"gotest.tools/v3/assert"
)
func TestGetSet(t *testing.T) {
conn := getLocalConnection()
defer conn.Close()
testCases := []struct {
name string
cmds []string
expect []interface{}
delays []time.Duration
}{
{
name: "GETSET with INCR",
cmds: []string{"INCR mycounter", "GETSET mycount... | No issues found. | "time"
"gotest.tools/v3/assert"
)
func TestGetSet(t *testing.T) {
conn := getLocalConnection()
defer conn.Close()
testCases := []struct {
name string
cmds []string
expect []interface{}
delays []time.Duration
}{
{
name: "GETSET with INCR",
cmds: []string{"INCR mycounter", "GETSET mycount... | @@ -0,0 +1,57 @@
+package tests
+
+import (
+ "testing"
+ "time"
+
+ "gotest.tools/v3/assert"
+)
+
+func TestGetSet(t *testing.T) {
+ conn := getLocalConnection()
+ defer conn.Close()
+
+ testCases := []struct {
+ name string
+ cmds []string
+ expect []interface{}
+ delays []time.Duration
+ }{
+ {
+ name: ... | tests/getset_test.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | #276: GETSET command implementation | 377 | DiceDB/dice | 10,326 | C | lucifercr07 | Review this pull request change.
Language: Go
File: tests/getset_test.go
PR Title: #276: GETSET command implementation
BEFORE CODE: "time"
"gotest.tools/v3/assert"
)
func TestGetSet(t *testing.T) {
conn := getLocalConnection()
defer conn.Close()
testCases := []struct {
name string
cmds []string
ex... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
package server
import (
"io"
"strings"
"github.com/dicedb/dice/core"
"github.com/dicedb/dice/server/utils"
)
func toArrayString(ai []interface{}) []string {
as := make([]string, len(ai))
for i := range ai {
as[i] = ai[i].(string)
}
return as
}
func readCommands(c io.ReadWriter) (core.RedisCmds, bool, erro... | No issues found. | package server
import (
"io"
"strings"
"github.com/dicedb/dice/core"
"github.com/dicedb/dice/server/utils"
)
func toArrayString(ai []interface{}) []string {
as := make([]string, len(ai))
for i := range ai {
as[i] = ai[i].(string)
}
return as
}
func readCommands(c io.ReadWriter) (core.RedisCmds, bool, erro... | @@ -5,6 +5,7 @@ import (
"strings"
"github.com/dicedb/dice/core"
+ "github.com/dicedb/dice/server/utils"
)
func toArrayString(ai []interface{}) []string {
@@ -28,6 +29,7 @@ func readCommands(c io.ReadWriter) (core.RedisCmds, bool, error) {
tokens := toArrayString(value.([]interface{}))
cmd := strings.To... | server/sync_tcp.go | 0 | Go | 1 | none | 16 | 47 | 47 | true | Temporarily assigning ID to every incoming command | 384 | DiceDB/dice | 10,326 | C | arpitbbhayani | Review this pull request change.
Language: Go
File: server/sync_tcp.go
PR Title: Temporarily assigning ID to every incoming command
BEFORE CODE: package server
import (
"io"
"strings"
"github.com/dicedb/dice/core"
"github.com/dicedb/dice/server/utils"
)
func toArrayString(ai []interface{}) []string {
as := ... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
returns the array of integers as the response.
if the key does not exist, then we return an empty array`,
Eval: evalSTACKINTPEEK,
Arity: 2,
KeySpecs: KeySpecs{BeginIndex: 1, Step: 1},
}
stackrefpushCmdMeta = DiceCmdMeta{
Name: "STACKREFPUSH",
Info: `STACKREFPUSH inserts the reference of the provi... | No issues found. | returns the array of integers as the response.
if the key does not exist, then we return an empty array`,
Eval: evalSTACKINTPEEK,
Arity: 2,
KeySpecs: KeySpecs{BeginIndex: 1, Step: 1},
}
stackrefpushCmdMeta = DiceCmdMeta{
Name: "STACKREFPUSH",
Info: `STACKREFPUSH inserts the reference of the provi... | @@ -618,6 +618,12 @@ var (
Eval: evalDBSIZE,
Arity: 1,
}
+ flushdbCmdMeta = DiceCmdMeta{
+ Name: "FLUSHDB",
+ Info: `FLUSHDB deletes all the keys of the currently selected DB`,
+ Eval: evalFLUSHDB,
+ Arity: -1,
+ }
bitposCmdMeta = DiceCmdMeta{
Name: "BITPOS",
Info: `BITPOS returns the position ... | core/commands.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | Added support for FLUSHDB command | 390 | DiceDB/dice | 10,326 | C | ashwaniYDV | Review this pull request change.
Language: Go
File: core/commands.go
PR Title: Added support for FLUSHDB command
BEFORE CODE: returns the array of integers as the response.
if the key does not exist, then we return an empty array`,
Eval: evalSTACKINTPEEK,
Arity: 2,
KeySpecs: KeySpecs{BeginIndex: 1,... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
qr.Insert("key3", store)
mockTime.SetTime(time.Now().Add(2 * time.Millisecond))
fmt.Printf("Queue size : %d\n", qr.Length(store))
qe, err := qr.Remove(store)
assert.Check(t, err == nil || qe.Obj.Value == val[2], fmt.Sprintf("test for removing mulitple expired key before non-expired failed , Expected : %d, Got %d\n... | No issues found. | qr.Insert("key3", store)
mockTime.SetTime(time.Now().Add(2 * time.Millisecond))
fmt.Printf("Queue size : %d\n", qr.Length(store))
qe, err := qr.Remove(store)
assert.Check(t, err == nil || qe.Obj.Value == val[2], fmt.Sprintf("test for removing mulitple expired key before non-expired failed , Expected : %d, Got %d\n... | @@ -14,7 +14,10 @@ import (
)
func TestQueueRef(t *testing.T) {
- qr := core.NewQueueRef()
+ qr, err := core.NewQueueRef()
+ if err != nil {
+ t.Fatal(err)
+ }
store := core.NewStore()
if _, err := qr.Remove(store); err != core.ErrQueueEmpty {
@@ -66,7 +69,10 @@ func TestQueueRef(t *testing.T) {
// Test f... | core/queueref_test.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | #285: Fix: STACKREFLEN and QUEUEREFLEN is not aware of the deletion of key | 393 | DiceDB/dice | 10,326 | C | kushal0511-not | Review this pull request change.
Language: Go
File: core/queueref_test.go
PR Title: #285: Fix: STACKREFLEN and QUEUEREFLEN is not aware of the deletion of key
BEFORE CODE: qr.Insert("key3", store)
mockTime.SetTime(time.Now().Add(2 * time.Millisecond))
fmt.Printf("Queue size : %d\n", qr.Length(store))
qe, err :... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
package server
import (
"io"
"strings"
"github.com/dicedb/dice/core"
)
func toArrayString(ai []interface{}) []string {
as := make([]string, len(ai))
for i := range ai {
as[i] = ai[i].(string)
}
return as
}
func readCommands(c io.ReadWriter) (core.RedisCmds, bool, error) {
var hasABORT bool = false
rp := ... | No issues found. | package server
import (
"io"
"strings"
"github.com/dicedb/dice/core"
)
func toArrayString(ai []interface{}) []string {
as := make([]string, len(ai))
for i := range ai {
as[i] = ai[i].(string)
}
return as
}
func readCommands(c io.ReadWriter) (core.RedisCmds, bool, error) {
var hasABORT bool = false
rp := ... | @@ -5,7 +5,6 @@ import (
"strings"
"github.com/dicedb/dice/core"
- "github.com/dicedb/dice/server/utils"
)
func toArrayString(ai []interface{}) []string {
@@ -29,7 +28,7 @@ func readCommands(c io.ReadWriter) (core.RedisCmds, bool, error) {
tokens := toArrayString(value.([]interface{}))
cmd := strings.To... | server/sync_tcp.go | 0 | Go | 1 | none | 16 | 46 | 46 | true | The new ID implementation | 396 | DiceDB/dice | 10,326 | C | arpitbbhayani | Review this pull request change.
Language: Go
File: server/sync_tcp.go
PR Title: The new ID implementation
BEFORE CODE: package server
import (
"io"
"strings"
"github.com/dicedb/dice/core"
)
func toArrayString(ai []interface{}) []string {
as := make([]string, len(ai))
for i := range ai {
as[i] = ai[i].(st... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
setup: "",
commands: []string{
"SET test_key test_value",
"EXPIRE test_key " + strconv.FormatInt(10, 10) + " GT",
"EXPIRE test_key " + strconv.FormatInt(10, 10),
"EXPIRE test_key " + strconv.FormatInt(20, 10) + " GT",
},
expected: []interface{}{"OK", int64(0), int64(1), int64(1)},
delay: ... | No issues found. | setup: "",
commands: []string{
"SET test_key test_value",
"EXPIRE test_key " + strconv.FormatInt(10, 10) + " GT",
"EXPIRE test_key " + strconv.FormatInt(10, 10),
"EXPIRE test_key " + strconv.FormatInt(20, 10) + " GT",
},
expected: []interface{}{"OK", int64(0), int64(1), int64(1)},
delay: ... | @@ -1,6 +1,7 @@
package tests
import (
+ "strconv"
"testing"
"time"
@@ -66,6 +67,143 @@ func TestExpire(t *testing.T) {
expected: []interface{}{"ERR wrong number of arguments for 'expire' command"},
delay: []time.Duration{0},
},
+ {
+ name: "Test(XX): Set the expiration only if the key has n... | tests/expire_test.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | #355: FEAT: Added support for additional options in EXPIRE and EXPIREAT. | 403 | DiceDB/dice | 10,326 | C | raghavbabbar | Review this pull request change.
Language: Go
File: tests/expire_test.go
PR Title: #355: FEAT: Added support for additional options in EXPIRE and EXPIREAT.
BEFORE CODE: setup: "",
commands: []string{
"SET test_key test_value",
"EXPIRE test_key " + strconv.FormatInt(10, 10) + " GT",
"EXPIRE test_ke... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
input: nil,
output: []byte("-ERR wrong number of arguments for 'json.type' command\r\n"),
},
"empty array": {
setup: func() {},
input: []string{},
output: []byte("-ERR wrong number of arguments for 'json.type' command\r\n"),
},
"key does not exist": {
setup: func() {},
input: []string{... | No issues found. | input: nil,
output: []byte("-ERR wrong number of arguments for 'json.type' command\r\n"),
},
"empty array": {
setup: func() {},
input: []string{},
output: []byte("-ERR wrong number of arguments for 'json.type' command\r\n"),
},
"key does not exist": {
setup: func() {},
input: []string{... | @@ -43,6 +43,7 @@ func TestEval(t *testing.T) {
testEvalHELLO(t, store)
testEvalSET(t, store)
testEvalGET(t, store)
+ testEvalJSONCLEAR(t, store)
testEvalJSONTYPE(t, store)
testEvalJSONGET(t, store)
testEvalJSONSET(t, store)
@@ -297,17 +298,135 @@ func testEvalEXPIREAT(t *testing.T, store *Store) {
runEva... | core/eval_test.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | #371: feat: add support for command [JSON.CLEAR] | 405 | DiceDB/dice | 10,326 | C | jujiale | Review this pull request change.
Language: Go
File: core/eval_test.go
PR Title: #371: feat: add support for command [JSON.CLEAR]
BEFORE CODE: input: nil,
output: []byte("-ERR wrong number of arguments for 'json.type' command\r\n"),
},
"empty array": {
setup: func() {},
input: []string{},
outp... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
// ByteSliceToIntObj converts a byte slice to an Obj with an integer value
func ByteSliceToIntObj(store *Store, oldObj *Obj, b []byte) (*Obj, error) {
intVal, err := strconv.ParseInt(string(b), 10, 64)
if err != nil {
return nil, fmt.Errorf("failed to parse byte slice to int: %v", err)
}
return store.NewObj(intV... | No issues found. |
// ByteSliceToIntObj converts a byte slice to an Obj with an integer value
func ByteSliceToIntObj(store *Store, oldObj *Obj, b []byte) (*Obj, error) {
intVal, err := strconv.ParseInt(string(b), 10, 64)
if err != nil {
return nil, fmt.Errorf("failed to parse byte slice to int: %v", err)
}
return store.NewObj(intV... | @@ -1,5 +1,11 @@
package core
+import (
+ "errors"
+ "fmt"
+ "strconv"
+)
+
type ByteArray struct {
data []byte
Length int64
@@ -13,6 +19,107 @@ func NewByteArray(size int) *ByteArray {
}
}
+func NewByteArrayFromObj(obj *Obj) (*ByteArray, error) {
+ b, err := getValueAsByteSlice(obj)
+ if err != nil {
+ ... | core/bytearray.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | #386: Fix SETBIT command for encoding | 409 | DiceDB/dice | 10,326 | C | kushal0511-not | Review this pull request change.
Language: Go
File: core/bytearray.go
PR Title: #386: Fix SETBIT command for encoding
BEFORE CODE:
// ByteSliceToIntObj converts a byte slice to an Obj with an integer value
func ByteSliceToIntObj(store *Store, oldObj *Obj, b []byte) (*Obj, error) {
intVal, err := strconv.ParseInt... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
DialTimeout: 10 * time.Second,
ReadTimeout: 30 * time.Second,
WriteTimeout: 30 * time.Second,
ContextTimeoutEnabled: true,
MaxRetries: -1,
PoolSize: 10,
PoolTimeout: 30 * time.Second,
ConnMaxIdleTime: time.Minute,
})
}
//nolint:unused
func fireCommand(conn ne... | No issues found. |
DialTimeout: 10 * time.Second,
ReadTimeout: 30 * time.Second,
WriteTimeout: 30 * time.Second,
ContextTimeoutEnabled: true,
MaxRetries: -1,
PoolSize: 10,
PoolTimeout: 30 * time.Second,
ConnMaxIdleTime: time.Minute,
})
}
//nolint:unused
func fireCommand(conn ne... | @@ -1,6 +1,8 @@
package tests
import (
+ "context"
+ "errors"
"fmt"
"io"
"net"
@@ -88,29 +90,45 @@ func runTestServer(wg *sync.WaitGroup) {
config.IOBufferLength = 16
config.Port = 8739
- totalRetries := 100
- serverFD := 0
+ const totalRetries = 100
var err error
+ // Initialize the AsyncServer
+ t... | tests/setup.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | Reorganize async server code | 410 | DiceDB/dice | 10,326 | C | JyotinderSingh | Review this pull request change.
Language: Go
File: tests/setup.go
PR Title: Reorganize async server code
BEFORE CODE:
DialTimeout: 10 * time.Second,
ReadTimeout: 30 * time.Second,
WriteTimeout: 30 * time.Second,
ContextTimeoutEnabled: true,
MaxRetries: -1,
PoolSize: ... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
delay: []time.Duration{0, 0},
},
{
name: "GETDEL a key holding a set",
cmd: []string{"SADD foo bar", "GETDEL foo"},
expected: []interface{}{int64(1), setErrorMsg},
assert_type: []string{"equal", "equal"},
delay: []time.Duration{0, 0},
},
{
name: "INCR a ... | No issues found. | delay: []time.Duration{0, 0},
},
{
name: "GETDEL a key holding a set",
cmd: []string{"SADD foo bar", "GETDEL foo"},
expected: []interface{}{int64(1), setErrorMsg},
assert_type: []string{"equal", "equal"},
delay: []time.Duration{0, 0},
},
{
name: "INCR a ... | @@ -0,0 +1,103 @@
+package tests
+
+import (
+ "testing"
+ "time"
+
+ "gotest.tools/v3/assert"
+)
+
+// this file may contain test cases for checking error messages accross all commands
+func TestErrorsForSetData(t *testing.T) {
+ conn := getLocalConnection()
+ defer conn.Close()
+
+ setErrorMsg := "WRONGTYPE Operation... | tests/check_type_test.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | #411: Add asserts checking non-set commands: addresses #411 | 413 | DiceDB/dice | 10,326 | C | apoorvyadav1111 | Review this pull request change.
Language: Go
File: tests/check_type_test.go
PR Title: #411: Add asserts checking non-set commands: addresses #411
BEFORE CODE: delay: []time.Duration{0, 0},
},
{
name: "GETDEL a key holding a set",
cmd: []string{"SADD foo bar", "GETDEL foo"},
exp... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
}
}(s.serverFD)
if err := s.SetupUsers(); err != nil {
return err
}
watchCtx, cancelWatch := context.WithCancel(ctx)
defer cancelWatch()
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
s.queryWatcher.Run(watchCtx)
}()
if err := syscall.Listen(s.serverFD, s.maxClients); err != nil {
r... | No issues found. | }
}(s.serverFD)
if err := s.SetupUsers(); err != nil {
return err
}
watchCtx, cancelWatch := context.WithCancel(ctx)
defer cancelWatch()
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
s.queryWatcher.Run(watchCtx)
}()
if err := syscall.Listen(s.serverFD, s.maxClients); err != nil {
r... | @@ -27,16 +27,19 @@ type AsyncServer struct {
multiplexerPollTimeout time.Duration
connectedClients map[int]*core.Client
store *core.Store
+ queryWatcher *core.QueryWatcher
lastCronExecTime time.Time
cronFrequency time.Duration
}
// NewAsyncServer initialize... | server/async_tcp.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | Move QWATCH logic to QueryWatcher | 416 | DiceDB/dice | 10,326 | C | JyotinderSingh | Review this pull request change.
Language: Go
File: server/async_tcp.go
PR Title: Move QWATCH logic to QueryWatcher
BEFORE CODE: }
}(s.serverFD)
if err := s.SetupUsers(); err != nil {
return err
}
watchCtx, cancelWatch := context.WithCancel(ctx)
defer cancelWatch()
var wg sync.WaitGroup
wg.Add(1)
go ... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
q := obj.Value.(*QueueRef)
return Encode(q.Length(store), false)
}
// evalSTACKREFLEN returns the length of the STACKREF identified by key
// returns the integer value indicating the length of the stack
// if the key does not exist, the response is 0
func evalSTACKREFLEN(args []string, store *Store) []byte {
if len... | No issues found. | q := obj.Value.(*QueueRef)
return Encode(q.Length(store), false)
}
// evalSTACKREFLEN returns the length of the STACKREF identified by key
// returns the integer value indicating the length of the stack
// if the key does not exist, the response is 0
func evalSTACKREFLEN(args []string, store *Store) []byte {
if len... | @@ -11,14 +11,14 @@ import (
"syscall"
"time"
- "github.com/cockroachdb/swiss"
- "github.com/dicedb/dice/core/auth"
- "github.com/dicedb/dice/core/comm"
-
+ "github.com/axiomhq/hyperloglog"
"github.com/bytedance/sonic"
"github.com/charmbracelet/log"
+ "github.com/cockroachdb/swiss"
"github.com/dicedb/dice/c... | core/eval.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | #238: PFADD/PFCOUNT implementation | 422 | DiceDB/dice | 10,326 | C | lucifercr07 | Review this pull request change.
Language: Go
File: core/eval.go
PR Title: #238: PFADD/PFCOUNT implementation
BEFORE CODE: q := obj.Value.(*QueueRef)
return Encode(q.Length(store), false)
}
// evalSTACKREFLEN returns the length of the STACKREF identified by key
// returns the integer value indicating the length ... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
func FireCommand(conn net.Conn, cmd string) interface{} {
var err error
args := testutils.ParseCommand(cmd)
_, err = conn.Write(clientio.Encode(args, false))
if err != nil {
slog.Error(
"error while firing command",
slog.Any("error", err),
slog.String("command", cmd),
)
os.Exit(1)
}
rp := clientio... | No issues found. | func FireCommand(conn net.Conn, cmd string) interface{} {
var err error
args := testutils.ParseCommand(cmd)
_, err = conn.Write(clientio.Encode(args, false))
if err != nil {
slog.Error(
"error while firing command",
slog.Any("error", err),
slog.String("command", cmd),
)
os.Exit(1)
}
rp := clientio... | @@ -24,8 +24,9 @@ import (
)
type TestServerOptions struct {
- Port int
- Logger *slog.Logger
+ Port int
+ Logger *slog.Logger
+ MaxClients int
}
//nolint:unused
@@ -112,12 +113,17 @@ func fireCommandAndGetRESPParser(conn net.Conn, cmd string) *clientio.RESPParser
func RunTestServer(ctx context.Con... | integration_tests/commands/async/setup.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | #415: Adding check for controlling the max TCP connections | 426 | DiceDB/dice | 10,326 | C | ayush571995 | Review this pull request change.
Language: Go
File: integration_tests/commands/async/setup.go
PR Title: #415: Adding check for controlling the max TCP connections
BEFORE CODE: func FireCommand(conn net.Conn, cmd string) interface{} {
var err error
args := testutils.ParseCommand(cmd)
_, err = conn.Write(clientio.... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
}{
{
name: "Set Invalid JSON",
command: `JSON.SET invalid $ {invalid:json}`,
expected: "ERR invalid JSON",
},
{
name: "Set JSON with Wrong Number of Arguments",
command: `JSON.SET`,
expected: "ERR wrong number of arguments for 'json.set' command",
},
}
for _, tc := range testCase... | No issues found. | }{
{
name: "Set Invalid JSON",
command: `JSON.SET invalid $ {invalid:json}`,
expected: "ERR invalid JSON",
},
{
name: "Set JSON with Wrong Number of Arguments",
command: `JSON.SET`,
expected: "ERR wrong number of arguments for 'json.set' command",
},
}
for _, tc := range testCase... | @@ -91,7 +91,7 @@ func TestJSONOperations(t *testing.T) {
name: "Set Non-JSON Value",
setCmd: `SET nonJson "not a json"`,
getCmd: `JSON.GET nonJson`,
- expected: "the operation is not permitted on this type",
+ expected: "ERR Existing key has wrong Dice type",
},
{
name: "Set Empty... | tests/json_test.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | #419: feat: add support for command [JSON.DEL] | 428 | DiceDB/dice | 10,326 | C | jujiale | Review this pull request change.
Language: Go
File: tests/json_test.go
PR Title: #419: feat: add support for command [JSON.DEL]
BEFORE CODE: }{
{
name: "Set Invalid JSON",
command: `JSON.SET invalid $ {invalid:json}`,
expected: "ERR invalid JSON",
},
{
name: "Set JSON with Wrong Number o... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
KeySpecs: KeySpecs{BeginIndex: 1, Step: 1},
}
// TODO: Remove this override once we support QWATCH in dice-cli.
subscribeCmdMeta = DiceCmdMeta{
Name: "SUBSCRIBE",
Info: `SUBSCRIBE(or QWATCH) adds the specified key to the watch list for the caller client.
Every time a key in the watch list is modified, the cl... | No issues found. | KeySpecs: KeySpecs{BeginIndex: 1, Step: 1},
}
// TODO: Remove this override once we support QWATCH in dice-cli.
subscribeCmdMeta = DiceCmdMeta{
Name: "SUBSCRIBE",
Info: `SUBSCRIBE(or QWATCH) adds the specified key to the watch list for the caller client.
Every time a key in the watch list is modified, the cl... | @@ -584,6 +584,14 @@ var (
Arity: -4,
KeySpecs: KeySpecs{BeginIndex: 1},
}
+ hgetAllCmdMeta = DiceCmdMeta{
+ Name: "HGETALL",
+ Info: `Returns all fields and values of the hash stored at key. In the returned value,
+ every field name is followed by its value, so the length of the reply is twice the ... | core/commands.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | #257: Feat: Added support for HGETALL | 431 | DiceDB/dice | 10,326 | C | raghavbabbar | Review this pull request change.
Language: Go
File: core/commands.go
PR Title: #257: Feat: Added support for HGETALL
BEFORE CODE: KeySpecs: KeySpecs{BeginIndex: 1, Step: 1},
}
// TODO: Remove this override once we support QWATCH in dice-cli.
subscribeCmdMeta = DiceCmdMeta{
Name: "SUBSCRIBE",
Info: `SUBSCRI... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
qwatchQuery: "SELECT $key, $value WHERE $key like 'match:200:user:0' AND '$value.name' = 'Tom'",
expectedUpdates: [][]interface{}{
{[]interface{}{"match:200:user:0", map[string]interface{}{"name": "Tom"}}},
},
},
{
key: "match:200:user:1",
value: `{"name":"Tom","age":24}`,
qwatchQuery: "S... | No issues found. | qwatchQuery: "SELECT $key, $value WHERE $key like 'match:200:user:0' AND '$value.name' = 'Tom'",
expectedUpdates: [][]interface{}{
{[]interface{}{"match:200:user:0", map[string]interface{}{"name": "Tom"}}},
},
},
{
key: "match:200:user:1",
value: `{"name":"Tom","age":24}`,
qwatchQuery: "S... | @@ -3,13 +3,13 @@ package commands
import (
"context"
"fmt"
- "github.com/dicedb/dice/internal/sql"
"net"
"testing"
"time"
"github.com/bytedance/sonic"
"github.com/dicedb/dice/internal/clientio"
+ "github.com/dicedb/dice/internal/sql"
redis "github.com/dicedb/go-dice"
"gotest.tools/v3/assert"
)
@@... | integration_tests/commands/qwatch_test.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | QWATCH tests failing on multiple runs | 456 | DiceDB/dice | 10,326 | C | VedWhat | Review this pull request change.
Language: Go
File: integration_tests/commands/qwatch_test.go
PR Title: QWATCH tests failing on multiple runs
BEFORE CODE: qwatchQuery: "SELECT $key, $value WHERE $key like 'match:200:user:0' AND '$value.name' = 'Tom'",
expectedUpdates: [][]interface{}{
{[]interface{}{"match:... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
}
// if object is a set type, return error
if dstore.AssertType(obj.TypeEncoding, dstore.ObjTypeSet) == nil {
return diceerrors.NewErrWithFormattedMessage(diceerrors.WrongTypeErr)
}
requiredByteArraySize := offset/8 + 1
// handle the case when it is string
if dstore.AssertType(obj.TypeEncoding, dstore.ObjTyp... | No issues found. | }
// if object is a set type, return error
if dstore.AssertType(obj.TypeEncoding, dstore.ObjTypeSet) == nil {
return diceerrors.NewErrWithFormattedMessage(diceerrors.WrongTypeErr)
}
requiredByteArraySize := offset/8 + 1
// handle the case when it is string
if dstore.AssertType(obj.TypeEncoding, dstore.ObjTyp... | @@ -1502,7 +1502,7 @@ func evalBITOP(args []string, store *dstore.Store) []byte {
// COUNT: return total count of commands in Dice.
func evalCommand(args []string, store *dstore.Store) []byte {
if len(args) == 0 {
- return diceerrors.NewErrArity("COMMAND")
+ return evalCommandDefault()
}
subcommand := strings... | internal/eval/eval.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | Added support for COMMAND command | 458 | DiceDB/dice | 10,326 | C | aashraybhandar1 | Review this pull request change.
Language: Go
File: internal/eval/eval.go
PR Title: Added support for COMMAND command
BEFORE CODE: }
// if object is a set type, return error
if dstore.AssertType(obj.TypeEncoding, dstore.ObjTypeSet) == nil {
return diceerrors.NewErrWithFormattedMessage(diceerrors.WrongTypeErr)
... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
key: "match:200:user:0",
value: `{"name":"Tom"}`,
qwatchQuery: "SELECT $key, $value FROM `match:200:user:0` WHERE '$value.name' = 'Tom'",
expectedUpdates: [][]interface{}{
{[]interface{}{"match:200:user:0", map[string]interface{}{"name": "Tom"}}},
},
},
{
key: "match:200:user:1",
... | No issues found. | key: "match:200:user:0",
value: `{"name":"Tom"}`,
qwatchQuery: "SELECT $key, $value FROM `match:200:user:0` WHERE '$value.name' = 'Tom'",
expectedUpdates: [][]interface{}{
{[]interface{}{"match:200:user:0", map[string]interface{}{"name": "Tom"}}},
},
},
{
key: "match:200:user:1",
... | @@ -15,6 +15,7 @@ import (
)
type qWatchTestCase struct {
+ key string
userID int
score int
expectedUpdates [][]interface{}
@@ -25,37 +26,37 @@ type qWatchSDKSubscriber struct {
qwatch *redis.QWatch
}
-var qWatchQuery = "SELECT $key, $value FROM `match:100:*` ORDER BY $valu... | tests/qwatch_test.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | #469: Add support for common cache per fingerprint in QWATCH | 473 | DiceDB/dice | 10,326 | C | pratikpandey21 | Review this pull request change.
Language: Go
File: tests/qwatch_test.go
PR Title: #469: Add support for common cache per fingerprint in QWATCH
BEFORE CODE: key: "match:200:user:0",
value: `{"name":"Tom"}`,
qwatchQuery: "SELECT $key, $value FROM `match:200:user:0` WHERE '$value.name' = 'Tom'",
... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
setup: "",
commands: []string{
"SET test_key test_value",
"EXPIRE test_key " + strconv.FormatInt(10, 10) + " GT",
"TTL test_key",
"EXPIRE test_key " + strconv.FormatInt(10, 10),
"EXPIRE test_key " + strconv.FormatInt(20, 10) + " GT",
},
expected: []interface{}{"OK", int64(0), int64(-1), ... | No issues found. | setup: "",
commands: []string{
"SET test_key test_value",
"EXPIRE test_key " + strconv.FormatInt(10, 10) + " GT",
"TTL test_key",
"EXPIRE test_key " + strconv.FormatInt(10, 10),
"EXPIRE test_key " + strconv.FormatInt(20, 10) + " GT",
},
expected: []interface{}{"OK", int64(0), int64(-1), ... | @@ -68,7 +68,7 @@ func TestExpire(t *testing.T) {
delay: []time.Duration{0},
},
{
- name: "Test(XX): Set the expiration only if the key has no expiration time",
+ name: "Test(NX): Set the expiration only if the key has no expiration time",
setup: "",
commands: []string{
"SET test_key tes... | tests/expire_test.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | Fixes inconsistent EXPIRE when ran with flags XX, LT-XX and GT on a key without ttl | 513 | DiceDB/dice | 10,326 | C | jainam2907 | Review this pull request change.
Language: Go
File: tests/expire_test.go
PR Title: Fixes inconsistent EXPIRE when ran with flags XX, LT-XX and GT on a key without ttl
BEFORE CODE: setup: "",
commands: []string{
"SET test_key test_value",
"EXPIRE test_key " + strconv.FormatInt(10, 10) + " GT",
"TTL... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
endRangeProvided = false
if len(args) > 0 {
start, err = strconv.Atoi(args[0])
if err != nil {
return 0, 0, "", false, errors.New("value is not an integer or out of range")
}
}
if len(args) > 1 {
end, err = strconv.Atoi(args[1])
if err != nil {
return 0, 0, "", false, errors.New("value is not an i... | No issues found. | endRangeProvided = false
if len(args) > 0 {
start, err = strconv.Atoi(args[0])
if err != nil {
return 0, 0, "", false, errors.New("value is not an integer or out of range")
}
}
if len(args) > 1 {
end, err = strconv.Atoi(args[1])
if err != nil {
return 0, 0, "", false, errors.New("value is not an i... | @@ -130,7 +130,7 @@ func getBitPos(byteSlice []byte, bitToFind byte, start, end int, rangeType strin
return result
}
-//nolint: gocritic
+// nolint: gocritic
func adjustBitPosSearchRange(start, end, byteLen int) (int, int) {
if start < 0 {
start += byteLen | internal/eval/bitpos.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | Adds retry with exponential backoff for QWATCH writes | 514 | DiceDB/dice | 10,326 | C | JyotinderSingh | Review this pull request change.
Language: Go
File: internal/eval/bitpos.go
PR Title: Adds retry with exponential backoff for QWATCH writes
BEFORE CODE: endRangeProvided = false
if len(args) > 0 {
start, err = strconv.Atoi(args[0])
if err != nil {
return 0, 0, "", false, errors.New("value is not an intege... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
_ = sonic.Unmarshal([]byte(value), &rootData)
obj := store.NewObj(rootData, -1, object.ObjTypeJSON, object.ObjEncodingJSON)
store.Put(key, obj)
},
input: []string{"EXISTING_KEY", "$.a"},
output: []byte("*1\r\n$6\r\nstring\r\n"),
},
"boolean type value": {
setup: func() {
key := "EXIST... | No issues found. | _ = sonic.Unmarshal([]byte(value), &rootData)
obj := store.NewObj(rootData, -1, object.ObjTypeJSON, object.ObjEncodingJSON)
store.Put(key, obj)
},
input: []string{"EXISTING_KEY", "$.a"},
output: []byte("*1\r\n$6\r\nstring\r\n"),
},
"boolean type value": {
setup: func() {
key := "EXIST... | @@ -4,15 +4,14 @@ import (
"bytes"
"errors"
"fmt"
+ "github.com/bytedance/sonic"
+ "github.com/dicedb/dice/internal/object"
"strconv"
"strings"
"testing"
"time"
- "github.com/dicedb/dice/internal/object"
-
"github.com/axiomhq/hyperloglog"
- "github.com/bytedance/sonic"
"github.com/dicedb/dice/intern... | internal/eval/eval_test.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | #241: Implementation PFMERGE command | 518 | DiceDB/dice | 10,326 | C | lucifercr07 | Review this pull request change.
Language: Go
File: internal/eval/eval_test.go
PR Title: #241: Implementation PFMERGE command
BEFORE CODE: _ = sonic.Unmarshal([]byte(value), &rootData)
obj := store.NewObj(rootData, -1, object.ObjTypeJSON, object.ObjEncodingJSON)
store.Put(key, obj)
},
input: []... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
errorChan: errorChan,
lastCronExecTime: utils.GetCurrentTime(),
cronFrequency: config.ShardCronFrequency,
}
}
// Start starts the shard thread, listening for incoming requests.
func (shard *ShardThread) Start(ctx context.Context) {
ticker := time.NewTicker(shard.cronFrequency)
defer ticker.Stop()
... | No issues found. | errorChan: errorChan,
lastCronExecTime: utils.GetCurrentTime(),
cronFrequency: config.ShardCronFrequency,
}
}
// Start starts the shard thread, listening for incoming requests.
func (shard *ShardThread) Start(ctx context.Context) {
ticker := time.NewTicker(shard.cronFrequency)
defer ticker.Stop()
... | @@ -7,6 +7,8 @@ import (
"sync"
"time"
+ "github.com/charmbracelet/log"
+
"github.com/dicedb/dice/config"
"github.com/dicedb/dice/internal/auth"
"github.com/dicedb/dice/internal/clientio"
@@ -127,5 +129,13 @@ func (shard *ShardThread) executeCommand(op *ops.StoreOp) []byte {
// cleanup handles cleanup logi... | internal/shard/shard_thread.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | Adding TestEnvEnabled config and avoiding AOF dump for test env | 523 | DiceDB/dice | 10,326 | C | lucifercr07 | Review this pull request change.
Language: Go
File: internal/shard/shard_thread.go
PR Title: Adding TestEnvEnabled config and avoiding AOF dump for test env
BEFORE CODE: errorChan: errorChan,
lastCronExecTime: utils.GetCurrentTime(),
cronFrequency: config.ShardCronFrequency,
}
}
// Start starts th... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
command: `JSON.GET bikes:inventory '$..[?(@.specs.material =~ "(?i)al")].model'`,
expected: "ERR invalid JSONPath",
},
{
name: "Using @ for referencing other fields",
command: `JSON.GET bikes:inventory '$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model'`,
expected: "ERR inval... | No issues found. | command: `JSON.GET bikes:inventory '$..[?(@.specs.material =~ "(?i)al")].model'`,
expected: "ERR invalid JSONPath",
},
{
name: "Using @ for referencing other fields",
command: `JSON.GET bikes:inventory '$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model'`,
expected: "ERR inval... | @@ -474,3 +474,77 @@ func TestJSONDelOperations(t *testing.T) {
})
}
}
+
+func TestJSONForgetOperations(t *testing.T) {
+ conn := getLocalConnection()
+ defer conn.Close()
+
+ fireCommand(conn, "FORGET user")
+
+ stringForgetTestJson := `{"flag":true,"name":"Tom"}`
+ booleanForgetTestJson := `{"flag":true,"name":... | tests/json_test.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | #494: Implementation `JSON.FORGET` command | 524 | DiceDB/dice | 10,326 | C | Nijin-P-S | Review this pull request change.
Language: Go
File: tests/json_test.go
PR Title: #494: Implementation `JSON.FORGET` command
BEFORE CODE: command: `JSON.GET bikes:inventory '$..[?(@.specs.material =~ "(?i)al")].model'`,
expected: "ERR invalid JSONPath",
},
{
name: "Using @ for referencing other fie... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
package utils
import (
"github.com/dicedb/dice/internal/cmd"
"github.com/stretchr/testify/assert"
"net/http/httptest"
"strings"
"testing"
)
func TestParseHTTPRequest(t *testing.T) {
commands := []struct {
name string
method string
url string
body string
expectedCmd stri... | No issues found. | package utils
import (
"github.com/dicedb/dice/internal/cmd"
"github.com/stretchr/testify/assert"
"net/http/httptest"
"strings"
"testing"
)
func TestParseHTTPRequest(t *testing.T) {
commands := []struct {
name string
method string
url string
body string
expectedCmd stri... | @@ -0,0 +1,45 @@
+package utils
+
+import (
+ "github.com/dicedb/dice/internal/cmd"
+ "github.com/stretchr/testify/assert"
+ "net/http/httptest"
+ "strings"
+ "testing"
+)
+
+func TestParseHTTPRequest(t *testing.T) {
+ commands := []struct {
+ name string
+ method string
+ url string
+ body ... | internal/server/utils/redisCmdAdapter_test.go | 0 | Go | 1 | none | 16 | 46 | 46 | true | Add Support for HTTP | 527 | DiceDB/dice | 10,326 | C | pratikpandey21 | Review this pull request change.
Language: Go
File: internal/server/utils/redisCmdAdapter_test.go
PR Title: Add Support for HTTP
BEFORE CODE: package utils
import (
"github.com/dicedb/dice/internal/cmd"
"github.com/stretchr/testify/assert"
"net/http/httptest"
"strings"
"testing"
)
func TestParseHTTPRequest(t... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
expected: []interface{}{int64(0), "(nil)", "(nil)"},
},
{
name: "NX on non-existing key",
commands: []string{"DEL k", "SET k v NX", "GET k"},
expected: []interface{}{int64(0), "OK", "v"},
},
{
name: "NX on existing key",
commands: []string{"DEL k", "SET k v NX", "GET k", "SET k v NX"},... | No issues found. | expected: []interface{}{int64(0), "(nil)", "(nil)"},
},
{
name: "NX on non-existing key",
commands: []string{"DEL k", "SET k v NX", "GET k"},
expected: []interface{}{int64(0), "OK", "v"},
},
{
name: "NX on existing key",
commands: []string{"DEL k", "SET k v NX", "GET k", "SET k v NX"},... | @@ -39,10 +39,10 @@ func TestSet(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
// deleteTestKeys([]string{"k"}, store)
- fireCommand(conn, "DEL k")
+ FireCommand(conn, "DEL k")
for i, cmd := range tc.commands {
- result := fireCommand(conn, cmd)
+ result := ... | tests/set_test.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | #437: feat: add test for abort command | 531 | DiceDB/dice | 10,326 | C | tdadadavid | Review this pull request change.
Language: Go
File: tests/set_test.go
PR Title: #437: feat: add test for abort command
BEFORE CODE: expected: []interface{}{int64(0), "(nil)", "(nil)"},
},
{
name: "NX on non-existing key",
commands: []string{"DEL k", "SET k v NX", "GET k"},
expected: []interface{... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
},
input: []string{"EXISTING_KEY", "$.language"},
output: []byte("*1\r\n$5\r\narray\r\n"),
},
"string type value": {
setup: func() {
key := "EXISTING_KEY"
value := "{\"a\":\"test\"}"
var rootData interface{}
_ = sonic.Unmarshal([]byte(value), &rootData)
obj := store.NewObj(rootData... | No issues found. | },
input: []string{"EXISTING_KEY", "$.language"},
output: []byte("*1\r\n$5\r\narray\r\n"),
},
"string type value": {
setup: func() {
key := "EXISTING_KEY"
value := "{\"a\":\"test\"}"
var rootData interface{}
_ = sonic.Unmarshal([]byte(value), &rootData)
obj := store.NewObj(rootData... | @@ -4,12 +4,13 @@ import (
"bytes"
"errors"
"fmt"
- "github.com/dicedb/dice/internal/object"
"strconv"
"strings"
"testing"
"time"
+ "github.com/dicedb/dice/internal/object"
+
"github.com/axiomhq/hyperloglog"
"github.com/bytedance/sonic"
"github.com/dicedb/dice/internal/clientio"
@@ -1006,6 +1007,1... | internal/eval/eval_test.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | Fixed hyperloglog type assertion check. | 541 | DiceDB/dice | 10,326 | C | AshwinKul28 | Review this pull request change.
Language: Go
File: internal/eval/eval_test.go
PR Title: Fixed hyperloglog type assertion check.
BEFORE CODE: },
input: []string{"EXISTING_KEY", "$.language"},
output: []byte("*1\r\n$5\r\narray\r\n"),
},
"string type value": {
setup: func() {
key := "EXISTING_KE... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
for i := 0; i < len(tcase.commands); i++ {
cmd := tcase.commands[i]
out := tcase.expected[i]
result := FireCommand(conn, cmd)
jsonResult, isString := result.(string)
if isString && testutils.IsJSONResponse(jsonResult) {
testutils.AssertJSONEqual(t, out.(string), jsonResult)
} else {
assert.E... | No issues found. | for i := 0; i < len(tcase.commands); i++ {
cmd := tcase.commands[i]
out := tcase.expected[i]
result := FireCommand(conn, cmd)
jsonResult, isString := result.(string)
if isString && testutils.IsJSONResponse(jsonResult) {
testutils.AssertJSONEqual(t, out.(string), jsonResult)
} else {
assert.E... | @@ -628,3 +628,60 @@ func TestJsonStrlen(t *testing.T) {
})
}
}
+
+func TestJsonARRAPPEND(t *testing.T) {
+ conn := getLocalConnection()
+ defer conn.Close()
+ a := `[1,2]`
+ b := `{"name":"jerry","partner":{"name":"tom","score":[10]},"partner2":{"score":[10,20]}}`
+ c := `{"name":["jerry"],"partner":{"name":"... | integration_tests/commands/json_test.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | #485: JSON.ARRAPPEND Command | 543 | DiceDB/dice | 10,326 | C | srivastava-yash | Review this pull request change.
Language: Go
File: integration_tests/commands/json_test.go
PR Title: #485: JSON.ARRAPPEND Command
BEFORE CODE: for i := 0; i < len(tcase.commands); i++ {
cmd := tcase.commands[i]
out := tcase.expected[i]
result := FireCommand(conn, cmd)
jsonResult, isString := result.... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
expected []interface{}
}{
{
commands: []string{"JSON.SET user $ " + user1 + " XX", "JSON.SET user $ " + user1 + " NX", "JSON.GET user"},
expected: []interface{}{"(nil)", "OK", user1},
},
{
commands: []string{"DEL user", "JSON.SET user $ " + user1, "JSON.SET user $ " + user1 + " NX"},
expected: []in... | No issues found. | expected []interface{}
}{
{
commands: []string{"JSON.SET user $ " + user1 + " XX", "JSON.SET user $ " + user1 + " NX", "JSON.GET user"},
expected: []interface{}{"(nil)", "OK", user1},
},
{
commands: []string{"DEL user", "JSON.SET user $ " + user1, "JSON.SET user $ " + user1 + " NX"},
expected: []in... | @@ -548,3 +548,83 @@ func TestJSONForgetOperations(t *testing.T) {
})
}
}
+
+func arraysArePermutations(a, b []interface{}) bool {
+ // If lengths are different, they cannot be permutations
+ if len(a) != len(b) {
+ return false
+ }
+
+ // Count occurrences of each element in array 'a'
+ countA := make(map[inter... | integration_tests/commands/json_test.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | #502 Added support for `JSON.STRLEN` | 545 | DiceDB/dice | 10,326 | C | apoorvyadav1111 | Review this pull request change.
Language: Go
File: integration_tests/commands/json_test.go
PR Title: #502 Added support for `JSON.STRLEN`
BEFORE CODE: expected []interface{}
}{
{
commands: []string{"JSON.SET user $ " + user1 + " XX", "JSON.SET user $ " + user1 + " NX", "JSON.GET user"},
expected: []int... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
obj := store.NewObj(rootData, -1, object.ObjTypeJSON, object.ObjEncodingJSON)
store.Put(key, obj)
},
input: []string{"array", "$.a", `"blue"`},
output: []byte("*1\r\n:3\r\n"),
},
}
runEvalTests(t, tests, evalJSONARRAPPEND, store)
}
func testEvalJSONTOGGLE(t *... | No issues found. | obj := store.NewObj(rootData, -1, object.ObjTypeJSON, object.ObjEncodingJSON)
store.Put(key, obj)
},
input: []string{"array", "$.a", `"blue"`},
output: []byte("*1\r\n:3\r\n"),
},
}
runEvalTests(t, tests, evalJSONARRAPPEND, store)
}
func testEvalJSONTOGGLE(t *... | @@ -4,6 +4,7 @@ import (
"bytes"
"errors"
"fmt"
+
"strconv"
"strings"
"testing"
@@ -49,6 +50,7 @@ func TestEval(t *testing.T) {
testEvalJSONTYPE(t, store)
testEvalJSONGET(t, store)
testEvalJSONSET(t, store)
+ testEvalJSONTOGGLE(t,store)
testEvalJSONARRAPPEND(t, store)
testEvalTTL(t, store)
testE... | internal/eval/eval_test.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | #503: Added support for JSON.TOGGLE | 546 | DiceDB/dice | 10,326 | C | TheRanomial | Review this pull request change.
Language: Go
File: internal/eval/eval_test.go
PR Title: #503: Added support for JSON.TOGGLE
BEFORE CODE: obj := store.NewObj(rootData, -1, object.ObjTypeJSON, object.ObjEncodingJSON)
store.Put(key, obj)
},
input: []string{"array", "$.a", `"blue"`},
... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
package commands
import (
"testing"
"gotest.tools/v3/assert"
)
func TestSelect(t *testing.T) {
conn := getLocalConnection()
defer conn.Close()
t.Run("SELECT command response", func(t *testing.T) {
actual := FireCommand(conn, "SELECT 1")
assert.DeepEqual(t, string("OK"), actual)
})
t.Run("SELECT command ... | No issues found. | package commands
import (
"testing"
"gotest.tools/v3/assert"
)
func TestSelect(t *testing.T) {
conn := getLocalConnection()
defer conn.Close()
t.Run("SELECT command response", func(t *testing.T) {
actual := FireCommand(conn, "SELECT 1")
assert.DeepEqual(t, string("OK"), actual)
})
t.Run("SELECT command ... | @@ -0,0 +1,22 @@
+package commands
+
+import (
+ "testing"
+
+ "gotest.tools/v3/assert"
+)
+
+func TestSelect(t *testing.T) {
+ conn := getLocalConnection()
+ defer conn.Close()
+
+ t.Run("SELECT command response", func(t *testing.T) {
+ actual := FireCommand(conn, "SELECT 1")
+ assert.DeepEqual(t, string("OK"), actu... | integration_tests/commands/select_test.go | 0 | Go | 1 | none | 16 | 23 | 23 | true | #569: cmd: add SELECT cmd | 574 | DiceDB/dice | 10,326 | C | codeasashu | Review this pull request change.
Language: Go
File: integration_tests/commands/select_test.go
PR Title: #569: cmd: add SELECT cmd
BEFORE CODE: package commands
import (
"testing"
"gotest.tools/v3/assert"
)
func TestSelect(t *testing.T) {
conn := getLocalConnection()
defer conn.Close()
t.Run("SELECT command... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
},
"multi type value": {
setup: func() {
key := "EXISTING_KEY"
value := "{\"name\":\"tom\",\"partner\":{\"name\":\"jerry\"}}"
var rootData interface{}
_ = sonic.Unmarshal([]byte(value), &rootData)
obj := store.NewObj(rootData, -1, object.ObjTypeJSON, object.ObjEncodingJSON)
store.Put(key,... | No issues found. | },
"multi type value": {
setup: func() {
key := "EXISTING_KEY"
value := "{\"name\":\"tom\",\"partner\":{\"name\":\"jerry\"}}"
var rootData interface{}
_ = sonic.Unmarshal([]byte(value), &rootData)
obj := store.NewObj(rootData, -1, object.ObjTypeJSON, object.ObjEncodingJSON)
store.Put(key,... | @@ -65,6 +65,7 @@ func TestEval(t *testing.T) {
testEvalHLEN(t, store)
testEvalSELECT(t, store)
testEvalLLEN(t, store)
+ testEvalGETEX(t, store)
}
func testEvalPING(t *testing.T, store *dstore.Store) {
@@ -122,6 +123,37 @@ func testEvalSET(t *testing.T, store *dstore.Store) {
runEvalTests(t, tests, evalSET,... | internal/eval/eval_test.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | GETEXwith EX with big integer reports an error | 576 | DiceDB/dice | 10,326 | C | Gaurav-Kumar81 | Review this pull request change.
Language: Go
File: internal/eval/eval_test.go
PR Title: GETEXwith EX with big integer reports an error
BEFORE CODE: },
"multi type value": {
setup: func() {
key := "EXISTING_KEY"
value := "{\"name\":\"tom\",\"partner\":{\"name\":\"jerry\"}}"
var rootData interface... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
setup: func() {},
input: []string{"KEY1", "KEY2"},
output: []byte("-ERR wrong number of arguments for 'ttl' command\r\n"),
},
"key exists expiry not set": {
setup: func() {
key := "EXISTING_KEY"
value := "mock_value"
obj := &object.Obj{
Value: value,
LastAccessedAt: uint... | No issues found. | setup: func() {},
input: []string{"KEY1", "KEY2"},
output: []byte("-ERR wrong number of arguments for 'ttl' command\r\n"),
},
"key exists expiry not set": {
setup: func() {
key := "EXISTING_KEY"
value := "mock_value"
obj := &object.Obj{
Value: value,
LastAccessedAt: uint... | @@ -41,6 +41,7 @@ func TestEval(t *testing.T) {
testEvalHELLO(t, store)
testEvalSET(t, store)
testEvalGET(t, store)
+ testEvalDebug(t, store)
testEvalJSONARRLEN(t, store)
testEvalJSONDEL(t, store)
testEvalJSONFORGET(t, store)
@@ -1507,6 +1508,250 @@ func testEvalHSET(t *testing.T, store *dstore.Store) {
r... | internal/eval/eval_test.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | Added support for JSON.DEBUG | 579 | DiceDB/dice | 10,326 | C | psrvere | Review this pull request change.
Language: Go
File: internal/eval/eval_test.go
PR Title: Added support for JSON.DEBUG
BEFORE CODE: setup: func() {},
input: []string{"KEY1", "KEY2"},
output: []byte("-ERR wrong number of arguments for 'ttl' command\r\n"),
},
"key exists expiry not set": {
setup: fun... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
deqCleanUp(conn, "k")
}
func TestLPushRPop(t *testing.T) {
deqTestInit()
conn := getLocalConnection()
defer conn.Close()
getPops := func(values []string) []string {
pops := make([]string, len(values)+1)
for i := 0; i < len(values)+1; i++ {
pops[i] = "RPOP k"
}
return pops
}
getPopExpects := func(val... | No issues found. | deqCleanUp(conn, "k")
}
func TestLPushRPop(t *testing.T) {
deqTestInit()
conn := getLocalConnection()
defer conn.Close()
getPops := func(values []string) []string {
pops := make([]string, len(values)+1)
for i := 0; i < len(values)+1; i++ {
pops[i] = "RPOP k"
}
return pops
}
getPopExpects := func(val... | @@ -403,6 +403,45 @@ func TestLRPushLRPop(t *testing.T) {
deqCleanUp(conn, "k")
}
+func TestLLEN(t *testing.T) {
+ deqTestInit()
+ conn := getLocalConnection()
+ defer conn.Close()
+
+ testCases := []struct {
+ name string
+ cmds []string
+ expect []any
+ }{
+ {
+ name: "L/RPush L/RPop",
+ cmds: []stri... | integration_tests/commands/deque_test.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | #572: Added support for LLEN command | 580 | DiceDB/dice | 10,326 | C | jainbhavya53 | Review this pull request change.
Language: Go
File: integration_tests/commands/deque_test.go
PR Title: #572: Added support for LLEN command
BEFORE CODE: deqCleanUp(conn, "k")
}
func TestLPushRPop(t *testing.T) {
deqTestInit()
conn := getLocalConnection()
defer conn.Close()
getPops := func(values []string) []... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
err = s.eventLoop(eventLoopCtx)
if err != nil {
cancelWatch()
cancelEventLoop()
s.InitiateShutdown()
}
}()
wg.Wait()
return err
}
// eventLoop listens for events and handles client requests. It also runs a cron job to delete expired keys
func (s *AsyncServer) eventLoop(ctx context.Context) error {
... | No issues found. | err = s.eventLoop(eventLoopCtx)
if err != nil {
cancelWatch()
cancelEventLoop()
s.InitiateShutdown()
}
}()
wg.Wait()
return err
}
// eventLoop listens for events and handles client requests. It also runs a cron job to delete expired keys
func (s *AsyncServer) eventLoop(ctx context.Context) error {
... | @@ -12,7 +12,8 @@ import (
"syscall"
"time"
- "github.com/charmbracelet/log"
+ "log/slog"
+
"github.com/dicedb/dice/config"
"github.com/dicedb/dice/internal/auth"
"github.com/dicedb/dice/internal/clientio"
@@ -40,18 +41,20 @@ type AsyncServer struct {
shardManager *shard.ShardManager
ioChan ... | internal/server/server.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | Setup slog with zerolog | 584 | DiceDB/dice | 10,326 | C | KaviiSuri | Review this pull request change.
Language: Go
File: internal/server/server.go
PR Title: Setup slog with zerolog
BEFORE CODE: err = s.eventLoop(eventLoopCtx)
if err != nil {
cancelWatch()
cancelEventLoop()
s.InitiateShutdown()
}
}()
wg.Wait()
return err
}
// eventLoop listens for events and hand... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
input: []string{"EXISTING_KEY", ".active"},
output: clientio.Encode([]interface{}{1}, false),
},
"key exists but expired": {
setup: func() {
key := "EXISTING_KEY"
value := "{\"active\":true}"
obj := &object.Obj{
... | No issues found. | input: []string{"EXISTING_KEY", ".active"},
output: clientio.Encode([]interface{}{1}, false),
},
"key exists but expired": {
setup: func() {
key := "EXISTING_KEY"
value := "{\"active\":true}"
obj := &object.Obj{
... | @@ -12,11 +12,11 @@ import (
"github.com/bytedance/sonic"
- "github.com/dicedb/dice/internal/object"
-
"github.com/axiomhq/hyperloglog"
"github.com/dicedb/dice/internal/clientio"
+ "github.com/dicedb/dice/internal/object"
dstore "github.com/dicedb/dice/internal/store"
+ testifyAssert "github.com/stretchr/te... | internal/eval/eval_test.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | #496: Feature `JSON.NUMINCRBY` | 585 | DiceDB/dice | 10,326 | C | apoorvyadav1111 | Review this pull request change.
Language: Go
File: internal/eval/eval_test.go
PR Title: #496: Feature `JSON.NUMINCRBY`
BEFORE CODE: input: []string{"EXISTING_KEY", ".active"},
output: clientio.Encode([]interface{}{1}, false),
},
"key exists but expired": {
setup... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
cmds []string
expect []interface{}
delays []time.Duration
}{
{
name: "GetDel",
cmds: []string{"SET k v", "GETDEL k", "GETDEL k", "GET k"},
expect: []interface{}{"OK", "v", "(nil)", "(nil)"},
delays: []time.Duration{0, 0, 0, 0},
},
{
name: "GetDel with expiration, checking if key exis... | No issues found. | cmds []string
expect []interface{}
delays []time.Duration
}{
{
name: "GetDel",
cmds: []string{"SET k v", "GETDEL k", "GETDEL k", "GET k"},
expect: []interface{}{"OK", "v", "(nil)", "(nil)"},
delays: []time.Duration{0, 0, 0, 0},
},
{
name: "GetDel with expiration, checking if key exis... | @@ -1,9 +1,10 @@
package commands
import (
- "gotest.tools/v3/assert"
"testing"
"time"
+
+ "gotest.tools/v3/assert"
)
func TestGetDel(t *testing.T) {
@@ -42,9 +43,28 @@ func TestGetDel(t *testing.T) {
"ERR wrong number of arguments for 'getdel' command"},
delays: []time.Duration{0, 0},
},
+ {
+... | integration_tests/commands/getdel_test.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | Enhance GETDEL to handle Set, JSON,ByteArray, String, and Integer and Expand Test Coverage | 586 | DiceDB/dice | 10,326 | C | rushabhk04 | Review this pull request change.
Language: Go
File: integration_tests/commands/getdel_test.go
PR Title: Enhance GETDEL to handle Set, JSON,ByteArray, String, and Integer and Expand Test Coverage
BEFORE CODE: cmds []string
expect []interface{}
delays []time.Duration
}{
{
name: "GetDel",
cmds: []... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
expectedCmd: "SET",
expectedArgs: []string{"k1", "v1", "nx"},
},
{
name: "Test GET command",
method: "POST",
url: "/get",
body: `{"key": "k1"}`,
expectedCmd: "GET",
expectedArgs: []string{"k1"},
},
{
name: "Test MSET command",
method: ... | No issues found. | expectedCmd: "SET",
expectedArgs: []string{"k1", "v1", "nx"},
},
{
name: "Test GET command",
method: "POST",
url: "/get",
body: `{"key": "k1"}`,
expectedCmd: "GET",
expectedArgs: []string{"k1"},
},
{
name: "Test MSET command",
method: ... | @@ -1,11 +1,12 @@
package utils
import (
- "github.com/dicedb/dice/internal/cmd"
- "github.com/stretchr/testify/assert"
"net/http/httptest"
"strings"
"testing"
+
+ "github.com/dicedb/dice/internal/cmd"
+ "github.com/stretchr/testify/assert"
)
func TestParseHTTPRequest(t *testing.T) {
@@ -18,71 +19,79 @@ f... | internal/server/utils/redisCmdAdapter_test.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | #551 Added JSON.INGEST support for HTTP | 588 | DiceDB/dice | 10,326 | C | kushal0511-not | Review this pull request change.
Language: Go
File: internal/server/utils/redisCmdAdapter_test.go
PR Title: #551 Added JSON.INGEST support for HTTP
BEFORE CODE: expectedCmd: "SET",
expectedArgs: []string{"k1", "v1", "nx"},
},
{
name: "Test GET command",
method: "POST",
url: ... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
obj := store.Get(key)
// if key does not exist, return RESP encoded nil
if obj == nil {
return EvalResponse{Result: clientio.RespNIL, Error: nil}
}
case NX:
obj := store.Get(key)
if obj != nil {
return EvalResponse{Result: clientio.RespNIL, Error: nil}
}
case KEEPTTL, Keepttl:
keept... | No issues found. | obj := store.Get(key)
// if key does not exist, return RESP encoded nil
if obj == nil {
return EvalResponse{Result: clientio.RespNIL, Error: nil}
}
case NX:
obj := store.Get(key)
if obj != nil {
return EvalResponse{Result: clientio.RespNIL, Error: nil}
}
case KEEPTTL, Keepttl:
keept... | @@ -214,3 +214,38 @@ func evalGETSET(args []string, store *dstore.Store) EvalResponse {
return getResp
}
+
+// evalSETEX puts a new <key, value> pair in db as in the args
+// args must contain only key , expiry and value
+// Returns encoded error response if <key,exp,value> is not part of args
+// Returns encoded... | internal/eval/store_eval.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | #570: Adds support for SETEX command | 590 | DiceDB/dice | 10,326 | C | AshikBN | Review this pull request change.
Language: Go
File: internal/eval/store_eval.go
PR Title: #570: Adds support for SETEX command
BEFORE CODE: obj := store.Get(key)
// if key does not exist, return RESP encoded nil
if obj == nil {
return EvalResponse{Result: clientio.RespNIL, Error: nil}
}
case NX:... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
"nested JSON structure with multiple booleans": {
setup: func() {
key := "NESTED_KEY"
value := `{"isSimple":true,"nested":{"isSimple":false}}`
var rootData interface{}
_ = sonic.Unmarshal([]byte(value), &rootData)
obj := store.NewObj(rootData, -1, object.ObjTypeJSON, object.ObjEncodingJSON)
... | No issues found. | "nested JSON structure with multiple booleans": {
setup: func() {
key := "NESTED_KEY"
value := `{"isSimple":true,"nested":{"isSimple":false}}`
var rootData interface{}
_ = sonic.Unmarshal([]byte(value), &rootData)
obj := store.NewObj(rootData, -1, object.ObjTypeJSON, object.ObjEncodingJSON)
... | @@ -52,6 +52,7 @@ func TestEval(t *testing.T) {
testEvalJSONTYPE(t, store)
testEvalJSONGET(t, store)
testEvalJSONSET(t, store)
+ testEvalJSONNUMMULTBY(t, store)
testEvalJSONTOGGLE(t, store)
testEvalJSONARRAPPEND(t, store)
testEvalTTL(t, store)
@@ -1054,6 +1055,87 @@ func testEvalJSONSET(t *testing.T, store ... | internal/eval/eval_test.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | Added support for JSON.NUMMULTBY | 592 | DiceDB/dice | 10,326 | C | c-harish | Review this pull request change.
Language: Go
File: internal/eval/eval_test.go
PR Title: Added support for JSON.NUMMULTBY
BEFORE CODE: "nested JSON structure with multiple booleans": {
setup: func() {
key := "NESTED_KEY"
value := `{"isSimple":true,"nested":{"isSimple":false}}`
var rootData interfac... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
Eval: evalBITCOUNT,
}
bitOpCmdMeta = DiceCmdMeta{
Name: "BITOP",
Info: "BITOP performs bitwise operations between multiple keys",
Eval: evalBITOP,
}
commandCmdMeta = DiceCmdMeta{
Name: "COMMAND <subcommand>",
Info: "Evaluates COMMAND <subcommand> command based on subcommand",
Eval: evalCommand,
A... | No issues found. | Eval: evalBITCOUNT,
}
bitOpCmdMeta = DiceCmdMeta{
Name: "BITOP",
Info: "BITOP performs bitwise operations between multiple keys",
Eval: evalBITOP,
}
commandCmdMeta = DiceCmdMeta{
Name: "COMMAND <subcommand>",
Info: "Evaluates COMMAND <subcommand> command based on subcommand",
Eval: evalCommand,
A... | @@ -180,6 +180,17 @@ var (
Arity: -2,
KeySpecs: KeySpecs{BeginIndex: 1},
}
+
+ jsonobjlenCmdMeta = DiceCmdMeta{
+ Name: "JSON.OBJLEN",
+ Info: `JSON.OBJLEN key [path]
+ Report the number of keys in the JSON object at path in key
+ Returns error response if the key doesn't exist or key is expired or the m... | internal/eval/commands.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | #499: Add support for command JSON.OBJLEN | 593 | DiceDB/dice | 10,326 | C | phaneesh707 | Review this pull request change.
Language: Go
File: internal/eval/commands.go
PR Title: #499: Add support for command JSON.OBJLEN
BEFORE CODE: Eval: evalBITCOUNT,
}
bitOpCmdMeta = DiceCmdMeta{
Name: "BITOP",
Info: "BITOP performs bitwise operations between multiple keys",
Eval: evalBITOP,
}
commandCmdMe... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
commands: []string{"MSET k1 v1 k2 v2", "GET k1", "GET k2"},
expected: []interface{}{"OK", "v1", "v2"},
},
{
name: "MSET with odd number of arguments",
commands: []string{"MSET k1 v1 k2"},
expected: []interface{}{"ERR wrong number of arguments for 'mset' command"},
},
}
for _, tc := range tes... | No issues found. | commands: []string{"MSET k1 v1 k2 v2", "GET k1", "GET k2"},
expected: []interface{}{"OK", "v1", "v2"},
},
{
name: "MSET with odd number of arguments",
commands: []string{"MSET k1 v1 k2"},
expected: []interface{}{"ERR wrong number of arguments for 'mset' command"},
},
}
for _, tc := range tes... | @@ -45,3 +45,54 @@ func TestMset(t *testing.T) {
})
}
}
+func TestMSETInconsistency(t *testing.T) {
+
+ conn := getLocalConnection()
+ defer conn.Close()
+
+ testCases := []struct {
+ name string
+ commands []string
+ expected []interface{}
+ }{
+ {
+ name: "MSET with one key-value pair",
+ comman... | integration_tests/commands/mset_test.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | #406 Fix MSET command consistency issue with Redis | 594 | DiceDB/dice | 10,326 | C | ar1fKhan | Review this pull request change.
Language: Go
File: integration_tests/commands/mset_test.go
PR Title: #406 Fix MSET command consistency issue with Redis
BEFORE CODE: commands: []string{"MSET k1 v1 k2 v2", "GET k1", "GET k2"},
expected: []interface{}{"OK", "v1", "v2"},
},
{
name: "MSET with odd numb... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
assert.Assert(t, !bytes.Equal(output, clientio.RespMinusTwo))
},
},
"key exists but expired": {
setup: func() {
key := "EXISTING_EXPIRED_KEY"
value := "mock_value"
obj := &object.Obj{
Value: value,
LastAccessedAt: uint32(time.Now().Unix()),
}
store.Put(key, obj)
... | No issues found. | assert.Assert(t, !bytes.Equal(output, clientio.RespMinusTwo))
},
},
"key exists but expired": {
setup: func() {
key := "EXISTING_EXPIRED_KEY"
value := "mock_value"
obj := &object.Obj{
Value: value,
LastAccessedAt: uint32(time.Now().Unix()),
}
store.Put(key, obj)
... | @@ -15,6 +15,7 @@ import (
"github.com/axiomhq/hyperloglog"
"github.com/dicedb/dice/internal/clientio"
+ diceerrors "github.com/dicedb/dice/internal/errors"
"github.com/dicedb/dice/internal/object"
dstore "github.com/dicedb/dice/internal/store"
testifyAssert "github.com/stretchr/testify/assert"
@@ -74,6 +75... | internal/eval/eval_test.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | #571: Add support for Redis TYPE command | 601 | DiceDB/dice | 10,326 | C | meetghodasara | Review this pull request change.
Language: Go
File: internal/eval/eval_test.go
PR Title: #571: Add support for Redis TYPE command
BEFORE CODE: assert.Assert(t, !bytes.Equal(output, clientio.RespMinusTwo))
},
},
"key exists but expired": {
setup: func() {
key := "EXISTING_EXPIRED_KEY"
value := ... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
name string
obj []*object.Obj
keys []string
setup func(string, *object.Obj)
perform func()
expectedKey string // false if we expect the key to be deleted
sleep bool
}{
{
name: "Test LFU - eviction pool should have least recent key if all access keys are same",
... | No issues found. | name string
obj []*object.Obj
keys []string
setup func(string, *object.Obj)
perform func()
expectedKey string // false if we expect the key to be deleted
sleep bool
}{
{
name: "Test LFU - eviction pool should have least recent key if all access keys are same",
... | @@ -27,12 +27,7 @@ func TestLFUEviction(t *testing.T) {
{
name: "Test LFU - eviction pool should have least recent key if all access keys are same",
keys: []string{"k1", "k2", "k3", "k4"},
- obj: []*object.Obj{
- &object.Obj{},
- &object.Obj{},
- &object.Obj{},
- &object.Obj{},
- },
+ obj: ... | internal/store/lfu_eviction_test.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | #609 fix: auth command line flags should be respected during server startup | 605 | DiceDB/dice | 10,326 | C | vinitparekh17 | Review this pull request change.
Language: Go
File: internal/store/lfu_eviction_test.go
PR Title: #609 fix: auth command line flags should be respected during server startup
BEFORE CODE: name string
obj []*object.Obj
keys []string
setup func(string, *object.Obj)
perform fun... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
})
querywatcher.WatchSubscriptionChan <- querywatcher.WatchSubscription{
Subscribe: true,
Query: query,
ClientFD: clientFd,
CacheChan: cacheChannel,
}
store.CacheKeysForQuery(query.Where, cacheChannel)
// Return the result of the query.
responseChan := make(chan querywatcher.AdhocQueryResult)
quer... | No issues found. | })
querywatcher.WatchSubscriptionChan <- querywatcher.WatchSubscription{
Subscribe: true,
Query: query,
ClientFD: clientFd,
CacheChan: cacheChannel,
}
store.CacheKeysForQuery(query.Where, cacheChannel)
// Return the result of the query.
responseChan := make(chan querywatcher.AdhocQueryResult)
quer... | @@ -2201,17 +2201,48 @@ func evalCommand(args []string, store *dstore.Store) []byte {
}
subcommand := strings.ToUpper(args[0])
switch subcommand {
- case "COUNT":
+ case Count:
return evalCommandCount()
- case "GETKEYS":
+ case GetKeys:
return evalCommandGetKeys(args[1:])
- case "LIST":
+ case List:
retu... | internal/eval/eval.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | Added COMMAND HELP | 608 | DiceDB/dice | 10,326 | C | psrvere | Review this pull request change.
Language: Go
File: internal/eval/eval.go
PR Title: Added COMMAND HELP
BEFORE CODE: })
querywatcher.WatchSubscriptionChan <- querywatcher.WatchSubscription{
Subscribe: true,
Query: query,
ClientFD: clientFd,
CacheChan: cacheChannel,
}
store.CacheKeysForQuery(query.W... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
package commands
import (
"testing"
"gotest.tools/v3/assert"
)
func TestEcho(t *testing.T) {
conn := getLocalConnection()
defer conn.Close()
testCases := []struct {
name string
commands []string
expected []interface{}
}{
{
name: "ECHO with invalid number of arguments",
commands: []string... | No issues found. | package commands
import (
"testing"
"gotest.tools/v3/assert"
)
func TestEcho(t *testing.T) {
conn := getLocalConnection()
defer conn.Close()
testCases := []struct {
name string
commands []string
expected []interface{}
}{
{
name: "ECHO with invalid number of arguments",
commands: []string... | @@ -0,0 +1,38 @@
+package commands
+
+import (
+ "testing"
+
+ "gotest.tools/v3/assert"
+)
+
+func TestEcho(t *testing.T) {
+ conn := getLocalConnection()
+ defer conn.Close()
+
+ testCases := []struct {
+ name string
+ commands []string
+ expected []interface{}
+ }{
+ {
+ name: "ECHO with invalid number ... | integration_tests/commands/echo_test.go | 0 | Go | 1 | none | 16 | 39 | 39 | true | #622: Add ECHO command | 626 | DiceDB/dice | 10,326 | C | hgupta12 | Review this pull request change.
Language: Go
File: integration_tests/commands/echo_test.go
PR Title: #622: Add ECHO command
BEFORE CODE: package commands
import (
"testing"
"gotest.tools/v3/assert"
)
func TestEcho(t *testing.T) {
conn := getLocalConnection()
defer conn.Close()
testCases := []struct {
na... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
runEvalTests(t, tests, evalPFCOUNT, store)
}
func testEvalHGET(t *testing.T, store *dstore.Store) {
tests := map[string]evalTestCase{
"wrong number of args passed": {
setup: func() {},
input: nil,
output: []byte("-ERR wrong number of arguments for 'hget' command\r\n"),
},
"only key passed": {
set... | No issues found. | runEvalTests(t, tests, evalPFCOUNT, store)
}
func testEvalHGET(t *testing.T, store *dstore.Store) {
tests := map[string]evalTestCase{
"wrong number of args passed": {
setup: func() {},
input: nil,
output: []byte("-ERR wrong number of arguments for 'hget' command\r\n"),
},
"only key passed": {
set... | @@ -85,6 +85,7 @@ func TestEval(t *testing.T) {
testEvalJSONNUMINCRBY(t, store)
testEvalTYPE(t, store)
testEvalCOMMAND(t, store)
+ testEvalJSONOBJKEYS(t, store)
testEvalGETRANGE(t, store)
testEvalPING(t, store)
testEvalSETEX(t, store)
@@ -3168,6 +3169,130 @@ func testEvalCOMMAND(t *testing.T, store *dstore.... | internal/eval/eval_test.go | 0 | Go | 1 | none | 16 | 51 | 51 | true | #498: Add support for JSON.OBJKEYS | 629 | DiceDB/dice | 10,326 | C | iamskp11 | Review this pull request change.
Language: Go
File: internal/eval/eval_test.go
PR Title: #498: Add support for JSON.OBJKEYS
BEFORE CODE: runEvalTests(t, tests, evalPFCOUNT, store)
}
func testEvalHGET(t *testing.T, store *dstore.Store) {
tests := map[string]evalTestCase{
"wrong number of args passed": {
setu... | No issues found. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.