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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
MaxClients int `mapstructure:"maxclients"`
MaxMemory int64 `mapstructure:"maxmemory"`
EvictionPolicy string `mapstructure:"evictionpolicy"`
EvictionRatio float64 `mapstructure:"evictionratio"`
KeysLimit int `mapstr... | KeysLimit is also getting used at `internal/store` Shall we keep this value small as well by default? We don't need these many keys to consider for eviction.
Shall we keep KeysLimit and WatchChanBufSize as two different variables? Hope there's no logical correlation between them | Timeout int32 `mapstructure:"timeout"`
MaxConn int32 `mapstructure:"max-conn"`
ShardCronFrequency time.Duration `mapstructure:"shardcronfrequency"`
MultiplexerPollTimeout time.Duration `mapstructure:"servermultiplexerpolltimeout"`
MaxClients int32 ... | @@ -116,13 +116,13 @@ var baseConfig = Config{
EvictionRatio: 0.9,
KeysLimit: 200000000, | config/config.go | 26 | Go | 0.643 | suggestion | 284 | 51 | 51 | false | Adding default config file to be used when dice server starts | 908 | DiceDB/dice | 10,326 | C | AshwinKul28 | lucifercr07 | Review this pull request change.
Language: Go
File: config/config.go
PR Title: Adding default config file to be used when dice server starts
BEFORE CODE: MaxClients int `mapstructure:"maxclients"`
MaxMemory int64 `mapstructure:"maxmemory"`
EvictionPolicy stri... | KeysLimit is also getting used at `internal/store` Shall we keep this value small as well by default? We don't need these many keys to consider for eviction.
Shall we keep KeysLimit and WatchChanBufSize as two different variables? Hope there's no logical correlation between them | 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 eval
import (
"math"
"strconv"
"testing"
"time"
"github.com/dicedb/dice/internal/clientio"
"github.com/dicedb/dice/internal/errors"
"github.com/dicedb/dice/internal/object"
"github.com/dicedb/dice/internal/store"
"github.com/stretchr/testify/assert"
)
func TestHashMapSetAndGet(t *testing.T) {
hmap ... | I just replaced this line with the below code and the test fails suggesting that the operation is giving no errors for `field4` . Is this expected behaviour or am I missing something?
```
val, err = hmap.incrementFloatValue("field4", 1.0)
val, err = hmap.incrementFloatValue("field4", math.MaxFloat64)
``` |
// Fetching a non-existing key (should return RESP NIL)
val, err = getValueFromHashMap("nonkey", field, store)
assert.Nil(t, err, "Expected no error when fetching a non-existing key from the hashmap")
assert.Equal(t, clientio.RespNIL, val, "Expected the value to give RespNIL")
}
func TestHashMapIncrementFloatValu... | @@ -116,4 +116,14 @@ func TestHashMapIncrementFloatValue(t *testing.T) {
val, err = hmap.incrementFloatValue("field2", 1.0)
assert.NotNil(t, err, "Expected error when incrementing a non-float value")
assert.Equal(t, errors.IntOrFloatErr, err.Error(), "Expected int or float error")
+
+ inf := math.MaxFloat64
+
+ v... | internal/eval/hmap_test.go | 26 | Go | 1 | bug | 310 | 120 | 34 | false | #921: Added Hashmap incrementFloatValue overflow check | 927 | DiceDB/dice | 10,326 | C | ayushsatyam146 | dograprabhav | Review this pull request change.
Language: Go
File: internal/eval/hmap_test.go
PR Title: #921: Added Hashmap incrementFloatValue overflow check
BEFORE CODE: package eval
import (
"math"
"strconv"
"testing"
"time"
"github.com/dicedb/dice/internal/clientio"
"github.com/dicedb/dice/internal/errors"
"github.co... | I just replaced this line with the below code and the test fails suggesting that the operation is giving no errors for `field4` . Is this expected behaviour or am I missing something?
```
val, err = hmap.incrementFloatValue("field4", 1.0)
val, err = hmap.incrementFloatValue("field4", math.MaxFloat64)
``` | 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 async
import (
"gotest.tools/v3/assert"
"testing"
)
func TestHMSET(t *testing.T) {
conn := getLocalConnection()
defer conn.Close()
defer FireCommand(conn, "DEL key key_new")
testCases := []TestCase{
{
commands: []string{"HMSET key field value", "HMSET key field value_new"},
expected: []interfac... | Please add a test case where you are setting multiple fields in a single `HMSET` command, then verify that all of those fields contain the new value. To make this test even more robust, some of these fields could be pre-existing, while others can be new. | package async
import (
"gotest.tools/v3/assert"
"testing"
)
func TestHMSET(t *testing.T) {
conn := getLocalConnection()
defer conn.Close()
defer FireCommand(conn, "DEL key key_new key2")
testCases := []TestCase{
{
commands: []string{"HMSET key field value field2 value2", "HGET key field",
"HGET key fi... | @@ -0,0 +1,42 @@
+package async
+
+import (
+ "gotest.tools/v3/assert"
+ "testing"
+)
+
+func TestHMSET(t *testing.T) { | integration_tests/commands/async/hmset_test.go | 8 | Go | 0.643 | suggestion | 254 | 33 | 33 | false | #651: FEAT: Added support for HMSET | 960 | DiceDB/dice | 10,326 | C | JyotinderSingh | raghavbabbar | Review this pull request change.
Language: Go
File: integration_tests/commands/async/hmset_test.go
PR Title: #651: FEAT: Added support for HMSET
BEFORE CODE: package async
import (
"gotest.tools/v3/assert"
"testing"
)
func TestHMSET(t *testing.T) {
conn := getLocalConnection()
defer conn.Close()
defer FireC... | Please add a test case where you are setting multiple fields in a single `HMSET` command, then verify that all of those fields contain the new value. To make this test even more robust, some of these fields could be pre-existing, while others can be new. | 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 val, ok := responseValue.(clientio.RespType); ok {
responseValue = respArr[val]
}
if bt, ok := responseValue.([]byte); ok {
responseValue = string(bt)
}
respBytes, err := json.Marshal(responseValue)
if err != nil {
writeResponse(conn, []byte("error: marshaling json response"))
con... | @ayushsatyam146 please add test cases around this. May be we can mock the websocket conn for different scenarios using `testify/mock`.
| }
}
if val, ok := responseValue.(clientio.RespType); ok {
responseValue = respArr[val]
}
if bt, ok := responseValue.([]byte); ok {
responseValue = string(bt)
}
respBytes, err := json.Marshal(responseValue)
if err != nil {
writeResponse(conn, []byte("error: marshaling json response"))
con... | @@ -215,11 +219,63 @@ func (s *WebsocketServer) WebsocketHandler(w http.ResponseWriter, r *http.Reques
continue
}
- // Write response
- writeResponse(conn, respBytes)
+ // Write response with retries for transient errors
+ if err := writeResponseWithRetries(conn, respBytes, 3); err != nil {
+ s.logger.Er... | internal/server/websocketServer.go | 26 | Go | 0.5 | suggestion | 138 | 51 | 51 | false | fix: handling multiple failure/error scenarios during socket writes | 983 | DiceDB/dice | 10,326 | C | lucifercr07 | ayushsatyam146 | Review this pull request change.
Language: Go
File: internal/server/websocketServer.go
PR Title: fix: handling multiple failure/error scenarios during socket writes
BEFORE CODE: }
}
if val, ok := responseValue.(clientio.RespType); ok {
responseValue = respArr[val]
}
if bt, ok := responseValue.([]byt... | @ayushsatyam146 please add test cases around this. May be we can mock the websocket conn for different scenarios using `testify/mock`.
| 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
}
} else {
if resp.EvalResponse.Error != nil {
responseValue = resp.EvalResponse.Error.Error()
} else {
responseValue = resp.EvalResponse.Result
}
}
if val, ok := responseValue.(clientio.RespType); ok {
responseValue = respArr[val]
}
if bt, ok := responseValue.([]byte); ok ... | We can extract out `3` to a const | return
}
} else {
if resp.EvalResponse.Error != nil {
responseValue = resp.EvalResponse.Error.Error()
} else {
responseValue = resp.EvalResponse.Result
}
}
if val, ok := responseValue.(clientio.RespType); ok {
responseValue = respArr[val]
}
if bt, ok := responseValue.([]byte); ok ... | @@ -215,11 +219,63 @@ func (s *WebsocketServer) WebsocketHandler(w http.ResponseWriter, r *http.Reques
continue
}
- // Write response
- writeResponse(conn, respBytes)
+ // Write response with retries for transient errors
+ if err := writeResponseWithRetries(conn, respBytes, 3); err != nil { | internal/server/websocketServer.go | 26 | Go | 0.286 | refactor | 33 | 51 | 51 | false | fix: handling multiple failure/error scenarios during socket writes | 983 | DiceDB/dice | 10,326 | C | lucifercr07 | ayushsatyam146 | Review this pull request change.
Language: Go
File: internal/server/websocketServer.go
PR Title: fix: handling multiple failure/error scenarios during socket writes
BEFORE CODE: return
}
} else {
if resp.EvalResponse.Error != nil {
responseValue = resp.EvalResponse.Error.Error()
} else {
resp... | We can extract out `3` to a const | 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. |
}
respBytes, err := json.Marshal(responseValue)
if err != nil {
writeResponse(conn, []byte("error: marshaling json response"))
continue
}
// Write response with retries for transient errors
if err := writeResponseWithRetries(conn, respBytes, 3); err != nil {
s.logger.Error(fmt.Sprintf("Error read... | Let's reduce nesting if possible. | }
respBytes, err := json.Marshal(responseValue)
if err != nil {
writeResponse(conn, []byte("error: marshaling json response"))
continue
}
// Write response with retries for transient errors
if err := WriteResponseWithRetries(conn, respBytes, config.DiceConfig.WebSocket.MaxWriteResponseRetries); err ... | @@ -215,11 +219,63 @@ func (s *WebsocketServer) WebsocketHandler(w http.ResponseWriter, r *http.Reques
continue
}
- // Write response
- writeResponse(conn, respBytes)
+ // Write response with retries for transient errors
+ if err := writeResponseWithRetries(conn, respBytes, 3); err != nil {
+ s.logger.Er... | internal/server/websocketServer.go | 26 | Go | 0.071 | suggestion | 33 | 51 | 51 | false | fix: handling multiple failure/error scenarios during socket writes | 983 | DiceDB/dice | 10,326 | C | lucifercr07 | ayushsatyam146 | Review this pull request change.
Language: Go
File: internal/server/websocketServer.go
PR Title: fix: handling multiple failure/error scenarios during socket writes
BEFORE CODE: }
respBytes, err := json.Marshal(responseValue)
if err != nil {
writeResponse(conn, []byte("error: marshaling json response"))
... | Let's reduce nesting if possible. | 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 writeResponseWithRetries(conn *websocket.Conn, text []byte, maxRetries int) error {
for attempts := 0; attempts < maxRetries; attempts++ {
// Set a write deadline
if err := conn.SetWriteDeadline(time.Now().Add(10 * time.Second)); err != nil {
slog.Error(fmt.Sprintf("Error setting write deadline: %v", er... | Please add a log here, so that it's notified that retries are happening | }
func WriteResponseWithRetries(conn *websocket.Conn, text []byte, maxRetries int) error {
for attempts := 0; attempts < maxRetries; attempts++ {
// Set a write deadline
if err := conn.SetWriteDeadline(time.Now().Add(config.DiceConfig.WebSocket.WriteResponseTimeout)); err != nil {
slog.Error(fmt.Sprintf("Error... | @@ -215,11 +219,63 @@ func (s *WebsocketServer) WebsocketHandler(w http.ResponseWriter, r *http.Reques
continue
}
- // Write response
- writeResponse(conn, respBytes)
+ // Write response with retries for transient errors
+ if err := writeResponseWithRetries(conn, respBytes, 3); err != nil {
+ s.logger.Er... | internal/server/websocketServer.go | 26 | Go | 0.214 | suggestion | 71 | 51 | 51 | false | fix: handling multiple failure/error scenarios during socket writes | 983 | DiceDB/dice | 10,326 | C | lucifercr07 | ayushsatyam146 | Review this pull request change.
Language: Go
File: internal/server/websocketServer.go
PR Title: fix: handling multiple failure/error scenarios during socket writes
BEFORE CODE: }
func writeResponseWithRetries(conn *websocket.Conn, text []byte, maxRetries int) error {
for attempts := 0; attempts < maxRetries; att... | Please add a log here, so that it's notified that retries are happening | 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 (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"log/slog"
"net"
"net/http"
"os"
"sync"
"syscall"
"time"
"github.com/dicedb/dice/config"
"github.com/dicedb/dice/internal/clientio"
diceerrors "github.com/dicedb/dice/internal/errors"
"github.com/dicedb/dice/internal/ops"
"githu... | The time should be configurable, may be we can use timeout from config here. | case syscall.ECONNRESET:
return fmt.Errorf("connection reset by peer: %w", err)
case syscall.ENOBUFS:
return fmt.Errorf("no buffer space available: %w", err)
case syscall.EAGAIN:
// Exponential backoff with jitter
backoffDuration := time.Duration(attempts+1)*100*time.Millisecond + time.Duration(rand.I... | @@ -215,11 +219,63 @@ func (s *WebsocketServer) WebsocketHandler(w http.ResponseWriter, r *http.Reques
continue
}
- // Write response
- writeResponse(conn, respBytes)
+ // Write response with retries for transient errors
+ if err := writeResponseWithRetries(conn, respBytes, 3); err != nil {
+ s.logger.Er... | internal/server/websocketServer.go | 26 | Go | 0.286 | suggestion | 76 | 282 | 36 | false | fix: handling multiple failure/error scenarios during socket writes | 983 | DiceDB/dice | 10,326 | C | lucifercr07 | ayushsatyam146 | Review this pull request change.
Language: Go
File: internal/server/websocketServer.go
PR Title: fix: handling multiple failure/error scenarios during socket writes
BEFORE CODE: package server
import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"log/slog"
"net"
"net/http"
"os"
"sync"
"syscall"
"t... | The time should be configurable, may be we can use timeout from config here. | 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 (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"log/slog"
"net/http"
"sync"
"time"
"github.com/dicedb/dice/config"
"github.com/dicedb/dice/internal/clientio"
diceerrors "github.com/dicedb/dice/internal/errors"
"github.com/dicedb/dice/internal/ops"
"github.com/dicedb/dice/intern... | Shall we just reuse `WriteResponseWithRetries(conn, respBytes, config.DiceConfig.WebSocket.MaxWriteResponseRetries);` for below case also?
```
respBytes, err := json.Marshal(responseValue)
if err != nil {
``` | case syscall.EPIPE:
return fmt.Errorf("broken pipe: %w", err)
case syscall.ECONNRESET:
return fmt.Errorf("connection reset by peer: %w", err)
case syscall.ENOBUFS:
return fmt.Errorf("no buffer space available: %w", err)
case syscall.EAGAIN:
// Exponential backoff with jitter
backoffDuration := ti... | @@ -215,11 +219,78 @@ func (s *WebsocketServer) WebsocketHandler(w http.ResponseWriter, r *http.Reques
continue
}
- // Write response
- writeResponse(conn, respBytes)
+ // Write response with retries for transient errors
+ if err := WriteResponseWithRetries(conn, respBytes, config.DiceConfig.WebSocket.MaxW... | internal/server/websocketServer.go | 26 | Go | 0.857 | suggestion | 213 | 226 | 38 | false | fix: handling multiple failure/error scenarios during socket writes | 983 | DiceDB/dice | 10,326 | C | lucifercr07 | ayushsatyam146 | Review this pull request change.
Language: Go
File: internal/server/websocketServer.go
PR Title: fix: handling multiple failure/error scenarios during socket writes
BEFORE CODE: package server
import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"log/slog"
"net/http"
"sync"
"time"
"github.com/diced... | Shall we just reuse `WriteResponseWithRetries(conn, respBytes, config.DiceConfig.WebSocket.MaxWriteResponseRetries);` for below case also?
```
respBytes, err := json.Marshal(responseValue)
if err != nil {
``` | 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: "Object Encoding check for int",
commands: []string{"SET foo 1", "OBJECT ENCODING foo"},
expected: []interface{}{"OK", "int"},
assertType: []string{"equal", "equal"},
delay: []time.Duration{0, 2 * time.Second},
},
{
name: "Object Encoding check for embstr",
commands: ... | Hi @sashpawar11 , Could you please share why we are testing the cases with delay here? | delay: []time.Duration{0, 0},
cleanup: []string{"DEL foo"},
},
{
name: "Object Encoding check for int",
commands: []string{"SET foo 1", "OBJECT ENCODING foo"},
expected: []interface{}{"OK", "int"},
assertType: []string{"equal", "equal"},
delay: []time.Duration{0, 0},
c... | @@ -25,6 +26,76 @@ func TestObjectCommand(t *testing.T) {
assertType: []string{"equal", "assert", "assert", "equal", "assert"},
delay: []time.Duration{0, 2 * time.Second, 3 * time.Second, 0, 0},
},
+ {
+ name: "Object Encoding check for raw",
+ commands: []string{"SET foo foobarfoobarfoobar... | integration_tests/commands/async/object_test.go | 26 | Go | 0.286 | question | 86 | 51 | 51 | false | #964 Support for OBJECT ENCODING | 1,039 | DiceDB/dice | 10,326 | C | apoorvyadav1111 | sashpawar11 | Review this pull request change.
Language: Go
File: integration_tests/commands/async/object_test.go
PR Title: #964 Support for OBJECT ENCODING
BEFORE CODE: name: "Object Encoding check for int",
commands: []string{"SET foo 1", "OBJECT ENCODING foo"},
expected: []interface{}{"OK", "int"},
asser... | Hi @sashpawar11 , Could you please share why we are testing the cases with delay here? | 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: "Object Encoding check for embstr",
commands: []string{"SET foo bar", "OBJECT ENCODING foo"},
expected: []interface{}{"OK", "embstr"},
assertType: []string{"equal", "equal"},
delay: []time.Duration{0, 0},
},
{
name: "Object Encoding check for deque",
commands: []str... | nit:
```suggestion
delay: []time.Duration{0, 0},
``` | assertType: []string{"equal", "equal"},
delay: []time.Duration{0, 0},
cleanup: []string{"DEL foo"},
},
{
name: "Object Encoding check for embstr",
commands: []string{"SET foo bar", "OBJECT ENCODING foo"},
expected: []interface{}{"OK", "embstr"},
assertType: []string{"equal", "... | @@ -25,6 +26,76 @@ func TestObjectCommand(t *testing.T) {
assertType: []string{"equal", "assert", "assert", "equal", "assert"},
delay: []time.Duration{0, 2 * time.Second, 3 * time.Second, 0, 0},
},
+ {
+ name: "Object Encoding check for raw",
+ commands: []string{"SET foo foobarfoobarfoobar... | integration_tests/commands/async/object_test.go | 26 | Go | 0.571 | suggestion | 63 | 51 | 51 | false | #964 Support for OBJECT ENCODING | 1,039 | DiceDB/dice | 10,326 | C | apoorvyadav1111 | sashpawar11 | Review this pull request change.
Language: Go
File: integration_tests/commands/async/object_test.go
PR Title: #964 Support for OBJECT ENCODING
BEFORE CODE: name: "Object Encoding check for embstr",
commands: []string{"SET foo bar", "OBJECT ENCODING foo"},
expected: []interface{}{"OK", "embstr"},
... | nit:
```suggestion
delay: []time.Duration{0, 0},
``` | 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 key string
if len(cmds[i].Args) > 0 {
key = cmds[i].Args[0]
} else {
key = cmds[i].Cmd
}
sid, rc = w.shardManager.GetShardInfo(key)
rc <- &ops.StoreOp{
SeqID: i,
RequestID: cmds[i].RequestID,
Cmd: cmds[i],
WorkerID: w.id,
ShardID: sid,
Client: nil,... | ```suggestion
func (w *BaseWorker) gather(ctx context.Context, diceDBCmd *cmd.DiceDBCmd, numCmds int, isWatchNotification bool) error {
``` | var key string
if len(cmds[i].Args) > 0 {
key = cmds[i].Args[0]
} else {
key = cmds[i].Cmd
}
sid, rc = w.shardManager.GetShardInfo(key)
rc <- &ops.StoreOp{
SeqID: i,
RequestID: cmds[i].RequestID,
Cmd: cmds[i],
WorkerID: w.id,
ShardID: sid,
Client: nil,... | @@ -293,7 +285,7 @@ func (w *BaseWorker) scatter(ctx context.Context, cmds []*cmd.DiceDBCmd) error {
// gather collects the responses from multiple shards and writes the results into the provided buffer.
// It first waits for responses from all the shards and then processes the result based on the command type (Sin... | internal/worker/worker.go | 26 | Go | 0.857 | suggestion | 141 | 51 | 51 | false | Refactoring to handle Watch command type in the generic flow of command handlers | 1,043 | DiceDB/dice | 10,326 | C | JyotinderSingh | AshwinKul28 | Review this pull request change.
Language: Go
File: internal/worker/worker.go
PR Title: Refactoring to handle Watch command type in the generic flow of command handlers
BEFORE CODE: var key string
if len(cmds[i].Args) > 0 {
key = cmds[i].Args[0]
} else {
key = cmds[i].Cmd
}
sid, rc = w.shard... | ```suggestion
func (w *BaseWorker) gather(ctx context.Context, diceDBCmd *cmd.DiceDBCmd, numCmds int, isWatchNotification bool) error {
``` | 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 = w.isAuthenticated(cmds[0])
if err != nil {
werr := w.ioHandler.Write(ctx, err)
if werr != nil {
w.logger.Debug("Write error, connection closed possibly", slog.Any("error", errors.Join(err, werr)))
return errors.Join(err, werr)
}
}
// executeCommand executes the comman... | I feel this name is a little better?
```suggestion
err := w.executeCommand(execCtx, cmds[0], isWatchNotification)
``` | }
}
err = w.isAuthenticated(cmds[0])
if err != nil {
werr := w.ioHandler.Write(ctx, err)
if werr != nil {
w.logger.Debug("Write error, connection closed possibly", slog.Any("error", errors.Join(err, werr)))
return errors.Join(err, werr)
}
}
// executeCommand executes the comman... | @@ -152,8 +155,8 @@ func (w *BaseWorker) Start(ctx context.Context) error {
}
}
-func (w *BaseWorker) executeCommandHandler(execCtx context.Context, errChan chan error, cmds []*cmd.DiceDBCmd, isWatchNotification bool) {
- err := w.executeCommand(execCtx, cmds[0], isWatchNotification)
+func (w *BaseWorker) executeC... | internal/worker/worker.go | 26 | Go | 0.786 | suggestion | 121 | 51 | 51 | false | Refactoring to handle Watch command type in the generic flow of command handlers | 1,043 | DiceDB/dice | 10,326 | C | JyotinderSingh | AshwinKul28 | Review this pull request change.
Language: Go
File: internal/worker/worker.go
PR Title: Refactoring to handle Watch command type in the generic flow of command handlers
BEFORE CODE: }
}
err = w.isAuthenticated(cmds[0])
if err != nil {
werr := w.ioHandler.Write(ctx, err)
if werr != nil {
w... | I feel this name is a little better?
```suggestion
err := w.executeCommand(execCtx, cmds[0], isWatchNotification)
``` | 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. |
serverWg.Add(1)
go func() {
defer serverWg.Done()
// Run the HTTP server
err := httpServer.Run(ctx)
if err != nil {
if errors.Is(err, context.Canceled) {
logr.Debug("HTTP Server was canceled")
} else if errors.Is(err, diceerrors.ErrAborted) {
logr.Debug("HTTP received abort command")
... | Shall we move this to another func like `func setupProfiling(logr *slog.Logger)`? | asyncServer.InitiateShutdown()
cancel()
}()
// Initialize the HTTP server
httpServer := server.NewHTTPServer(shardManager, logr)
serverWg.Add(1)
go func() {
defer serverWg.Done()
// Run the HTTP server
err := httpServer.Run(ctx)
if err != nil {
if errors.Is(err, context.Canceled) {
... | @@ -153,6 +157,61 @@ func main() {
}
}()
} else {
+ if config.EnableProfiling { | main.go | 26 | Go | 0.429 | refactor | 81 | 51 | 51 | false | Add profiling for DiceDB | 1,048 | DiceDB/dice | 10,326 | C | lucifercr07 | soumya-codes | Review this pull request change.
Language: Go
File: main.go
PR Title: Add profiling for DiceDB
BEFORE CODE: serverWg.Add(1)
go func() {
defer serverWg.Done()
// Run the HTTP server
err := httpServer.Run(ctx)
if err != nil {
if errors.Is(err, context.Canceled) {
logr.Debug("HTTP Server was c... | Shall we move this to another func like `func setupProfiling(logr *slog.Logger)`? | 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. |
serverWg.Add(1)
go func() {
defer serverWg.Done()
// Run the HTTP server
err := httpServer.Run(ctx)
if err != nil {
if errors.Is(err, context.Canceled) {
logr.Debug("HTTP Server was canceled")
} else if errors.Is(err, diceerrors.ErrAborted) {
logr.Debug("HTTP received abort command")
... | Would this lead to panic if `Create` failed? | asyncServer.InitiateShutdown()
cancel()
}()
// Initialize the HTTP server
httpServer := server.NewHTTPServer(shardManager, logr)
serverWg.Add(1)
go func() {
defer serverWg.Done()
// Run the HTTP server
err := httpServer.Run(ctx)
if err != nil {
if errors.Is(err, context.Canceled) {
... | @@ -153,6 +157,61 @@ func main() {
}
}()
} else {
+ if config.EnableProfiling {
+ // Start CPU profiling
+ cpuFile, err := os.Create("cpu.prof")
+ if err != nil {
+ logr.Warn("could not create file cpu.prof: ", slog.Any("error", err))
+ }
+ defer cpuFile.Close() | main.go | 26 | Go | 0.214 | bug | 44 | 51 | 51 | false | Add profiling for DiceDB | 1,048 | DiceDB/dice | 10,326 | C | lucifercr07 | soumya-codes | Review this pull request change.
Language: Go
File: main.go
PR Title: Add profiling for DiceDB
BEFORE CODE: serverWg.Add(1)
go func() {
defer serverWg.Done()
// Run the HTTP server
err := httpServer.Run(ctx)
if err != nil {
if errors.Is(err, context.Canceled) {
logr.Debug("HTTP Server was c... | Would this lead to panic if `Create` failed? | 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(mergedHll, -1, object.ObjTypeString, object.ObjEncodingRaw)
store.Put(destKey, obj)
return clientio.RespOK
}
func evalJSONSTRLEN(args []string, store *dstore.Store) []byte {
if len(args) < 1 {
return diceerrors.NewErrArity("JSON.STRLEN")
}
key := args[0]
if len(args) < 2 {
// no recurs... | nit: can avoid extra code
```suggestion
return diceerrors.NewErrWithFormattedMessage(JSONPathValueTypeErr, strings.ToLower(utils.GetJSONFieldType(jsonData)))
``` | hll := hyperloglog.New()
for _, arg := range args[1:] {
hll.Insert([]byte(arg))
}
obj = store.NewObj(hll, -1, object.ObjTypeString, object.ObjEncodingRaw)
store.Put(key, obj)
return clientio.Encode(1, false)
}
existingHll, ok := obj.Value.(*hyperloglog.Sketch)
if !ok {
return diceerrors.NewErrWit... | @@ -4115,7 +4115,7 @@ func evalJSONSTRLEN(args []string, store *dstore.Store) []byte {
jsonData := obj.Value
if utils.GetJSONFieldType(jsonData) != utils.StringType {
- return diceerrors.NewErrWithFormattedMessage(diceerrors.JSONPathValueTypeErr)
+ return diceerrors.NewErrPathTypeErr(utils.GetJSONFieldType(... | internal/eval/eval.go | 26 | Go | 0.929 | suggestion | 167 | 51 | 51 | false | #1060 JSON.STRLEN no path and type error | 1,064 | DiceDB/dice | 10,326 | C | apoorvyadav1111 | bhima2001 | Review this pull request change.
Language: Go
File: internal/eval/eval.go
PR Title: #1060 JSON.STRLEN no path and type error
BEFORE CODE: obj = store.NewObj(mergedHll, -1, object.ObjTypeString, object.ObjEncodingRaw)
store.Put(destKey, obj)
return clientio.RespOK
}
func evalJSONSTRLEN(args []string, store *dst... | nit: can avoid extra code
```suggestion
return diceerrors.NewErrWithFormattedMessage(JSONPathValueTypeErr, strings.ToLower(utils.GetJSONFieldType(jsonData)))
``` | 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. |
output: []byte("$-1\r\n"),
},
"root not string strlen(object)": {
setup: func() {
key := "EXISTING_KEY"
value := "{\"name\":\"Bhima\",\"age\":10}"
var rootData interface{}
_ = sonic.Unmarshal([]byte(value), &rootData)
obj := store.NewObj(rootData, -1, object.ObjTypeJSON, object.ObjEncoding... | ```suggestion
output: []byte("-WRONGTYPE wrong type of path value - expected string but found integer\r\n"),
``` | input: []string{"NONEXISTENT_KEY"},
output: []byte("$-1\r\n"),
},
"root not string strlen(object)": {
setup: func() {
key := "EXISTING_KEY"
value := "{\"name\":\"Bhima\",\"age\":10}"
var rootData interface{}
_ = sonic.Unmarshal([]byte(value), &rootData)
obj := store.NewObj(rootData, -1... | @@ -2607,17 +2607,53 @@ func testEvalJSONSTRLEN(t *testing.T, store *dstore.Store) {
input: []string{"NONEXISTENT_KEY"},
output: []byte("$-1\r\n"),
},
- "root not string strlen": {
+ "root not string strlen(object)": {
setup: func() {
key := "EXISTING_KEY"
- value := "{\"age\":13,\"name\":\"a\... | internal/eval/eval_test.go | 26 | Go | 0.857 | bug | 117 | 51 | 51 | false | #1060 JSON.STRLEN no path and type error | 1,064 | DiceDB/dice | 10,326 | C | apoorvyadav1111 | bhima2001 | Review this pull request change.
Language: Go
File: internal/eval/eval_test.go
PR Title: #1060 JSON.STRLEN no path and type error
BEFORE CODE: output: []byte("$-1\r\n"),
},
"root not string strlen(object)": {
setup: func() {
key := "EXISTING_KEY"
value := "{\"name\":\"Bhima\",\"age\":10}"
var ... | ```suggestion
output: []byte("-WRONGTYPE wrong type of path value - expected string but found integer\r\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. |
},
expected: []interface{}{"OK", "WRONGTYPE wrong type of path value - expected string but found boolean"},
},
{
name: "STRLEN with no path and object at array",
commands: []HTTPCommand{
{Command: "JSON.SET", Body: map[string]interface{}{"key": "k", "path": "$", "json": []int{1, 2, 3, 4}}},
{Com... | ```suggestion
expected: []interface{}{"OK", "WRONGTYPE wrong type of path value - expected string but found integer"},
``` | },
expected: []interface{}{"OK", "WRONGTYPE wrong type of path value - expected string but found boolean"},
},
{
name: "STRLEN with no path and object at array",
commands: []HTTPCommand{
{Command: "JSON.SET", Body: map[string]interface{}{"key": "k", "path": "$", "json": []int{1, 2, 3, 4}}},
{Com... | @@ -647,6 +647,38 @@ func TestJsonStrlen(t *testing.T) {
},
expected: []interface{}{"OK", []interface{}{float64(5), float64(3)}},
},
+ {
+ name: "STRLEN with no path and object at root",
+ commands: []HTTPCommand{
+ {Command: "JSON.SET", Body: map[string]interface{}{"key": "k", "path": "$", "json": m... | integration_tests/commands/http/json_test.go | 26 | Go | 0.857 | bug | 127 | 51 | 51 | false | #1060 JSON.STRLEN no path and type error | 1,064 | DiceDB/dice | 10,326 | C | apoorvyadav1111 | bhima2001 | Review this pull request change.
Language: Go
File: integration_tests/commands/http/json_test.go
PR Title: #1060 JSON.STRLEN no path and type error
BEFORE CODE: },
expected: []interface{}{"OK", "WRONGTYPE wrong type of path value - expected string but found boolean"},
},
{
name: "STRLEN with no path an... | ```suggestion
expected: []interface{}{"OK", "WRONGTYPE wrong type of path value - expected string but found integer"},
``` | 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(mergedHll, -1, object.ObjTypeString, object.ObjEncodingRaw)
store.Put(destKey, obj)
return clientio.RespOK
}
func evalJSONSTRLEN(args []string, store *dstore.Store) []byte {
if len(args) < 1 {
return diceerrors.NewErrArity("JSON.STRLEN")
}
key := args[0]
if len(args) < 2 {
// no recurs... | suggestion:
```suggestion
currType := strings.ToLower(utils.GetJSONFieldType(jsonData))
if currType == "number"{
currType = "integer"
}
return diceerrors.NewErrWithFormattedMessage(diceerrors.JSONPathVa... | hll := hyperloglog.New()
for _, arg := range args[1:] {
hll.Insert([]byte(arg))
}
obj = store.NewObj(hll, -1, object.ObjTypeString, object.ObjEncodingRaw)
store.Put(key, obj)
return clientio.Encode(1, false)
}
existingHll, ok := obj.Value.(*hyperloglog.Sketch)
if !ok {
return diceerrors.NewErrWit... | @@ -4115,7 +4115,7 @@ func evalJSONSTRLEN(args []string, store *dstore.Store) []byte {
jsonData := obj.Value
if utils.GetJSONFieldType(jsonData) != utils.StringType {
- return diceerrors.NewErrWithFormattedMessage(diceerrors.JSONPathValueTypeErr)
+ return diceerrors.NewErrWithFormattedMessage(diceerrors.JSO... | internal/eval/eval.go | 26 | Go | 0.929 | suggestion | 346 | 51 | 51 | false | #1060 JSON.STRLEN no path and type error | 1,064 | DiceDB/dice | 10,326 | C | apoorvyadav1111 | bhima2001 | Review this pull request change.
Language: Go
File: internal/eval/eval.go
PR Title: #1060 JSON.STRLEN no path and type error
BEFORE CODE: obj = store.NewObj(mergedHll, -1, object.ObjTypeString, object.ObjEncodingRaw)
store.Put(destKey, obj)
return clientio.RespOK
}
func evalJSONSTRLEN(args []string, store *dst... | suggestion:
```suggestion
currType := strings.ToLower(utils.GetJSONFieldType(jsonData))
if currType == "number"{
currType = "integer"
}
return diceerrors.NewErrWithFormattedMessage(diceerrors.JSONPathVa... | 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. |
hwConfig, err := GetHardwareMeta()
if err != nil {
return
}
payload := &PingPayload{
HardwareConfig: hwConfig,
InstanceID: config.DiceConfig.InstanceID,
Version: config.DiceConfig.Server.Version,
Err: err,
Date: time.Now().UTC().Format("2006-01-02 15:04:05"),
DBConfig:... | @JyotinderSingh please add your thoughts around the `panic` here? Was thinking should we panic if the `PING` fails or we can log error?
We can add integration test around it so that we get to know if token expires or something. | func Ping(logger *slog.Logger) {
hwConfig, err := GetHardwareMeta()
if err != nil {
return
}
payload := &PingPayload{
HardwareConfig: hwConfig,
InstanceID: config.DiceConfig.InstanceID,
Version: config.DiceConfig.Server.Version,
Err: err,
Date: time.Now().UTC().Format("2... | @@ -37,18 +43,18 @@ func Ping() {
DBConfig: DBConfig{},
}
- url := "https://api.us-east.aws.tinybird.co/v0/events?name=ping"
b, _ := json.Marshal(payload)
+ ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
+ defer cancel()
- req, _ := http.NewRequestWithContext(context.Background... | internal/observability/ping.go | 26 | Go | 0.786 | bug | 228 | 30 | 33 | false | Fix lint issues for master build | 1,069 | DiceDB/dice | 10,326 | C | lucifercr07 | lucifercr07 | Review this pull request change.
Language: Go
File: internal/observability/ping.go
PR Title: Fix lint issues for master build
BEFORE CODE: hwConfig, err := GetHardwareMeta()
if err != nil {
return
}
payload := &PingPayload{
HardwareConfig: hwConfig,
InstanceID: config.DiceConfig.InstanceID,
Version... | @JyotinderSingh please add your thoughts around the `panic` here? Was thinking should we panic if the `PING` fails or we can log error?
We can add integration test around it so that we get to know if token expires or something. | 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. |
added := 0
for i := 1; i < len(args); i += 2 {
scoreStr := args[i]
member := args[i+1]
score, err := strconv.ParseFloat(scoreStr, 64)
if err != nil || math.IsNaN(score) {
return &EvalResponse{
Result: nil,
Error: diceerrors.ErrInvalidNumberFormat,
}
}
wasInserted := sortedSet.Upsert(scor... | We don't need to send encoded responses from evals. Please send raw responses so that it won't be protocol specific. |
added := 0
for i := 1; i < len(args); i += 2 {
scoreStr := args[i]
member := args[i+1]
score, err := strconv.ParseFloat(scoreStr, 64)
if err != nil || math.IsNaN(score) {
return &EvalResponse{
Result: nil,
Error: diceerrors.ErrInvalidNumberFormat,
}
}
wasInserted := sortedSet.Upsert(scor... | @@ -316,3 +318,133 @@ func evalSETEX(args []string, store *dstore.Store) *EvalResponse {
return evalSET(newArgs, store)
}
+
+// evalZADD adds all the specified members with the specified scores to the sorted set stored at key.
+// If a specified member is already a member of the sorted set, the score is updated an... | internal/eval/store_eval.go | 26 | Go | 0.357 | suggestion | 117 | 51 | 51 | false | #1034 Command Migration: ('ZADD', 'ZRANGE') (Issue #1034) | 1,077 | DiceDB/dice | 10,326 | C | AshwinKul28 | benjaminmishra | Review this pull request change.
Language: Go
File: internal/eval/store_eval.go
PR Title: #1034 Command Migration: ('ZADD', 'ZRANGE') (Issue #1034)
BEFORE CODE:
added := 0
for i := 1; i < len(args); i += 2 {
scoreStr := args[i]
member := args[i+1]
score, err := strconv.ParseFloat(scoreStr, 64)
if err !=... | We don't need to send encoded responses from evals. Please send raw responses so that it won't be protocol specific. | 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: nil,
Error: diceerrors.ErrInvalidNumberFormat,
}
}
obj := store.Get(key)
if obj == nil {
return &EvalResponse{
Result: clientio.Encode([]string{}, false),
Error: nil,
}
}
ss, errMsg := sortedset.FromObject(obj)
if errMsg != nil {
return &EvalResponse{
Result: nil,
Error: di... | We don't need to send encoded responses from evals. Please send raw responses so that it won't be protocol specific. | Result: nil,
Error: diceerrors.ErrInvalidNumberFormat,
}
}
obj := store.Get(key)
if obj == nil {
return &EvalResponse{
Result: []string{},
Error: nil,
}
}
sortedSet, errMsg := sortedset.FromObject(obj)
if errMsg != nil {
return &EvalResponse{
Result: nil,
Error: diceerrors.ErrWrong... | @@ -316,3 +318,133 @@ func evalSETEX(args []string, store *dstore.Store) *EvalResponse {
return evalSET(newArgs, store)
}
+
+// evalZADD adds all the specified members with the specified scores to the sorted set stored at key.
+// If a specified member is already a member of the sorted set, the score is updated an... | internal/eval/store_eval.go | 26 | Go | 0.357 | suggestion | 116 | 30 | 30 | false | #1034 Command Migration: ('ZADD', 'ZRANGE') (Issue #1034) | 1,077 | DiceDB/dice | 10,326 | C | AshwinKul28 | benjaminmishra | Review this pull request change.
Language: Go
File: internal/eval/store_eval.go
PR Title: #1034 Command Migration: ('ZADD', 'ZRANGE') (Issue #1034)
BEFORE CODE: Result: nil,
Error: diceerrors.ErrInvalidNumberFormat,
}
}
obj := store.Get(key)
if obj == nil {
return &EvalResponse{
Result: clientio.E... | We don't need to send encoded responses from evals. Please send raw responses so that it won't be protocol specific. | 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. |
// added := 0
// for i := 1; i < len(args); i += 2 {
// scoreStr := args[i]
// member := args[i+1]
// score, err := strconv.ParseFloat(scoreStr, 64)
// if err != nil || math.IsNaN(score) {
// return diceerrors.NewErrWithMessage(diceerrors.InvalidFloatErr)
// }
// wasInserted := ss.Upsert(score, membe... | Please remove the old eval function (commented code) | errWithMessage := object.AssertTypeAndEncoding(obj.TypeEncoding, object.ObjTypeJSON, object.ObjEncodingJSON)
if errWithMessage != nil {
return errWithMessage
}
jsonData := obj.Value
if path == defaultRootPath {
resp := parseJSONStructure(jsonData, false)
return clientio.Encode(resp, false)
}
// if path ... | @@ -4723,98 +4723,98 @@ func parseJSONStructure(jsonData interface{}, nested bool) (resp []any) {
// evalZADD adds all the specified members with the specified scores to the sorted set stored at key.
// If a specified member is already a member of the sorted set, the score is updated and the element reinserted at the... | internal/eval/eval.go | 26 | Go | 0.286 | suggestion | 52 | 51 | 51 | false | #1034 Command Migration: ('ZADD', 'ZRANGE') (Issue #1034) | 1,077 | DiceDB/dice | 10,326 | C | AshwinKul28 | benjaminmishra | Review this pull request change.
Language: Go
File: internal/eval/eval.go
PR Title: #1034 Command Migration: ('ZADD', 'ZRANGE') (Issue #1034)
BEFORE CODE: // added := 0
// for i := 1; i < len(args); i += 2 {
// scoreStr := args[i]
// member := args[i+1]
// score, err := strconv.ParseFloat(scoreStr, 64)
// ... | Please remove the old eval function (commented code) | 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. |
resp = append(resp, key)
resp = append(resp, parseJSONStructure(value, true)...)
}
// wrap in another array to offset print
if nested {
resp = []interface{}{resp}
}
case []interface{}:
resp = append(resp, "[")
for _, value := range json {
resp = append(resp, parseJSONStructure(value, true)...)
... | Please remove the old eval function (commented code) |
store.Put(key, store.NewObj(storedValue, -1, oType, oEnc))
return clientio.Encode(len(value), false)
}
// Key exists path
_, currentEnc := object.ExtractTypeEncoding(obj)
var currentValueStr string
switch currentEnc {
case object.ObjEncodingInt:
// If the encoding is an integer, convert the current value... | @@ -4723,98 +4723,98 @@ func parseJSONStructure(jsonData interface{}, nested bool) (resp []any) {
// evalZADD adds all the specified members with the specified scores to the sorted set stored at key.
// If a specified member is already a member of the sorted set, the score is updated and the element reinserted at the... | internal/eval/eval.go | 26 | Go | 0.286 | suggestion | 52 | 51 | 51 | false | #1034 Command Migration: ('ZADD', 'ZRANGE') (Issue #1034) | 1,077 | DiceDB/dice | 10,326 | C | AshwinKul28 | benjaminmishra | Review this pull request change.
Language: Go
File: internal/eval/eval.go
PR Title: #1034 Command Migration: ('ZADD', 'ZRANGE') (Issue #1034)
BEFORE CODE: resp = append(resp, key)
resp = append(resp, parseJSONStructure(value, true)...)
}
// wrap in another array to offset print
if nested {
resp = []i... | Please remove the old eval function (commented code) | 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 wg sync.WaitGroup
// Run the test server
// This is a synchronous method, because internally it
// checks for available port and then forks a goroutine
// to start the server
opts := TestServerOptions{
Port: testPort1,
Logger: l,
}
ctx, cancel := context.WithCancel(context.Background())
RunWebsocket... | Shall we just `defer cancel()` after L27? | var wg sync.WaitGroup
// Run the test server
// This is a synchronous method, because internally it
// checks for available port and then forks a goroutine
// to start the server
opts := TestServerOptions{
Port: testPort1,
Logger: l,
}
ctx, cancel := context.WithCancel(context.Background())
defer cancel... | @@ -37,8 +38,8 @@ func TestMain(m *testing.M) {
// abort
conn := executor.ConnectToServer()
executor.FireCommand(conn, "abort")
- executor.DisconnectServer(conn)
+ cancel() | integration_tests/commands/websocket/main_test.go | 26 | Go | 0.214 | question | 41 | 30 | 30 | false | Fixed bugs in Websocket Integration Tests | 1,142 | DiceDB/dice | 10,326 | C | lucifercr07 | psrvere | Review this pull request change.
Language: Go
File: integration_tests/commands/websocket/main_test.go
PR Title: Fixed bugs in Websocket Integration Tests
BEFORE CODE: var wg sync.WaitGroup
// Run the test server
// This is a synchronous method, because internally it
// checks for available port and then forks ... | Shall we just `defer cancel()` after L27? | 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. |
http.Error(writer, "Internal Server Error", http.StatusInternalServerError)
return
}
flusher, ok := writer.(http.Flusher)
if !ok {
http.Error(writer, "Streaming unsupported", http.StatusInternalServerError)
return
}
flusher.Flush() // Flush the response to send it to the client
}
func (s *HTTPServer) wr... | Can we have more code comments here to better understand for new users? | http.Error(writer, "Internal Server Error", http.StatusInternalServerError)
return
}
flusher, ok := writer.(http.Flusher)
if !ok {
http.Error(writer, "Streaming unsupported", http.StatusInternalServerError)
return
}
flusher.Flush() // Flush the response to send it to the client
}
func (s *HTTPServer) wr... | @@ -326,33 +329,20 @@ func (s *HTTPServer) writeQWatchResponse(writer http.ResponseWriter, response in
}
func (s *HTTPServer) writeResponse(writer http.ResponseWriter, result *ops.StoreResponse, diceDBCmd *cmd.DiceDBCmd) {
- _, ok := WorkerCmdsMeta[diceDBCmd.Cmd]
- var rp *clientio.RESPParser
+ var (
+ responseVal... | internal/server/httpServer.go | 26 | Go | 0.286 | question | 72 | 51 | 51 | false | Refactor HTTP response | 1,150 | DiceDB/dice | 10,326 | C | AshwinKul28 | lucifercr07 | Review this pull request change.
Language: Go
File: internal/server/httpServer.go
PR Title: Refactor HTTP response
BEFORE CODE: http.Error(writer, "Internal Server Error", http.StatusInternalServerError)
return
}
flusher, ok := writer.(http.Flusher)
if !ok {
http.Error(writer, "Streaming unsupported", htt... | Can we have more code comments here to better understand for new users? | 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
}
_, err = writer.Write(responseJSON)
if err != nil {
slog.Error("Error writing response", "error", err)
}
}
func createHTTPResponse(responseValue interface{}) utils.HTTPResponse {
respArr := []string{
"(nil)", // Represents a RESP Nil Bulk String, which indicates a null value.
"OK", // Repre... | A one-liner comment about this functionality would be helpful here. | if err != nil {
slog.Error("Error marshaling response", "error", err)
http.Error(writer, "Internal Server Error", http.StatusInternalServerError)
return
}
_, err = writer.Write(responseJSON)
if err != nil {
slog.Error("Error writing response", "error", err)
}
}
func createHTTPResponse(responseValue inter... | @@ -376,36 +414,40 @@ func (s *HTTPServer) writeResponse(writer http.ResponseWriter, result *ops.Store
"*0", // Represents an empty RESP Array.
}
- if val, ok := responseValue.(clientio.RespType); ok {
- responseValue = respArr[val]
- }
+ switch v := responseValue.(type) {
+ case []interface{}: | internal/server/httpServer.go | 26 | Go | 0.214 | suggestion | 68 | 51 | 51 | false | Refactor HTTP response | 1,150 | DiceDB/dice | 10,326 | C | AshwinKul28 | lucifercr07 | Review this pull request change.
Language: Go
File: internal/server/httpServer.go
PR Title: Refactor HTTP response
BEFORE CODE: return
}
_, err = writer.Write(responseJSON)
if err != nil {
slog.Error("Error writing response", "error", err)
}
}
func createHTTPResponse(responseValue interface{}) utils.HTTPR... | A one-liner comment about this functionality would be helpful here. | 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. |
)
os.Exit(1)
}
return clientio.NewRESPParser(conn)
}
func RunTestServer(wg *sync.WaitGroup, opt TestServerOptions) {
logr := logger.New(logger.Opts{WithTimestamp: true})
slog.SetDefault(logr)
config.DiceConfig.Network.IOBufferLength = 16
config.DiceConfig.Persistence.WriteAOFOnCleanup = false
if opt.Port !... | declare this in the same manner as the queryWatchChan and cmdWatchChan to maintain consistency. Ideally these definitions should be clubbed together. | os.Exit(1)
}
return clientio.NewRESPParser(conn)
}
func RunTestServer(wg *sync.WaitGroup, opt TestServerOptions) {
slog.SetDefault(logger.New())
config.DiceConfig.Network.IOBufferLength = 16
config.DiceConfig.Persistence.WriteAOFOnCleanup = false
if opt.Port != 0 {
config.DiceConfig.AsyncServer.Port = opt.P... | @@ -127,8 +128,11 @@ func RunTestServer(wg *sync.WaitGroup, opt TestServerOptions) {
gec := make(chan error)
shardManager := shard.NewShardManager(1, queryWatchChan, cmdWatchChan, gec, logr)
workerManager := worker.NewWorkerManager(20000, shardManager)
+ var (
+ cmdWatchSubscriptionChan chan watchmanager.WatchSu... | integration_tests/commands/resp/setup.go | 26 | Go | 0.429 | suggestion | 149 | 51 | 51 | false | Changed scope of CmdWatchSubscriptionChan to local | 1,169 | DiceDB/dice | 10,326 | C | JyotinderSingh | KanniShashankh | Review this pull request change.
Language: Go
File: integration_tests/commands/resp/setup.go
PR Title: Changed scope of CmdWatchSubscriptionChan to local
BEFORE CODE: )
os.Exit(1)
}
return clientio.NewRESPParser(conn)
}
func RunTestServer(wg *sync.WaitGroup, opt TestServerOptions) {
logr := logger.New(logg... | declare this in the same manner as the queryWatchChan and cmdWatchChan to maintain consistency. Ideally these definitions should be clubbed together. | 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 watchmanager
import (
"context"
"log/slog"
"sync"
"github.com/dicedb/dice/internal/cmd"
dstore "github.com/dicedb/dice/internal/store"
)
type (
WatchSubscription struct {
Subscribe bool // Subscribe is true for subscribe, false for unsubscribe. Required.
AdhocReqChan chan *cmd.Dic... | We can add a comment here explaining the purpose of this channel, same as the other members of this struct. | package watchmanager
import (
"context"
"log/slog"
"sync"
"github.com/dicedb/dice/internal/cmd"
dstore "github.com/dicedb/dice/internal/store"
)
type (
WatchSubscription struct {
Subscribe bool // Subscribe is true for subscribe, false for unsubscribe. Required.
AdhocReqChan chan *cmd.Dic... | @@ -18,30 +18,30 @@ type (
}
Manager struct {
- querySubscriptionMap map[string]map[uint32]struct{} // querySubscriptionMap is a map of Key -> [fingerprint1, fingerprint2, ...]
- tcpSubscriptionMap map[uint32]map[chan *cmd.DiceDBCmd]struct{} // tcpSubscriptionMap is a map of fingerprint -> [clien... | internal/watchmanager/watch_manager.go | 24 | Go | 0.357 | suggestion | 107 | 49 | 49 | false | Changed scope of CmdWatchSubscriptionChan to local | 1,169 | DiceDB/dice | 10,326 | C | JyotinderSingh | KanniShashankh | Review this pull request change.
Language: Go
File: internal/watchmanager/watch_manager.go
PR Title: Changed scope of CmdWatchSubscriptionChan to local
BEFORE CODE: package watchmanager
import (
"context"
"log/slog"
"sync"
"github.com/dicedb/dice/internal/cmd"
dstore "github.com/dicedb/dice/internal/store"
)... | We can add a comment here explaining the purpose of this channel, same as the other members of this struct. | 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. |
shardManager := shard.NewShardManager(uint8(numCores), queryWatchChan, cmdWatchChan, serverErrCh, logr)
wg := sync.WaitGroup{}
wg.Add(1)
go func() {
defer wg.Done()
shardManager.Run(ctx)
}()
var serverWg sync.WaitGroup
if config.EnableMultiThreading {
if config.EnableProfiling {
stopProfiling, err :... | declare this similar to how the other channels are declared to maintain consistency. | }
// Get the number of available CPU cores on the machine using runtime.NumCPU().
// This determines the total number of logical processors that can be utilized
// for parallel execution. Setting the maximum number of CPUs to the available
// core count ensures the application can make full use of all available h... | @@ -123,7 +126,10 @@ func main() {
}
workerManager := worker.NewWorkerManager(config.DiceConfig.Performance.MaxClients, shardManager)
- respServer := resp.NewServer(shardManager, workerManager, cmdWatchChan, serverErrCh, logr)
+ var (
+ cmdWatchSubscriptionChan chan watchmanager.WatchSubscription
+ ) | main.go | 26 | Go | 0.214 | style | 84 | 51 | 51 | false | Changed scope of CmdWatchSubscriptionChan to local | 1,169 | DiceDB/dice | 10,326 | C | JyotinderSingh | KanniShashankh | Review this pull request change.
Language: Go
File: main.go
PR Title: Changed scope of CmdWatchSubscriptionChan to local
BEFORE CODE: shardManager := shard.NewShardManager(uint8(numCores), queryWatchChan, cmdWatchChan, serverErrCh, logr)
wg := sync.WaitGroup{}
wg.Add(1)
go func() {
defer wg.Done()
shardMa... | declare this similar to how the other channels are declared to maintain consistency. | 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 (s *WebsocketServer) WebsocketHandler(w http.ResponseWriter, r *http.Request) {
// upgrade http connection to websocket
conn, err := s.upgrader.Upgrade(w, r, nil)
if err != nil {
return
}
// closing handshake
defer func() {
closeErr := conn.WriteMessage(websocket.CloseMessage, websocket.FormatCloseMess... | This doesn't need to be logged. |
func (s *WebsocketServer) WebsocketHandler(w http.ResponseWriter, r *http.Request) {
// upgrade http connection to websocket
conn, err := s.upgrader.Upgrade(w, r, nil)
if err != nil {
return
}
// closing handshake
defer func() {
closeErr := conn.WriteMessage(websocket.CloseMessage, websocket.FormatCloseMess... | @@ -120,20 +120,30 @@ func (s *WebsocketServer) WebsocketHandler(w http.ResponseWriter, r *http.Reques
// closing handshake
defer func() {
- _ = conn.WriteMessage(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseNormalClosure, "close 1000 (normal)"))
+ closeErr := conn.WriteMessage(websocket.... | internal/server/websocketServer.go | 26 | Go | 0.071 | suggestion | 31 | 51 | 51 | false | Issue-1103 - Fixing broken pipe errors | 1,170 | DiceDB/dice | 10,326 | C | JyotinderSingh | Kannav02 | Review this pull request change.
Language: Go
File: internal/server/websocketServer.go
PR Title: Issue-1103 - Fixing broken pipe errors
BEFORE CODE:
func (s *WebsocketServer) WebsocketHandler(w http.ResponseWriter, r *http.Request) {
// upgrade http connection to websocket
conn, err := s.upgrader.Upgrade(w, r, n... | This doesn't need to be logged. | 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. |
// closing handshake
defer func() {
closeErr := conn.WriteMessage(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseNormalClosure, "close 1000 (normal)"))
if closeErr != nil {
slog.Warn("Error during closing handshake", slog.Any("error", closeErr))
}
conn.Close()
}()
maxRetries := conf... | This does not need to be logged. | // closing handshake
defer func() {
closeErr := conn.WriteMessage(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseNormalClosure, "close 1000 (normal)"))
if closeErr != nil {
slog.Debug("Error during closing handshake", slog.Any("error", closeErr))
}
conn.Close()
}()
maxRetries := con... | @@ -120,20 +120,30 @@ func (s *WebsocketServer) WebsocketHandler(w http.ResponseWriter, r *http.Reques
// closing handshake
defer func() {
- _ = conn.WriteMessage(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseNormalClosure, "close 1000 (normal)"))
+ closeErr := conn.WriteMessage(websocket.... | internal/server/websocketServer.go | 26 | Go | 0.071 | suggestion | 32 | 51 | 51 | false | Issue-1103 - Fixing broken pipe errors | 1,170 | DiceDB/dice | 10,326 | C | JyotinderSingh | Kannav02 | Review this pull request change.
Language: Go
File: internal/server/websocketServer.go
PR Title: Issue-1103 - Fixing broken pipe errors
BEFORE CODE: // closing handshake
defer func() {
closeErr := conn.WriteMessage(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseNormalClosure, "close 1000 (n... | This does not need to be logged. | 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 wasInserted {
added += 1
}
}
obj = store.NewObj(sortedSet, -1, object.ObjTypeSortedSet, object.ObjEncodingBTree)
store.Put(key, obj, dstore.WithPutCmd(dstore.ZAdd))
return &EvalResponse{
Result: added,
Error: nil,
}
}
func parseScore(input string) (float64, error) {
switch input {
case "-inf":
... | To maintain consistency, lets add a short function description, which will appear as function summary. Look at other functions to see what can be added. | if wasInserted {
added += 1
}
}
obj = store.NewObj(sortedSet, -1, object.ObjTypeSortedSet, object.ObjEncodingBTree)
store.Put(key, obj, dstore.WithPutCmd(dstore.ZAdd))
return &EvalResponse{
Result: added,
Error: nil,
}
}
// The ZCOUNT command in DiceDB counts the number of members in a sorted set at... | @@ -473,6 +473,62 @@ func evalZADD(args []string, store *dstore.Store) *EvalResponse {
}
}
+func parseScore(input string) (float64, error) {
+ switch input {
+ case "-inf":
+ return math.Inf(-1), nil
+ case "+inf":
+ return math.Inf(1), nil
+ default:
+ return strconv.ParseFloat(input, 64)
+ }
+}
+
+func evalZC... | internal/eval/store_eval.go | 26 | Go | 0.357 | style | 152 | 51 | 51 | false | #1130: Adds support for command ZCOUNT | 1,171 | DiceDB/dice | 10,326 | C | iamskp11 | tarun-29 | Review this pull request change.
Language: Go
File: internal/eval/store_eval.go
PR Title: #1130: Adds support for command ZCOUNT
BEFORE CODE: if wasInserted {
added += 1
}
}
obj = store.NewObj(sortedSet, -1, object.ObjTypeSortedSet, object.ObjEncodingBTree)
store.Put(key, obj, dstore.WithPutCmd(dstore.ZA... | To maintain consistency, lets add a short function description, which will appear as function summary. Look at other functions to see what can be added. | 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. |
wasInserted := sortedSet.Upsert(score, member)
if wasInserted {
added += 1
}
}
obj = store.NewObj(sortedSet, -1, object.ObjTypeSortedSet, object.ObjEncodingBTree)
store.Put(key, obj, dstore.WithPutCmd(dstore.ZAdd))
return &EvalResponse{
Result: added,
Error: nil,
}
}
func parseScore(input string)... | Isn't this a utility method, and should be moved to util folder? Looks like a common functionality which may be used in some other commands. | wasInserted := sortedSet.Upsert(score, member)
if wasInserted {
added += 1
}
}
obj = store.NewObj(sortedSet, -1, object.ObjTypeSortedSet, object.ObjEncodingBTree)
store.Put(key, obj, dstore.WithPutCmd(dstore.ZAdd))
return &EvalResponse{
Result: added,
Error: nil,
}
}
// The ZCOUNT command in Dice... | @@ -473,6 +473,62 @@ func evalZADD(args []string, store *dstore.Store) *EvalResponse {
}
}
+func parseScore(input string) (float64, error) {
+ switch input {
+ case "-inf":
+ return math.Inf(-1), nil
+ case "+inf":
+ return math.Inf(1), nil
+ default:
+ return strconv.ParseFloat(input, 64)
+ }
+} | internal/eval/store_eval.go | 26 | Go | 0.429 | refactor | 140 | 51 | 51 | false | #1130: Adds support for command ZCOUNT | 1,171 | DiceDB/dice | 10,326 | C | iamskp11 | tarun-29 | Review this pull request change.
Language: Go
File: internal/eval/store_eval.go
PR Title: #1130: Adds support for command ZCOUNT
BEFORE CODE: wasInserted := sortedSet.Upsert(score, member)
if wasInserted {
added += 1
}
}
obj = store.NewObj(sortedSet, -1, object.ObjTypeSortedSet, object.ObjEncodingBTree... | Isn't this a utility method, and should be moved to util folder? Looks like a common functionality which may be used in some other commands. | 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: []HTTPCommand{
{Command: "ZADD", Body: map[string]interface{}{"key": "myzset", "values": [...]string{"5", "member1", "15", "member2", "25", "member3"}}},
{Command: "ZCOUNT", Body: map[string]interface{}{"key": "myzset", "values": [...]string{"30", "50"}}},
},
expected: []interface{}{float64(3... | Please add a clean up at the end of the testcase to ensure the further tests are not effected from the last test case | {Command: "ZADD", Body: map[string]interface{}{"key": "myzset", "values": [...]string{"5", "member1", "15", "member2", "25", "member3"}}},
{Command: "ZCOUNT", Body: map[string]interface{}{"key": "myzset", "values": [...]string{"30", "50"}}},
},
expected: []interface{}{float64(3), float64(0)}, // Expecting... | @@ -105,3 +106,83 @@ func TestZPOPMIN(t *testing.T) {
})
}
}
+
+func TestZCOUNT(t *testing.T) {
+ exec := NewHTTPCommandExecutor()
+ testCases := []struct {
+ name string
+ commands []HTTPCommand
+ expected []interface{}
+ }{
+ {
+ name: "ZCOUNT on non-existent key",
+ commands: []HTTPCommand{
+ {C... | integration_tests/commands/http/zset_test.go | 26 | Go | 0.357 | refactor | 117 | 40 | 48 | false | #1130: Adds support for command ZCOUNT | 1,171 | DiceDB/dice | 10,326 | C | apoorvyadav1111 | tarun-29 | Review this pull request change.
Language: Go
File: integration_tests/commands/http/zset_test.go
PR Title: #1130: Adds support for command ZCOUNT
BEFORE CODE: commands: []HTTPCommand{
{Command: "ZADD", Body: map[string]interface{}{"key": "myzset", "values": [...]string{"5", "member1", "15", "member2", "25", ... | Please add a clean up at the end of the testcase to ensure the further tests are not effected from the last test case | 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 &EvalResponse{
Result: added,
Error: nil,
}
}
// The ZCOUNT command in DiceDB counts the number of members in a sorted set at the specified key
// whose scores fall within a given range. The command takes three arguments: the key of the sorted set
// the minimum score, and the maximum score.
func evalZCO... | Please verify the order in which ZCOUNT validates the arguments. Here we are returning 0 even for below command:
```bash
zcount key a b
``` | return &EvalResponse{
Result: added,
Error: nil,
}
}
// The ZCOUNT command in DiceDB counts the number of members in a sorted set at the specified key
// whose scores fall within a given range. The command takes three arguments: the key of the sorted set
// the minimum score, and the maximum score.
func evalZCO... | @@ -473,6 +473,54 @@ func evalZADD(args []string, store *dstore.Store) *EvalResponse {
}
}
+// The ZCOUNT command in DiceDB counts the number of members in a sorted set at the specified key
+// whose scores fall within a given range. The command takes three arguments: the key of the sorted set
+// the minimum scor... | internal/eval/store_eval.go | 26 | Go | 0.714 | suggestion | 142 | 51 | 51 | false | #1130: Adds support for command ZCOUNT | 1,171 | DiceDB/dice | 10,326 | C | apoorvyadav1111 | tarun-29 | Review this pull request change.
Language: Go
File: internal/eval/store_eval.go
PR Title: #1130: Adds support for command ZCOUNT
BEFORE CODE: return &EvalResponse{
Result: added,
Error: nil,
}
}
// The ZCOUNT command in DiceDB counts the number of members in a sorted set at the specified key
// whose scores... | Please verify the order in which ZCOUNT validates the arguments. Here we are returning 0 even for below command:
```bash
zcount key a b
``` | 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 &EvalResponse{
Result: nil,
Error: diceerrors.ErrWrongArgumentCount("ZCOUNT"),
}
}
key := args[0]
obj := store.Get(key)
if obj == nil {
return &EvalResponse{
Result: 0,
Error: nil,
}
}
var sortedSet *sortedset.Set
var err []byte
sortedSet, err = sortedset.FromObject(obj)
if err ... | Can we try using `strconv.ParseFloat(var, 64)` directly here instead? ZADD parses the score this way. Can you please verify if we are handling -inf/inf in ZADD?
Thanks | // 1. Check no of arguments
return &EvalResponse{
Result: nil,
Error: diceerrors.ErrWrongArgumentCount("ZCOUNT"),
}
}
key := args[0]
minArg := args[1]
maxArg := args[2]
// 2. Parse the min and max score arguments
minValue, errMin := strconv.ParseFloat(minArg, 64)
maxValue, errMax := strconv.ParseF... | @@ -473,6 +473,54 @@ func evalZADD(args []string, store *dstore.Store) *EvalResponse {
}
}
+// The ZCOUNT command in DiceDB counts the number of members in a sorted set at the specified key
+// whose scores fall within a given range. The command takes three arguments: the key of the sorted set
+// the minimum scor... | internal/eval/store_eval.go | 26 | Go | 0.571 | question | 171 | 51 | 51 | false | #1130: Adds support for command ZCOUNT | 1,171 | DiceDB/dice | 10,326 | C | apoorvyadav1111 | tarun-29 | Review this pull request change.
Language: Go
File: internal/eval/store_eval.go
PR Title: #1130: Adds support for command ZCOUNT
BEFORE CODE: return &EvalResponse{
Result: nil,
Error: diceerrors.ErrWrongArgumentCount("ZCOUNT"),
}
}
key := args[0]
obj := store.Get(key)
if obj == nil {
return &Eval... | Can we try using `strconv.ParseFloat(var, 64)` directly here instead? ZADD parses the score this way. Can you please verify if we are handling -inf/inf in ZADD?
Thanks | 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 (
TxnCommands map[string]bool
serverID string
diceCommandsCount int
)
// EvalResponse represents the response of an evaluation operation for a command from store.
// It contains the sequence ID, the result of the store operation, and any error encountered during the operation.
type EvalRespons... | Let's remove this directive (it anyway does nothing on newer versions of Go) | )
var (
TxnCommands map[string]bool
serverID string
diceCommandsCount int
)
// EvalResponse represents the response of an evaluation operation for a command from store.
// It contains the sequence ID, the result of the store operation, and any error encountered during the operation.
type EvalRespons... | @@ -54,6 +54,16 @@ type EvalResponse struct {
Error error // Error holds any error that occurred during the operation. If no error, it will be nil.
}
+// Following functions should be used to create a new EvalResponse with the given result and error.
+// These ensure that result and error are mutually exclu... | internal/eval/eval.go | 26 | Go | 0.286 | refactor | 76 | 51 | 51 | false | #1117: Addressed review comments | 1,186 | DiceDB/dice | 10,326 | C | JyotinderSingh | apoorvyadav1111 | Review this pull request change.
Language: Go
File: internal/eval/eval.go
PR Title: #1117: Addressed review comments
BEFORE CODE: )
var (
TxnCommands map[string]bool
serverID string
diceCommandsCount int
)
// EvalResponse represents the response of an evaluation operation for a command from stor... | Let's remove this directive (it anyway does nothing on newer versions of 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. |
}
func TestPFCountWATCHWithSDK(t *testing.T) {
publisher := getLocalSdk()
subscribers := []WatchSubscriber{{client: getLocalSdk()}, {client: getLocalSdk()}, {client: getLocalSdk()}}
publisher.Del(context.Background(), pfcountWatchKey)
channels := make([]<-chan *dicedb.WatchResult, len(subscribers))
for i, subsc... | Ideally we should have constants defined separately.
```suggestion
pfCountWatchKey = "pfcount_watch_key" // assuming this was defined elsewhere
defaultTimeout = 5 * time.Second
watchFingerprint = "1580567186"
``` | pfcountWatchQuerySDK = "PFCOUNT.WATCH %s"
pfcountWatchFingerPrintSDK = "1832643469"
defaultTimeout = 5 * time.Second
)
type pfcountWatchSDKTestCase struct {
key string
val any
result int64
}
type pfcountWatchSDKWithPFMergeTestCase struct {
destKey1 string
destValue1 []string
destK... | @@ -0,0 +1,194 @@
+package resp
+
+import (
+ "context"
+ "fmt"
+ "net"
+ "testing"
+ "time"
+
+ "github.com/dicedb/dice/internal/clientio"
+ dicedb "github.com/dicedb/dicedb-go"
+ "gotest.tools/v3/assert"
+)
+
+type pfcountWatchTestCase struct {
+ key string
+ val any
+ result int64
+}
+
+type pfcountWatchWithPF... | integration_tests/commands/resp/pfcountwatch_test.go | 26 | Go | 0.857 | suggestion | 220 | 47 | 51 | false | #1133: Add support for PFCOUNT.WATCH command | 1,197 | DiceDB/dice | 10,326 | C | JyotinderSingh | iamskp11 | Review this pull request change.
Language: Go
File: integration_tests/commands/resp/pfcountwatch_test.go
PR Title: #1133: Add support for PFCOUNT.WATCH command
BEFORE CODE: }
func TestPFCountWATCHWithSDK(t *testing.T) {
publisher := getLocalSdk()
subscribers := []WatchSubscriber{{client: getLocalSdk()}, {client:... | Ideally we should have constants defined separately.
```suggestion
pfCountWatchKey = "pfcount_watch_key" // assuming this was defined elsewhere
defaultTimeout = 5 * time.Second
watchFingerprint = "1580567186"
``` | 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. |
v, err := rp.DecodeOne()
assert.NilError(t, err)
castedValue, ok := v.([]interface{})
if !ok {
t.Errorf("Type assertion to []interface{} failed for value: %v", v)
}
assert.Equal(t, 3, len(castedValue))
assert.Equal(t, "PFCOUNT", castedValue[0])
assert.Equal(t, "1580567186", castedValue[1])
... | style guide doesn't recommend snake case. use camel case. |
func testPFCountAdd(t *testing.T, publisher net.Conn, respParsers []*clientio.RESPParser) {
for _, tc := range pfcountWatchTestCases {
res := FireCommand(publisher, fmt.Sprintf("PFADD %s %s", tc.key, tc.val))
assert.Equal(t, int64(1), res)
verifyWatchResults(t, respParsers, tc.result)
}
}
func testPFCountM... | @@ -0,0 +1,194 @@
+package resp
+
+import (
+ "context"
+ "fmt"
+ "net"
+ "testing"
+ "time"
+
+ "github.com/dicedb/dice/internal/clientio"
+ dicedb "github.com/dicedb/dicedb-go"
+ "gotest.tools/v3/assert"
+)
+
+type pfcountWatchTestCase struct {
+ key string
+ val any
+ result int64
+}
+
+type pfcountWatchWithPF... | integration_tests/commands/resp/pfcountwatch_test.go | 26 | Go | 0.286 | suggestion | 57 | 51 | 51 | false | #1133: Add support for PFCOUNT.WATCH command | 1,197 | DiceDB/dice | 10,326 | C | JyotinderSingh | iamskp11 | Review this pull request change.
Language: Go
File: integration_tests/commands/resp/pfcountwatch_test.go
PR Title: #1133: Add support for PFCOUNT.WATCH command
BEFORE CODE: v, err := rp.DecodeOne()
assert.NilError(t, err)
castedValue, ok := v.([]interface{})
if !ok {
t.Errorf("Type assertion to []in... | style guide doesn't recommend snake case. use camel case. | 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. |
channels := make([]<-chan *dicedb.WatchResult, len(subscribers))
for i, subscriber := range subscribers {
watch := subscriber.client.WatchConn(context.Background())
subscribers[i].watch = watch
assert.Assert(t, watch != nil)
firstMsg, err := watch.Watch(context.Background(), "PFCOUNT", pfcountWatchKey)
ass... | Maybe we can rewrite this better as follows:
```go
func TestPFCountWatchWithSDK(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), defaultTimeout)
defer cancel()
publisher := getLocalSDK(t)
subscribers := setupSubscribers(t, 3)
defer cleanupSubscribers(subscribers)
// Clean up te... | val any
result int64
}
type pfcountWatchSDKWithPFMergeTestCase struct {
destKey1 string
destValue1 []string
destKey2 string
destValue2 []string
result int64
}
var PFCountWatchSDKTestCases = []pfcountWatchSDKTestCase{
{pfcountWatchKeySDK, "value1", int64(1)},
{pfcountWatchKeySDK, "value2", int64(2)... | @@ -0,0 +1,194 @@
+package resp
+
+import (
+ "context"
+ "fmt"
+ "net"
+ "testing"
+ "time"
+
+ "github.com/dicedb/dice/internal/clientio"
+ dicedb "github.com/dicedb/dicedb-go"
+ "gotest.tools/v3/assert"
+)
+
+type pfcountWatchTestCase struct {
+ key string
+ val any
+ result int64
+}
+
+type pfcountWatchWithPF... | integration_tests/commands/resp/pfcountwatch_test.go | 26 | Go | 1 | refactor | 3,048 | 40 | 51 | false | #1133: Add support for PFCOUNT.WATCH command | 1,197 | DiceDB/dice | 10,326 | C | JyotinderSingh | iamskp11 | Review this pull request change.
Language: Go
File: integration_tests/commands/resp/pfcountwatch_test.go
PR Title: #1133: Add support for PFCOUNT.WATCH command
BEFORE CODE:
channels := make([]<-chan *dicedb.WatchResult, len(subscribers))
for i, subscriber := range subscribers {
watch := subscriber.client.Watch... | Maybe we can rewrite this better as follows:
```go
func TestPFCountWatchWithSDK(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), defaultTimeout)
defer cancel()
publisher := getLocalSDK(t)
subscribers := setupSubscribers(t, 3)
defer cleanupSubscribers(subscribers)
// Clean up te... | 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 resp
import (
"context"
"fmt"
"net"
"testing"
"time"
"github.com/dicedb/dice/internal/clientio"
dicedb "github.com/dicedb/dicedb-go"
"gotest.tools/v3/assert"
)
type pfcountWatchTestCase struct {
key string
val any
result int64
}
type pfcountWatchWithPFMergeTestCase struct {
dest_key_1 s... | use camel case and not snake case for field names | package resp
import (
"context"
"fmt"
"net"
"testing"
"time"
"github.com/dicedb/dice/internal/clientio"
dicedb "github.com/dicedb/dicedb-go"
"gotest.tools/v3/assert"
)
type pfcountWatchTestCase struct {
key string
val any
result int64
}
type pfcountWatchWithPFMergeTestCase struct {
destKey1 str... | @@ -0,0 +1,194 @@
+package resp
+
+import (
+ "context"
+ "fmt"
+ "net"
+ "testing"
+ "time"
+
+ "github.com/dicedb/dice/internal/clientio"
+ dicedb "github.com/dicedb/dicedb-go"
+ "gotest.tools/v3/assert"
+)
+
+type pfcountWatchTestCase struct {
+ key string
+ val any
+ result int64
+}
+
+type pfcountWatchWithPF... | integration_tests/commands/resp/pfcountwatch_test.go | 23 | Go | 0.143 | suggestion | 49 | 48 | 48 | false | #1133: Add support for PFCOUNT.WATCH command | 1,197 | DiceDB/dice | 10,326 | C | JyotinderSingh | iamskp11 | Review this pull request change.
Language: Go
File: integration_tests/commands/resp/pfcountwatch_test.go
PR Title: #1133: Add support for PFCOUNT.WATCH command
BEFORE CODE: package resp
import (
"context"
"fmt"
"net"
"testing"
"time"
"github.com/dicedb/dice/internal/clientio"
dicedb "github.com/dicedb/dice... | use camel case and not snake case for field names | 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. |
"testing"
"time"
"github.com/dicedb/dice/internal/clientio"
dicedb "github.com/dicedb/dicedb-go"
"gotest.tools/v3/assert"
)
type pfcountWatchTestCase struct {
key string
val any
result int64
}
type pfcountWatchWithPFMergeTestCase struct {
dest_key_1 string
dest_value_1 []string
dest_key_2 str... | use this to declare the expected fingerprints as well (or define them in a local variable inside the test methods) | "testing"
"time"
"github.com/dicedb/dice/internal/clientio"
dicedb "github.com/dicedb/dicedb-go"
"gotest.tools/v3/assert"
)
type pfcountWatchTestCase struct {
key string
val any
result int64
}
type pfcountWatchWithPFMergeTestCase struct {
destKey1 string
destValue1 []string
destKey2 string
des... | @@ -0,0 +1,194 @@
+package resp
+
+import (
+ "context"
+ "fmt"
+ "net"
+ "testing"
+ "time"
+
+ "github.com/dicedb/dice/internal/clientio"
+ dicedb "github.com/dicedb/dicedb-go"
+ "gotest.tools/v3/assert"
+)
+
+type pfcountWatchTestCase struct {
+ key string
+ val any
+ result int64
+}
+
+type pfcountWatchWithPF... | integration_tests/commands/resp/pfcountwatch_test.go | 26 | Go | 0.429 | suggestion | 114 | 51 | 51 | false | #1133: Add support for PFCOUNT.WATCH command | 1,197 | DiceDB/dice | 10,326 | C | JyotinderSingh | iamskp11 | Review this pull request change.
Language: Go
File: integration_tests/commands/resp/pfcountwatch_test.go
PR Title: #1133: Add support for PFCOUNT.WATCH command
BEFORE CODE: "testing"
"time"
"github.com/dicedb/dice/internal/clientio"
dicedb "github.com/dicedb/dicedb-go"
"gotest.tools/v3/assert"
)
type pfcount... | use this to declare the expected fingerprints as well (or define them in a local variable inside the test methods) | 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. |
cmdList = append(cmdList, watchCmd)
isWatchNotification = true
case Unwatch:
// Generate the Cmd being unwatched. All we need to do is remove the .UNWATCH suffix from the command and pass
// it along as is.
// Modify the command name to remove the .UNWATCH suffix, this will allow us to generate a cons... | The UNWATCH command unsubscribes using the fingerprint and not the command. The usage is as follows:
```sh
> GET.WATCH k
1) GET
2) 12345 # Fingerprint
3) value
> GET.UNWATCH 12345
OK
``` | }
cmdList = append(cmdList, watchCmd)
isWatchNotification = true
case Unwatch:
// Generate the Cmd being unwatched. All we need to do is remove the .UNWATCH suffix from the command and pass
// it along as is.
// Modify the command name to remove the .UNWATCH suffix, this will allow us to generate a... | @@ -248,7 +248,37 @@ func (w *BaseWorker) executeCommand(ctx context.Context, diceDBCmd *cmd.DiceDBCm
}
cmdList = append(cmdList, watchCmd)
isWatchNotification = true
+
+ case Unwatch:
+ // Generate the Cmd being unwatched. All we need to do is remove the .UNWATCH suffix from the command and pass
+ // ... | internal/worker/worker.go | 26 | Go | 0.714 | suggestion | 194 | 51 | 51 | false | #998: Added GET.UNWATCH command support and fix watch related issues | 1,201 | DiceDB/dice | 10,326 | C | JyotinderSingh | psrvere | Review this pull request change.
Language: Go
File: internal/worker/worker.go
PR Title: #998: Added GET.UNWATCH command support and fix watch related issues
BEFORE CODE: cmdList = append(cmdList, watchCmd)
isWatchNotification = true
case Unwatch:
// Generate the Cmd being unwatched. All we need to do is... | The UNWATCH command unsubscribes using the fingerprint and not the command. The usage is as follows:
```sh
> GET.WATCH k
1) GET
2) 12345 # Fingerprint
3) value
> GET.UNWATCH 12345
OK
``` | 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. |
flag.IntVar(&config.NumShards, "num-shards", -1, "number shards to create. defaults to number of cores")
flag.BoolVar(&config.EnableWatch, "enable-watch", false, "enable support for .WATCH commands and real-time reactivity")
flag.BoolVar(&config.EnableProfiling, "enable-profiling", false, "enable profiling and capt... | Shall we move all of printing logic to another file altogether? | flag.IntVar(&config.NumShards, "num-shards", -1, "number shards to create. defaults to number of cores")
flag.BoolVar(&config.EnableWatch, "enable-watch", false, "enable support for .WATCH commands and real-time reactivity")
flag.BoolVar(&config.EnableProfiling, "enable-profiling", false, "enable profiling and capt... | @@ -66,24 +74,86 @@ func init() {
slog.SetDefault(logger.New())
}
-func main() {
+func printSplash() { | main.go | 26 | Go | 0.286 | question | 63 | 51 | 51 | false | Added startup splash and info table | 1,217 | DiceDB/dice | 10,326 | C | lucifercr07 | AshwinKul28 | Review this pull request change.
Language: Go
File: main.go
PR Title: Added startup splash and info table
BEFORE CODE: flag.IntVar(&config.NumShards, "num-shards", -1, "number shards to create. defaults to number of cores")
flag.BoolVar(&config.EnableWatch, "enable-watch", false, "enable support for .WATCH comma... | Shall we move all of printing logic to another file altogether? | 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. |
`)
}
// configuration function used to add configuration values to the print table at the startup.
// add entry to this function to add a new row in the startup configuration table.
func configuration() {
// Add the version of the DiceDB to the configuration table
addEntry("Version", config.DiceDBVersion)
// Add ... | Shall we add entries for HTTP/Websocket enabled also? | }
// configuration function used to add configuration values to the print table at the startup.
// add entry to this function to add a new row in the startup configuration table.
func configuration() {
// Add the version of the DiceDB to the configuration table
addEntry("Version", config.DiceDBVersion)
// Add the ... | @@ -66,24 +74,86 @@ func init() {
slog.SetDefault(logger.New())
}
-func main() {
+func printSplash() {
fmt.Print(`
-██████╗ ██╗ ██████╗███████╗██████╗ ██████╗
-██╔══██╗██║██╔════╝██╔════╝██╔══██╗██╔══██╗
-██║ ██║██║██║ █████╗ ██║ ██║██████╔╝
-██║ ██║██║██║ ██╔══╝ ██║ ██║██╔══██╗
-██████╔╝██║╚█████... | main.go | 26 | Go | 0.214 | question | 53 | 51 | 51 | false | Added startup splash and info table | 1,217 | DiceDB/dice | 10,326 | C | lucifercr07 | AshwinKul28 | Review this pull request change.
Language: Go
File: main.go
PR Title: Added startup splash and info table
BEFORE CODE: `)
}
// configuration function used to add configuration values to the print table at the startup.
// add entry to this function to add a new row in the startup configuration table.
func configur... | Shall we add entries for HTTP/Websocket enabled also? | 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. |
flag.StringVar(&config.FileLocation, "c", config.FileLocation, "file path of the config file")
flag.BoolVar(&config.InitConfigCmd, "init-config", false, "initialize a new config file")
flag.IntVar(&config.KeysLimit, "keys-limit", config.KeysLimit, "keys limit for the DiceDB server. "+
"This flag controls the numbe... | Let's confirm this once with Arpit, I believe we had discussed that day to avoid phrase | flag.StringVar(&config.FileLocation, "c", config.FileLocation, "file path of the config file")
flag.BoolVar(&config.InitConfigCmd, "init-config", false, "initialize a new config file")
flag.IntVar(&config.KeysLimit, "keys-limit", config.KeysLimit, "keys limit for the DiceDB server. "+
"This flag controls the numbe... | @@ -66,24 +74,86 @@ func init() {
slog.SetDefault(logger.New())
}
-func main() {
+func printSplash() {
fmt.Print(`
-██████╗ ██╗ ██████╗███████╗██████╗ ██████╗
-██╔══██╗██║██╔════╝██╔════╝██╔══██╗██╔══██╗
-██║ ██║██║██║ █████╗ ██║ ██║██████╔╝
-██║ ██║██║██║ ██╔══╝ ██║ ██║██╔══██╗
-██████╔╝██║╚█████... | main.go | 26 | Go | 0.286 | suggestion | 87 | 51 | 51 | false | Added startup splash and info table | 1,217 | DiceDB/dice | 10,326 | C | lucifercr07 | AshwinKul28 | Review this pull request change.
Language: Go
File: main.go
PR Title: Added startup splash and info table
BEFORE CODE: flag.StringVar(&config.FileLocation, "c", config.FileLocation, "file path of the config file")
flag.BoolVar(&config.InitConfigCmd, "init-config", false, "initialize a new config file")
flag.IntV... | Let's confirm this once with Arpit, I believe we had discussed that day to avoid phrase | 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. |
}
popNumber = nos
}
obj := store.Get(args[0])
if obj == nil {
return clientio.RespNIL
}
// if object is a set type, return error
if object.AssertType(obj.TypeEncoding, object.ObjTypeSet) == nil {
return diceerrors.NewErrWithFormattedMessage(diceerrors.WrongTypeErr)
}
if err := object.AssertType(obj.T... | nit
```suggestion
var elements []string
``` | }
popNumber = nos
}
obj := store.Get(args[0])
if obj == nil {
return clientio.RespNIL
}
// if object is a set type, return error
if object.AssertType(obj.TypeEncoding, object.ObjTypeSet) == nil {
return diceerrors.NewErrWithFormattedMessage(diceerrors.WrongTypeErr)
}
if err := object.AssertType(obj.T... | @@ -2180,15 +2201,29 @@ func evalLPOP(args []string, store *dstore.Store) []byte {
}
deq := obj.Value.(*Deque)
- x, err := deq.LPop()
- if err != nil {
- if errors.Is(err, ErrDequeEmpty) {
- return clientio.RespNIL
+
+ // holds the elements popped
+ var str []string | internal/eval/eval.go | 26 | Go | 0.429 | suggestion | 47 | 51 | 51 | false | #1100: Fix LPOP to support multiple arguments | 1,231 | DiceDB/dice | 10,326 | C | JyotinderSingh | tren03 | Review this pull request change.
Language: Go
File: internal/eval/eval.go
PR Title: #1100: Fix LPOP to support multiple arguments
BEFORE CODE: }
popNumber = nos
}
obj := store.Get(args[0])
if obj == nil {
return clientio.RespNIL
}
// if object is a set type, return error
if object.AssertType(obj.TypeE... | nit
```suggestion
var elements []string
``` | 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 XX:
// Get the key from the hash table
obj := store.Get(key)
// if key does not exist, return RESP encoded nil
if obj == nil {
return makeEvalResult(clientio.NIL)
}
case NX:
obj := store.Get(key)
if obj != nil {
return makeEvalResult(clientio.NIL)
}
case KeepTTL:
if state... | Can you please share this as a code suggestion? that way I would be able to accurately test it in local. | case XX:
// Get the key from the hash table
obj := store.Get(key)
// if key does not exist, return RESP encoded nil
if obj == nil {
return makeEvalResult(clientio.NIL)
}
case NX:
obj := store.Get(key)
if obj != nil {
return makeEvalResult(clientio.NIL)
}
case KeepTTL:
if state ... | @@ -295,32 +264,27 @@ func evalSET(args []string, store *dstore.Store) *EvalResponse {
// if key does not exist, return RESP encoded nil
if obj == nil {
- return &EvalResponse{
- Result: clientio.NIL,
- Error: nil,
- }
+ return makeEvalResult(clientio.NIL)
}
case NX:
obj := store.... | internal/eval/store_eval.go | 26 | Go | 0.357 | suggestion | 104 | 51 | 51 | false | #207 Feature: get in set | 1,238 | DiceDB/dice | 10,326 | C | apoorvyadav1111 | apoorvyadav1111 | Review this pull request change.
Language: Go
File: internal/eval/store_eval.go
PR Title: #207 Feature: get in set
BEFORE CODE:
case XX:
// Get the key from the hash table
obj := store.Get(key)
// if key does not exist, return RESP encoded nil
if obj == nil {
return makeEvalResult(clientio.NIL)
... | Can you please share this as a code suggestion? that way I would be able to accurately test it in local. | 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. |
// args must contain key and value.
// args can also contain multiple options -
//
// EX or ex which will set the expiry time(in secs) for the key
// PX or px which will set the expiry time(in milliseconds) for the key
// EXAT or exat which will set the specified Unix time at which the key will expire, in seconds (a po... | ```suggestion
var oldVal *interface{}
``` | // args must contain key and value.
// args can also contain multiple options -
//
// EX or ex which will set the expiry time(in secs) for the key
// PX or px which will set the expiry time(in milliseconds) for the key
// EXAT or exat which will set the specified Unix time at which the key will expire, in seconds (a po... | @@ -183,16 +183,15 @@ func evalEXPIRETIME(args []string, store *dstore.Store) *EvalResponse {
// If the key already exists then the value will be overwritten and expiry will be discarded
func evalSET(args []string, store *dstore.Store) *EvalResponse {
if len(args) <= 1 {
- return &EvalResponse{
- Result: nil,
- ... | internal/eval/store_eval.go | 26 | Go | 0.429 | suggestion | 44 | 51 | 51 | false | #207 Feature: get in set | 1,238 | DiceDB/dice | 10,326 | C | tejasa97 | apoorvyadav1111 | Review this pull request change.
Language: Go
File: internal/eval/store_eval.go
PR Title: #207 Feature: get in set
BEFORE CODE: // args must contain key and value.
// args can also contain multiple options -
//
// EX or ex which will set the expiry time(in secs) for the key
// PX or px which will set the expiry tim... | ```suggestion
var oldVal *interface{}
``` | 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 exDurationMs < 0 {
exDurationMs = 0
}
state = Initialized
case XX:
// Get the key from the hash table
obj := store.Get(key)
// if key does not exist, return RESP encoded nil
if obj == nil {
return makeEvalResult(clientio.NIL)
}
case NX:
obj := store.Get(key)
if obj != nil ... | ```suggestion
evalGet := evalGET([]string{key}, store)
if evalGet.Error != nil {
return makeEvalError(diceerrors.ErrWrongTypeOperation)
}
oldVal = &evalGet.Result
``` | exDurationMs = 0
}
state = Initialized
case XX:
// Get the key from the hash table
obj := store.Get(key)
// if key does not exist, return RESP encoded nil
if obj == nil {
return makeEvalResult(clientio.NIL)
}
case NX:
obj := store.Get(key)
if obj != nil {
return makeEvalResu... | @@ -295,32 +264,27 @@ func evalSET(args []string, store *dstore.Store) *EvalResponse {
// if key does not exist, return RESP encoded nil
if obj == nil {
- return &EvalResponse{
- Result: clientio.NIL,
- Error: nil,
- }
+ return makeEvalResult(clientio.NIL)
}
case NX:
obj := store.... | internal/eval/store_eval.go | 26 | Go | 0.857 | bug | 188 | 51 | 51 | false | #207 Feature: get in set | 1,238 | DiceDB/dice | 10,326 | C | tejasa97 | apoorvyadav1111 | Review this pull request change.
Language: Go
File: internal/eval/store_eval.go
PR Title: #207 Feature: get in set
BEFORE CODE: if exDurationMs < 0 {
exDurationMs = 0
}
state = Initialized
case XX:
// Get the key from the hash table
obj := store.Get(key)
// if key does not exist, return RE... | ```suggestion
evalGet := evalGET([]string{key}, store)
if evalGet.Error != nil {
return makeEvalError(diceerrors.ErrWrongTypeOperation)
}
oldVal = &evalGet.Result
``` | 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 GET:
getVal = true
oldVal := evalGET([]string{key}, store)
if oldVal.Error != nil {
return makeEvalError(diceerrors.ErrWrongTypeOperation)
}
getOldVal = oldVal.Result
default:
return makeEvalError(diceerrors.ErrSyntax)
}
}
// Cast the value properly based on the encoding type
var st... | ```suggestion
if oldVal != nil {
return makeEvalResult(*oldVal)
}
``` | getResult := evalGET([]string{key}, store)
if getResult.Error != nil {
return makeEvalError(diceerrors.ErrWrongTypeOperation)
}
oldVal = &getResult.Result
default:
return makeEvalError(diceerrors.ErrSyntax)
}
}
// Cast the value properly based on the encoding type
var storedValue interface{}
... | @@ -332,19 +296,15 @@ func evalSET(args []string, store *dstore.Store) *EvalResponse {
case object.ObjEncodingEmbStr, object.ObjEncodingRaw:
storedValue = value
default:
- return &EvalResponse{
- Result: nil,
- Error: diceerrors.ErrUnsupportedEncoding(int(oEnc)),
- }
+ return makeEvalError(diceerrors.Err... | internal/eval/store_eval.go | 26 | Go | 0.571 | suggestion | 77 | 51 | 51 | false | #207 Feature: get in set | 1,238 | DiceDB/dice | 10,326 | C | tejasa97 | apoorvyadav1111 | Review this pull request change.
Language: Go
File: internal/eval/store_eval.go
PR Title: #207 Feature: get in set
BEFORE CODE: case GET:
getVal = true
oldVal := evalGET([]string{key}, store)
if oldVal.Error != nil {
return makeEvalError(diceerrors.ErrWrongTypeOperation)
}
getOldVal = oldVal.Re... | ```suggestion
if oldVal != nil {
return makeEvalResult(*oldVal)
}
``` | 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 resp
import (
"context"
"fmt"
"net"
"testing"
"time"
"github.com/dicedb/dice/internal/clientio"
"github.com/dicedb/dice/internal/cmd"
"github.com/dicedb/dicedb-go"
"github.com/stretchr/testify/assert"
)
func generateFingrprint(cmdName string, key string) string {
cmd := cmd.DiceDBCmd{
Cmd: cmdNa... | fingerprint generation logic can be hidden away from the test, we can simply assert the behavior using a static string. | package resp
import (
"context"
"fmt"
"net"
"testing"
"time"
"github.com/dicedb/dice/internal/clientio"
"github.com/dicedb/dicedb-go"
"github.com/stretchr/testify/assert"
)
const (
getUnwatchKey = "getunwatchkey"
)
type getUnwatchTestCase struct {
key string
val string
}
var getUnwatchTestCases = []getU... | @@ -8,13 +8,21 @@ import (
"time"
"github.com/dicedb/dice/internal/clientio"
+ "github.com/dicedb/dice/internal/cmd"
"github.com/dicedb/dicedb-go"
"github.com/stretchr/testify/assert"
)
+func generateFingrprint(cmdName string, key string) string {
+ cmd := cmd.DiceDBCmd{
+ Cmd: cmdName,
+ Args: []string... | integration_tests/commands/resp/getunwatch_test.go | 23 | Go | 0.357 | suggestion | 119 | 48 | 48 | false | #207 Feature: get in set | 1,238 | DiceDB/dice | 10,326 | C | JyotinderSingh | apoorvyadav1111 | Review this pull request change.
Language: Go
File: integration_tests/commands/resp/getunwatch_test.go
PR Title: #207 Feature: get in set
BEFORE CODE: package resp
import (
"context"
"fmt"
"net"
"testing"
"time"
"github.com/dicedb/dice/internal/clientio"
"github.com/dicedb/dice/internal/cmd"
"github.com/d... | fingerprint generation logic can be hidden away from the test, we can simply assert the behavior using a static string. | 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 generateFingrprint(cmdName string, key string) string {
cmd := cmd.DiceDBCmd{
Cmd: cmdName,
Args: []string{key},
}
return fmt.Sprintf("%d", cmd.GetFingerprint())
}
const (
getUnwatchKey = "getunwatchkey"
)
type getUnwatchTestCase struct {
key string
val string
}
var getUnwatchTestCases = []getUnwatc... | just store a constant string here instead of calculating it in the test. It's an anti pattern to couple the key generation logic tightly with the test here. | const (
getUnwatchKey = "getunwatchkey"
)
type getUnwatchTestCase struct {
key string
val string
}
var getUnwatchTestCases = []getUnwatchTestCase{
{getUnwatchKey, "value1"},
{getUnwatchKey, "value2"},
{getUnwatchKey, "value3"},
{getUnwatchKey, "value4"},
}
func TestGETUNWATCH(t *testing.T) {
publisher := get... | @@ -29,6 +37,8 @@ var getUnwatchTestCases = []getUnwatchTestCase{
{getUnwatchKey, "value4"},
}
+var fingerprint = generateFingrprint("GET", getUnwatchKey) | integration_tests/commands/resp/getunwatch_test.go | 26 | Go | 0.429 | suggestion | 156 | 51 | 51 | false | #207 Feature: get in set | 1,238 | DiceDB/dice | 10,326 | C | JyotinderSingh | apoorvyadav1111 | Review this pull request change.
Language: Go
File: integration_tests/commands/resp/getunwatch_test.go
PR Title: #207 Feature: get in set
BEFORE CODE:
func generateFingrprint(cmdName string, key string) string {
cmd := cmd.DiceDBCmd{
Cmd: cmdName,
Args: []string{key},
}
return fmt.Sprintf("%d", cmd.GetFing... | just store a constant string here instead of calculating it in the test. It's an anti pattern to couple the key generation logic tightly with the test here. | 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 watchmanager
import (
"context"
"log/slog"
"sync"
"github.com/dicedb/dice/internal/cmd"
dstore "github.com/dicedb/dice/internal/store"
)
type (
WatchSubscription struct {
Subscribe bool // Subscribe is true for subscribe, false for unsubscribe. Required.
AdhocReqChan chan *cmd.Dic... | we probably don't need to maintain this map here, the first response is not routed through the watch manager, and there is no need to store the uuid state in the server (it is only for synchronization at the SDK level) | package watchmanager
import (
"context"
"log/slog"
"sync"
"github.com/dicedb/dice/internal/cmd"
dstore "github.com/dicedb/dice/internal/store"
)
type (
WatchSubscription struct {
Subscribe bool // Subscribe is true for subscribe, false for unsubscribe. Required.
AdhocReqChan chan *cmd.Dic... | @@ -15,12 +15,14 @@ type (
AdhocReqChan chan *cmd.DiceDBCmd // AdhocReqChan is the channel to send adhoc requests to the worker. Required.
WatchCmd *cmd.DiceDBCmd // WatchCmd Represents a unique key for each watch artifact, only populated for subscriptions.
Fingerprint uint32 // Fingerpr... | internal/watchmanager/watch_manager.go | 25 | Go | 0.429 | suggestion | 218 | 50 | 50 | false | Added Label for Watch commands | 1,267 | DiceDB/dice | 10,326 | C | JyotinderSingh | psrvere | Review this pull request change.
Language: Go
File: internal/watchmanager/watch_manager.go
PR Title: Added Label for Watch commands
BEFORE CODE: package watchmanager
import (
"context"
"log/slog"
"sync"
"github.com/dicedb/dice/internal/cmd"
dstore "github.com/dicedb/dice/internal/store"
)
type (
WatchSubsc... | we probably don't need to maintain this map here, the first response is not routed through the watch manager, and there is no need to store the uuid state in the server (it is only for synchronization at the SDK level) | 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. |
Manager struct {
querySubscriptionMap map[string]map[uint32]struct{} // querySubscriptionMap is a map of Key -> [fingerprint1, fingerprint2, ...]
tcpSubscriptionMap map[uint32]map[chan *cmd.DiceDBCmd]struct{} // tcpSubscriptionMap is a map of fingerprint -> [client1Chan, client2Chan, ...]
... | we probably don't need this either, for the same reason as the other one. | Manager struct {
querySubscriptionMap map[string]map[uint32]struct{} // querySubscriptionMap is a map of Key -> [fingerprint1, fingerprint2, ...]
tcpSubscriptionMap map[uint32]map[chan *cmd.DiceDBCmd]struct{} // tcpSubscriptionMap is a map of fingerprint -> [client1Chan, client2Chan, ...]
... | @@ -40,6 +42,7 @@ func NewManager(cmdWatchSubscriptionChan chan WatchSubscription, cmdWatchChan ch
querySubscriptionMap: make(map[string]map[uint32]struct{}),
tcpSubscriptionMap: make(map[uint32]map[chan *cmd.DiceDBCmd]struct{}),
fingerprintCmdMap: make(map[uint32]*cmd.DiceDBCmd),
+ fingerpri... | internal/watchmanager/watch_manager.go | 26 | Go | 0.214 | suggestion | 73 | 51 | 51 | false | Added Label for Watch commands | 1,267 | DiceDB/dice | 10,326 | C | JyotinderSingh | psrvere | Review this pull request change.
Language: Go
File: internal/watchmanager/watch_manager.go
PR Title: Added Label for Watch commands
BEFORE CODE:
Manager struct {
querySubscriptionMap map[string]map[uint32]struct{} // querySubscriptionMap is a map of Key -> [fingerprint1, fingerprint2, ...]
tc... | we probably don't need this either, for the same reason as the other one. | 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 watchmanager
import (
"context"
"log/slog"
"sync"
"github.com/dicedb/dice/internal/cmd"
dstore "github.com/dicedb/dice/internal/store"
)
type (
WatchSubscription struct {
Subscribe bool // Subscribe is true for subscribe, false for unsubscribe. Required.
AdhocReqChan chan *cmd.Dic... | We can probably remove this? I don't think we're using this anywhere. | package watchmanager
import (
"context"
"log/slog"
"sync"
"github.com/dicedb/dice/internal/cmd"
dstore "github.com/dicedb/dice/internal/store"
)
type (
WatchSubscription struct {
Subscribe bool // Subscribe is true for subscribe, false for unsubscribe. Required.
AdhocReqChan chan *cmd.Dic... | @@ -15,6 +15,7 @@ type (
AdhocReqChan chan *cmd.DiceDBCmd // AdhocReqChan is the channel to send adhoc requests to the worker. Required.
WatchCmd *cmd.DiceDBCmd // WatchCmd Represents a unique key for each watch artifact, only populated for subscriptions.
Fingerprint uint32 // Fingerprin... | internal/watchmanager/watch_manager.go | 18 | Go | 0.286 | refactor | 69 | 43 | 43 | false | Added Label for Watch commands | 1,267 | DiceDB/dice | 10,326 | C | JyotinderSingh | psrvere | Review this pull request change.
Language: Go
File: internal/watchmanager/watch_manager.go
PR Title: Added Label for Watch commands
BEFORE CODE: package watchmanager
import (
"context"
"log/slog"
"sync"
"github.com/dicedb/dice/internal/cmd"
dstore "github.com/dicedb/dice/internal/store"
)
type (
WatchSubsc... | We can probably remove this? I don't think we're using this anywhere. | 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. |
// Scatter the broken-down commands to the appropriate shards.
if err := w.scatter(ctx, cmdList); err != nil {
return err
}
// Gather the responses from the shards and write them to the buffer.
if err := w.gather(ctx, diceDBCmd, len(cmdList), isWatchNotification, watchLabel); err != nil {
return err
}
if ... | `watchLabel` is not being used by the watch manager so no need to send it. | }
}
// Unsubscribe Unwatch command type
if meta.CmdType == Unwatch {
return w.handleCommandUnwatch(ctx, cmdList)
}
// Scatter the broken-down commands to the appropriate shards.
if err := w.scatter(ctx, cmdList, meta.CmdType); err != nil {
return err
}
// Gather the responses from the shards and write ... | @@ -279,24 +291,25 @@ func (w *BaseWorker) executeCommand(ctx context.Context, diceDBCmd *cmd.DiceDBCm
}
// Gather the responses from the shards and write them to the buffer.
- if err := w.gather(ctx, diceDBCmd, len(cmdList), isWatchNotification); err != nil {
+ if err := w.gather(ctx, diceDBCmd, len(cmdList), is... | internal/worker/worker.go | 26 | Go | 0.429 | suggestion | 74 | 51 | 51 | false | Added Label for Watch commands | 1,267 | DiceDB/dice | 10,326 | C | JyotinderSingh | psrvere | Review this pull request change.
Language: Go
File: internal/worker/worker.go
PR Title: Added Label for Watch commands
BEFORE CODE:
// Scatter the broken-down commands to the appropriate shards.
if err := w.scatter(ctx, cmdList); err != nil {
return err
}
// Gather the responses from the shards and write th... | `watchLabel` is not being used by the watch manager so no need to send it. | 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.Nil(t, err)
castedValue, ok := v.([]interface{})
if !ok {
t.Errorf("Type assertion to []interface{} failed for value: %v", v)
}
assert.Equal(t, 3, len(castedValue))
assert.Equal(t, "GET", castedValue[0])
assert.Equal(t, "2714318480", castedValue[1])
assert.Equal(t, tc.val, castedValue... | I don't think we need to send the uuid on the user side, the SDK already creates one for us inside the Watch() method.
```suggestion
``` | unsubscribeFromUpdates(t, subscribers, "2714318480")
}
func TestGETWATCHWithSDK(t *testing.T) {
publisher := getLocalSdk()
subscribers := []WatchSubscriber{{client: getLocalSdk()}, {client: getLocalSdk()}, {client: getLocalSdk()}}
defer func() {
err := ClosePublisherSubscribersSDK(publisher, subscribers)
asse... | @@ -101,10 +105,13 @@ func TestGETWATCHWithSDK(t *testing.T) {
watch := subscriber.client.WatchConn(context.Background())
subscribers[i].watch = watch
assert.True(t, watch != nil)
- firstMsg, err := watch.Watch(context.Background(), "GET", getWatchKey)
+
+ uuid := uuid.New().String() | integration_tests/commands/resp/getwatch_test.go | 26 | Go | 0.786 | suggestion | 138 | 51 | 51 | false | Added Label for Watch commands | 1,267 | DiceDB/dice | 10,326 | C | JyotinderSingh | psrvere | Review this pull request change.
Language: Go
File: integration_tests/commands/resp/getwatch_test.go
PR Title: Added Label for Watch commands
BEFORE CODE: assert.Nil(t, err)
castedValue, ok := v.([]interface{})
if !ok {
t.Errorf("Type assertion to []interface{} failed for value: %v", v)
}
assert.... | I don't think we need to send the uuid on the user side, the SDK already creates one for us inside the Watch() method.
```suggestion
``` | 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. |
castedValue, ok := v.([]interface{})
if !ok {
t.Errorf("Type assertion to []interface{} failed for value: %v", v)
}
assert.Equal(t, 3, len(castedValue))
assert.Equal(t, "GET", castedValue[0])
assert.Equal(t, "2714318480", castedValue[1])
assert.Equal(t, tc.val, castedValue[2])
}
}
}
func Te... | ```suggestion
firstMsg, err := watch.Watch(context.Background(), "GET", getWatchKey)
``` | }
func TestGETWATCHWithSDK(t *testing.T) {
publisher := getLocalSdk()
subscribers := []WatchSubscriber{{client: getLocalSdk()}, {client: getLocalSdk()}, {client: getLocalSdk()}}
defer func() {
err := ClosePublisherSubscribersSDK(publisher, subscribers)
assert.Nil(t, err)
}()
publisher.Del(context.Background... | @@ -101,10 +105,13 @@ func TestGETWATCHWithSDK(t *testing.T) {
watch := subscriber.client.WatchConn(context.Background())
subscribers[i].watch = watch
assert.True(t, watch != nil)
- firstMsg, err := watch.Watch(context.Background(), "GET", getWatchKey)
+
+ uuid := uuid.New().String()
+ firstMsg, err := watc... | integration_tests/commands/resp/getwatch_test.go | 26 | Go | 0.571 | suggestion | 92 | 51 | 51 | false | Added Label for Watch commands | 1,267 | DiceDB/dice | 10,326 | C | JyotinderSingh | psrvere | Review this pull request change.
Language: Go
File: integration_tests/commands/resp/getwatch_test.go
PR Title: Added Label for Watch commands
BEFORE CODE: castedValue, ok := v.([]interface{})
if !ok {
t.Errorf("Type assertion to []interface{} failed for value: %v", v)
}
assert.Equal(t, 3, len(casted... | ```suggestion
firstMsg, err := watch.Watch(context.Background(), "GET", getWatchKey)
``` | 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. |
parser: parser,
shardManager: shardManager,
globalErrorChan: gec,
responseChan: responseChan,
preprocessingChan: preprocessingChan,
Session: auth.NewSession(),
adhocReqChan: make(chan *cmd.DiceDBCmd, config.DiceConfig.P... | Could you please add a comment explaining when len(data) can be 0? | parser: parser,
shardManager: shardManager,
globalErrorChan: gec,
responseChan: responseChan,
preprocessingChan: preprocessingChan,
Session: auth.NewSession(),
adhocReqChan: make(chan *cmd.DiceDBCmd, config.DiceConfig.P... | @@ -85,9 +85,13 @@ func (w *BaseWorker) Start(ctx context.Context) error {
go func() {
for {
data, err := w.ioHandler.Read(ctx)
- if err != nil {
- readErrChan <- err
- return
+ if err != nil || len(data) == 0 { | internal/worker/worker.go | 26 | Go | 0.286 | question | 66 | 51 | 51 | false | Fixed goroutine leaks and deadlocks in Worker and Resp Integrations Tests | 1,298 | DiceDB/dice | 10,326 | C | JyotinderSingh | psrvere | Review this pull request change.
Language: Go
File: internal/worker/worker.go
PR Title: Fixed goroutine leaks and deadlocks in Worker and Resp Integrations Tests
BEFORE CODE: parser: parser,
shardManager: shardManager,
globalErrorChan: gec,
responseChan: re... | Could you please add a comment explaining when len(data) can be 0? | 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. |
preprocessingChan: preprocessingChan,
Session: auth.NewSession(),
adhocReqChan: make(chan *cmd.DiceDBCmd, config.DiceConfig.Performance.AdhocReqChanBufSize),
cmdWatchSubscriptionChan: cmdWatchSubscriptionChan,
wl: wl,
}
}
func (w *BaseWorker) ID() st... | Can we use `case <-ctx.Done()` or use a channel to communicate between the main worker go routine and this go-routine instead?
IMO, this would make the behaviour more predictable and help better co-ordination.
wdyt? | preprocessingChan: preprocessingChan,
Session: auth.NewSession(),
adhocReqChan: make(chan *cmd.DiceDBCmd, config.DiceConfig.Performance.AdhocReqChanBufSize),
cmdWatchSubscriptionChan: cmdWatchSubscriptionChan,
wl: wl,
}
}
func (w *BaseWorker) ID() st... | @@ -85,9 +85,13 @@ func (w *BaseWorker) Start(ctx context.Context) error {
go func() {
for {
data, err := w.ioHandler.Read(ctx)
- if err != nil {
- readErrChan <- err
- return
+ if err != nil || len(data) == 0 {
+ select {
+ case readErrChan <- err:
+ return
+ case <-time.After(time.Seco... | internal/worker/worker.go | 26 | Go | 0.643 | question | 217 | 51 | 51 | false | Fixed goroutine leaks and deadlocks in Worker and Resp Integrations Tests | 1,298 | DiceDB/dice | 10,326 | C | soumya-codes | psrvere | Review this pull request change.
Language: Go
File: internal/worker/worker.go
PR Title: Fixed goroutine leaks and deadlocks in Worker and Resp Integrations Tests
BEFORE CODE: preprocessingChan: preprocessingChan,
Session: auth.NewSession(),
adhocReqChan: make(chan *cmd.Dice... | Can we use `case <-ctx.Done()` or use a channel to communicate between the main worker go routine and this go-routine instead?
IMO, this would make the behaviour more predictable and help better co-ordination.
wdyt? | 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.NewSession(),
adhocReqChan: make(chan *cmd.DiceDBCmd, config.DiceConfig.Performance.AdhocReqChanBufSize),
cmdWatchSubscriptionChan: cmdWatchSubscriptionChan,
wl: wl,
}
}
func (w *BaseWorker) ID() string {
return w.id
}
func (w *BaseWorker) Sta... | nit: can we move `w.ioHandler.Read` within the select statement and add it to the default case?
With this we may need a single select statement.
| Session: auth.NewSession(),
adhocReqChan: make(chan *cmd.DiceDBCmd, config.DiceConfig.Performance.AdhocReqChanBufSize),
cmdWatchSubscriptionChan: cmdWatchSubscriptionChan,
wl: wl,
}
}
func (w *BaseWorker) ID() string {
return w.id
}
func (w *BaseWorker) Sta... | @@ -82,14 +82,28 @@ func (w *BaseWorker) Start(ctx context.Context) error {
dataChan := make(chan []byte)
readErrChan := make(chan error)
+ runCtx, runCancel := context.WithCancel(ctx)
+ defer runCancel()
+
go func() {
+ defer close(dataChan)
+ defer close(readErrChan)
+
for {
- data, err := w.ioHandler.... | internal/worker/worker.go | 26 | Go | 0.714 | nitpick | 147 | 51 | 51 | false | Fixed goroutine leaks and deadlocks in Worker and Resp Integrations Tests | 1,298 | DiceDB/dice | 10,326 | C | soumya-codes | psrvere | Review this pull request change.
Language: Go
File: internal/worker/worker.go
PR Title: Fixed goroutine leaks and deadlocks in Worker and Resp Integrations Tests
BEFORE CODE: Session: auth.NewSession(),
adhocReqChan: make(chan *cmd.DiceDBCmd, config.DiceConfig.Performance.AdhocReqCh... | nit: can we move `w.ioHandler.Read` within the select statement and add it to the default case?
With this we may need a single select statement.
| 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 []HTTPCommand
expected []interface{}
}{
{
name: "GEOPOS for existing points",
commands: []HTTPCommand{
{Command: "GEOADD", Body: map[string]interface{}{"key": "index", "values": []interface{... | Shall we add a test for below case?
```
redis> SET k1 v1
"OK"
redis> GEOPOS k1 v1
(error) WRONGTYPE Operation against a key holding the wrong kind of value
```
|
testCases := []struct {
name string
commands []HTTPCommand
expected []interface{}
}{
{
name: "GEOPOS for existing points",
commands: []HTTPCommand{
{Command: "GEOADD", Body: map[string]interface{}{"key": "index", "values": []interface{... | @@ -84,3 +84,48 @@ func TestGeoDist(t *testing.T) {
})
}
}
+
+func TestGeoPos(t *testing.T) {
+ exec := NewHTTPCommandExecutor()
+
+ testCases := []struct {
+ name string
+ commands []HTTPCommand
+ expected []interface{}
+ }{
+ {
+ name: "GEOPOS for existing poi... | integration_tests/commands/http/geo_test.go | 26 | Go | 0.857 | bug | 169 | 43 | 51 | false | Add support for command GEOPOS | 1,328 | DiceDB/dice | 10,326 | C | lucifercr07 | helios2003 | Review this pull request change.
Language: Go
File: integration_tests/commands/http/geo_test.go
PR Title: Add support for command GEOPOS
BEFORE CODE:
testCases := []struct {
name string
commands []HTTPCommand
expected []interface{}
}{
{
name: "GEOPOS for exis... | Shall we add a test for below case?
```
redis> SET k1 v1
"OK"
redis> GEOPOS k1 v1
(error) WRONGTYPE Operation against a key holding the wrong kind of value
```
| 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 responses[idx].EvalResponse.Error != nil {
return responses[idx].EvalResponse.Error
}
resp := responses[idx].EvalResponse.Result.([]string)
if len(resp) > 0 {
results = append(results, resp...)
}
}
return results
}
func composeFlushDB(responses ...ops.StoreResponse) interface{} {
for idx := rang... | Just want to clarify if this note is for PFMERGE here? | if responses[idx].EvalResponse.Error != nil {
return responses[idx].EvalResponse.Error
}
resp := responses[idx].EvalResponse.Result.([]string)
if len(resp) > 0 {
results = append(results, resp...)
}
}
return results
}
func composeFlushDB(responses ...ops.StoreResponse) interface{} {
for idx := rang... | @@ -262,3 +262,17 @@ func composeFlushDB(responses ...ops.StoreResponse) interface{} {
return clientio.OK
}
+
+// composeMSet processes responses from multiple shards for an "MSet" operation
+// (Multi-set operation). It loops through the responses to check if any shard returned an error.
+// If an error is detect... | internal/iothread/cmd_compose.go | 26 | Go | 0.214 | question | 55 | 36 | 36 | false | Update `PFMERGE` to be supported as multishard command | 1,388 | DiceDB/dice | 10,326 | C | apoorvyadav1111 | lucifercr07 | Review this pull request change.
Language: Go
File: internal/iothread/cmd_compose.go
PR Title: Update `PFMERGE` to be supported as multishard command
BEFORE CODE: if responses[idx].EvalResponse.Error != nil {
return responses[idx].EvalResponse.Error
}
resp := responses[idx].EvalResponse.Result.([]string)
... | Just want to clarify if this note is for PFMERGE here? | 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. |
// Need to get response from both keys to handle Replace or not
rc <- &ops.StoreOp{
SeqID: 0,
RequestID: GenerateUniqueRequestID(),
Cmd: &preCmd,
IOThreadID: thread.id,
ShardID: sid,
Client: nil,
PreProcessing: true,
}
return nil
}
// preProcessPFMerge prepares... | Please add a comment about explicit call to the internal GETOBJECT command |
// Need to get response from both keys to handle Replace or not
rc <- &ops.StoreOp{
SeqID: 0,
RequestID: GenerateUniqueRequestID(),
Cmd: &preCmd,
IOThreadID: thread.id,
ShardID: sid,
Client: nil,
PreProcessing: true,
}
return nil
}
// preProcessPFMerge prepares... | @@ -79,3 +79,32 @@ func customProcessCopy(thread *BaseIOThread, diceDBCmd *cmd.DiceDBCmd) error {
return nil
}
+
+// preProcessPFMerge prepares the PFMERGE command for preprocessing by sending GET commands
+// to retrieve the value of all the keys to be merged with. The retrieved value is used later in the
+// dec... | internal/iothread/cmd_preprocess.go | 26 | Go | 0.214 | suggestion | 74 | 44 | 46 | false | Update `PFMERGE` to be supported as multishard command | 1,388 | DiceDB/dice | 10,326 | C | AshwinKul28 | lucifercr07 | Review this pull request change.
Language: Go
File: internal/iothread/cmd_preprocess.go
PR Title: Update `PFMERGE` to be supported as multishard command
BEFORE CODE:
// Need to get response from both keys to handle Replace or not
rc <- &ops.StoreOp{
SeqID: 0,
RequestID: GenerateUniqueRequestID(),... | Please add a comment about explicit call to the internal GETOBJECT command | 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 config
import (
"fmt"
"github.com/spf13/pflag"
"github.com/spf13/viper"
"log/slog"
"os"
"path/filepath"
"runtime"
)
con... | A better way to handle this is by adding OS specific files and let Go's compiler take care of binding the apt file. You can import this variable in `constants.go` file and refer that variable in the codebase.
This way, you don't need multiple variables. | // 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 config
import (
"fmt"
"log/slog"
"os"
"reflect"
"github.com/spf13/pflag"
"github.com/spf13/viper"
)
const (
DiceDBVers... | @@ -4,15 +4,27 @@
package config
import (
+ "fmt"
"github.com/spf13/pflag"
"github.com/spf13/viper"
+ "log/slog"
+ "os"
+ "path/filepath"
+ "runtime"
)
const (
DiceDBVersion = "0.1.0"
+
+ linuxPath = "/var/lib/dicedb"
+ darwinPath = "~/Library/Application Support/dicedb"
+ windowsPath = "C:\\ProgramDat... | config/config.go | 21 | Go | 0.786 | suggestion | 256 | 46 | 46 | false | Add default data directory for storing logs and other dicedb files, minor fixes | 1,432 | DiceDB/dice | 10,326 | C | arpitbbhayani | lucifercr07 | Review this pull request change.
Language: Go
File: config/config.go
PR Title: Add default data directory for storing logs and other dicedb files, minor fixes
BEFORE CODE: // Copyright (c) 2022-present, DiceDB contributors
// All rights reserved. Licensed under the BSD 3-Clause License. See LICENSE file in the proj... | A better way to handle this is by adding OS specific files and let Go's compiler take care of binding the apt file. You can import this variable in `constants.go` file and refer that variable in the codebase.
This way, you don't need multiple variables. | 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. |
type DiceDBConfig struct {
Host string `mapstructure:"host" default:"0.0.0.0" description:"the host address to bind to"`
Port int `mapstructure:"port" default:"7379" description:"the port to bind to"`
Username string `mapstructure:"username" default:"dicedb" description:"the username to use for authentication"`
... | Why the path `/var/` and not `/etc`? | LogLevel string `mapstructure:"log-level" default:"info" description:"the log level"`
EnableWatch bool `mapstructure:"enable-watch" default:"false" description:"enable support for .WATCH commands and real-time reactivity"`
MaxClients int `mapstructure:"max-clients" default:"20000" description:"the maximum number ... | @@ -45,10 +57,11 @@ type DiceDBConfig struct {
}
func Init(flags *pflag.FlagSet) {
+ configureParentDirPaths()
viper.SetConfigName("dicedb")
viper.SetConfigType("yaml")
viper.AddConfigPath(".")
- viper.AddConfigPath("/etc/dicedb") | config/config.go | 26 | Go | 0.214 | question | 36 | 51 | 51 | false | Add default data directory for storing logs and other dicedb files, minor fixes | 1,432 | DiceDB/dice | 10,326 | C | arpitbbhayani | lucifercr07 | Review this pull request change.
Language: Go
File: config/config.go
PR Title: Add default data directory for storing logs and other dicedb files, minor fixes
BEFORE CODE: type DiceDBConfig struct {
Host string `mapstructure:"host" default:"0.0.0.0" description:"the host address to bind to"`
Port int `mapstruc... | Why the path `/var/` and not `/etc`? | 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 := viper.Unmarshal(&Config); err != nil {
panic(err)
}
}
// ConfigureParentDirPaths Creates the default parent directory which can be used for logs and persistent data
func configureParentDirPaths() {
var err error
DefaultParentDir, err = createDefaultParentDir()
if err != nil {
slog.Warn("Fai... | this logic will become much simpler once we have OS specific files with the same variable name. Ref comment - https://github.com/golang/go/issues/18364#issue-196240462.
| // ConfigureDataDirPaths Creates the default data directory which can be used for dicedb logs and other persistent data
func configureDataDirPaths() {
// Creating dir with owner only permission
if err := os.MkdirAll(DicedbDataDir, 0o700); err != nil {
slog.Warn("Failed to create default preferences directory", slog... | @@ -59,10 +72,58 @@ func Init(flags *pflag.FlagSet) {
if flag.Name == "help" {
return
}
- viper.Set(flag.Name, flag.Value.String())
+
+ // Only updated parsed configs if the user sets value
+ if flag.Changed {
+ viper.Set(flag.Name, flag.Value.String())
+ }
})
if err := viper.Unmarshal(&Config); e... | config/config.go | 26 | Go | 0.357 | suggestion | 172 | 51 | 51 | false | Add default data directory for storing logs and other dicedb files, minor fixes | 1,432 | DiceDB/dice | 10,326 | C | arpitbbhayani | lucifercr07 | Review this pull request change.
Language: Go
File: config/config.go
PR Title: Add default data directory for storing logs and other dicedb files, minor fixes
BEFORE CODE: }
})
if err := viper.Unmarshal(&Config); err != nil {
panic(err)
}
}
// ConfigureParentDirPaths Creates the default parent directory wh... | this logic will become much simpler once we have OS specific files with the same variable name. Ref comment - https://github.com/golang/go/issues/18364#issue-196240462.
| 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 != nil {
slog.Warn("Failed to create default preferences directory", slog.String("error", err.Error()))
}
}
func createDefaultParentDir() (string, error) {
// Get the default directory path for the OS
prefDir := GetDefaultParentDirPath()
if err := os.MkdirAll(prefDir, os.ModePerm); err != nil {
return ... | There should not be any default. The same variable is defined across three files and that same var is ref in constants and then used here. I do not see we need this function at all after the above changes. |
for i := 0; i < configType.NumField(); i++ {
field := configType.Field(i)
value := configValue.Field(i)
tag := field.Tag.Get("default")
if tag != "" {
switch value.Kind() {
case reflect.String:
value.SetString(tag)
case reflect.Int:
intVal := 0
_, err := fmt.Sscanf(tag, "%d", &intVal)
... | @@ -59,10 +72,58 @@ func Init(flags *pflag.FlagSet) {
if flag.Name == "help" {
return
}
- viper.Set(flag.Name, flag.Value.String())
+
+ // Only updated parsed configs if the user sets value
+ if flag.Changed {
+ viper.Set(flag.Name, flag.Value.String())
+ }
})
if err := viper.Unmarshal(&Config); e... | config/config.go | 26 | Go | 0.5 | suggestion | 205 | 40 | 48 | false | Add default data directory for storing logs and other dicedb files, minor fixes | 1,432 | DiceDB/dice | 10,326 | C | arpitbbhayani | lucifercr07 | Review this pull request change.
Language: Go
File: config/config.go
PR Title: Add default data directory for storing logs and other dicedb files, minor fixes
BEFORE CODE: if err != nil {
slog.Warn("Failed to create default preferences directory", slog.String("error", err.Error()))
}
}
func createDefaultParent... | There should not be any default. The same variable is defined across three files and that same var is ref in constants and then used here. I do not see we need this function at all after the above changes. | 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 GetDefaultParentDirPath() string {
switch runtime.GOOS {
case "linux":
return linuxPath
case "darwin":
return expandHomeDirDarwin(darwinPath)
case "windows":
return windowsPath
default:
slog.Warn("unsupported OS, defaulting to current directory")
return DefaultParentDir
}
}
func expandHomeDirDa... | Again, this might not be required. Let's have absolute paths only, the more we support this, the more are the edge cases that we will need tp handle. | if err == nil {
value.SetInt(int64(intVal))
}
case reflect.Bool:
boolVal := false
_, err := fmt.Sscanf(tag, "%t", &boolVal)
if err == nil {
value.SetBool(boolVal)
}
}
}
}
return defaultConfig
}
func ForceInit(config *DiceDBConfig) {
defaultConfig := initDefaultConfig()
c... | @@ -59,10 +72,58 @@ func Init(flags *pflag.FlagSet) {
if flag.Name == "help" {
return
}
- viper.Set(flag.Name, flag.Value.String())
+
+ // Only updated parsed configs if the user sets value
+ if flag.Changed {
+ viper.Set(flag.Name, flag.Value.String())
+ }
})
if err := viper.Unmarshal(&Config); e... | config/config.go | 26 | Go | 0.5 | bug | 149 | 27 | 35 | false | Add default data directory for storing logs and other dicedb files, minor fixes | 1,432 | DiceDB/dice | 10,326 | C | arpitbbhayani | lucifercr07 | Review this pull request change.
Language: Go
File: config/config.go
PR Title: Add default data directory for storing logs and other dicedb files, minor fixes
BEFORE CODE: }
func GetDefaultParentDirPath() string {
switch runtime.GOOS {
case "linux":
return linuxPath
case "darwin":
return expandHomeDirDarwin... | Again, this might not be required. Let's have absolute paths only, the more we support this, the more are the edge cases that we will need tp handle. | 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. |
printConfiguration()
// TODO: Handle the addition of the default user
// and new users in a much better way. Doing this using
// and empty password check is not a good solution.
if config.Config.Password != "" {
user, _ := auth.UserStore.Add(config.Config.Username)
_ = user.SetPassword(config.Config.Password)... | WALFile would not be in `parentDir`. It would always be in `/var/log/`. Check for similar paths in other OS arch. I think most people will use Mac and Unix, so it is safe to assume that.
Also, why the path on Mac should be `... Applications`, why can't it be `/var/xxxx`? | }
ctx, cancel := context.WithCancel(context.Background())
// Handle SIGTERM and SIGINT
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGTERM, syscall.SIGINT)
var (
serverErrCh = make(chan error, 2)
wl wal.AbstractWAL
)
wl, _ = wal.NewNullWAL()
if config.Config.EnableWAL {
_wl, ... | @@ -100,9 +101,10 @@ func Start() {
wl, _ = wal.NewNullWAL()
if config.Config.EnableWAL {
- _wl, err := wal.NewAOFWAL(config.Config.WALDir)
+ WALDir := filepath.Join(config.DefaultParentDir, config.Config.WALDir) | server/main.go | 26 | Go | 0.643 | question | 274 | 51 | 51 | false | Add default data directory for storing logs and other dicedb files, minor fixes | 1,432 | DiceDB/dice | 10,326 | C | arpitbbhayani | lucifercr07 | Review this pull request change.
Language: Go
File: server/main.go
PR Title: Add default data directory for storing logs and other dicedb files, minor fixes
BEFORE CODE: printConfiguration()
// TODO: Handle the addition of the default user
// and new users in a much better way. Doing this using
// and empty pa... | WALFile would not be in `parentDir`. It would always be in `/var/log/`. Check for similar paths in other OS arch. I think most people will use Mac and Unix, so it is safe to assume that.
Also, why the path on Mac should be `... Applications`, why can't it be `/var/xxxx`? | 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 cmd
import (
"math"
"github.com/dicedb/dice/internal/object"
dstore "github.com/dicedb/dice/internal/store"
"github.com/dicedb/dice/wire"
)
var cDECR = &DiceDBCommand{
Name: "DECR",
HelpShort: "DECR decrements the value of the specified key in args by 1",
Eval: evalDECR,
}
func init() {
co... | Are there enough cyclomatic complexity that you need to add this flag? I don't feel so. Check once. | package cmd
import (
"math"
"github.com/dicedb/dice/internal/object"
dstore "github.com/dicedb/dice/internal/store"
"github.com/dicedb/dice/wire"
)
var cDECR = &DiceDBCommand{
Name: "DECR",
HelpShort: "DECR decrements the value of the specified key in args by 1",
Eval: evalDECR,
}
func init() {
co... | @@ -0,0 +1,59 @@
+package cmd
+
+import (
+ "math"
+
+ "github.com/dicedb/dice/internal/object"
+ dstore "github.com/dicedb/dice/internal/store"
+ "github.com/dicedb/dice/wire"
+)
+
+var cDECR = &DiceDBCommand{
+ Name: "DECR",
+ HelpShort: "DECR decrements the value of the specified key in args by 1",
+ Eval: ... | internal/cmd/cmd_decr.go | 21 | Go | 0.214 | performance | 99 | 46 | 46 | false | feat: port `DECR` command | 1,437 | DiceDB/dice | 10,326 | C | arpitbbhayani | manosriram | Review this pull request change.
Language: Go
File: internal/cmd/cmd_decr.go
PR Title: feat: port `DECR` command
BEFORE CODE: package cmd
import (
"math"
"github.com/dicedb/dice/internal/object"
dstore "github.com/dicedb/dice/internal/store"
"github.com/dicedb/dice/wire"
)
var cDECR = &DiceDBCommand{
Name: ... | Are there enough cyclomatic complexity that you need to add this flag? I don't feel so. Check once. | 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. |
"github.com/dicedb/dice/internal/object"
dstore "github.com/dicedb/dice/internal/store"
"github.com/dicedb/dice/wire"
)
var cDECR = &DiceDBCommand{
Name: "DECR",
HelpShort: "DECR decrements the value of the specified key in args by 1",
Eval: evalDECR,
}
func init() {
commandRegistry.AddCommand(cDECR)... | Create a contant in the `cmd` module called `INFINITE_EXPIRATION` and set the value to be `-1`. Use it here. This way, we will be able to reuse the same variable throughout the codebase. | "github.com/dicedb/dice/internal/object"
dstore "github.com/dicedb/dice/internal/store"
"github.com/dicedb/dice/wire"
)
var cDECR = &DiceDBCommand{
Name: "DECR",
HelpShort: "DECR decrements the value of the specified key in args by 1",
Eval: evalDECR,
}
func init() {
commandRegistry.AddCommand(cDECR)... | @@ -0,0 +1,59 @@
+package cmd
+
+import (
+ "math"
+
+ "github.com/dicedb/dice/internal/object"
+ dstore "github.com/dicedb/dice/internal/store"
+ "github.com/dicedb/dice/wire"
+)
+
+var cDECR = &DiceDBCommand{
+ Name: "DECR",
+ HelpShort: "DECR decrements the value of the specified key in args by 1",
+ Eval: ... | internal/cmd/cmd_decr.go | 26 | Go | 0.571 | suggestion | 186 | 51 | 51 | false | feat: port `DECR` command | 1,437 | DiceDB/dice | 10,326 | C | arpitbbhayani | manosriram | Review this pull request change.
Language: Go
File: internal/cmd/cmd_decr.go
PR Title: feat: port `DECR` command
BEFORE CODE: "github.com/dicedb/dice/internal/object"
dstore "github.com/dicedb/dice/internal/store"
"github.com/dicedb/dice/wire"
)
var cDECR = &DiceDBCommand{
Name: "DECR",
HelpShort: "DECR ... | Create a contant in the `cmd` module called `INFINITE_EXPIRATION` and set the value to be `-1`. Use it here. This way, we will be able to reuse the same variable throughout the codebase. | 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. |
HelpShort: "DECR decrements the value of the specified key in args by 1",
Eval: evalDECR,
}
func init() {
commandRegistry.AddCommand(cDECR)
}
//nolint:gocyclo
func evalDECR(c *Cmd, s *dstore.Store) (*CmdRes, error) {
if len(c.C.Args) <= 1 {
return cmdResNil, errWrongArgumentCount("DECR")
}
incr := int64(... | what do you mean type is not "KV"? This seems an inaccurate comment. | HelpShort: "DECR decrements the value of the specified key in args by 1",
Eval: evalDECR,
}
func init() {
commandRegistry.AddCommand(cDECR)
}
func evalDECR(c *Cmd, s *dstore.Store) (*CmdRes, error) {
if len(c.C.Args) <= 1 {
return cmdResNil, errWrongArgumentCount("DECR")
}
incr := int64(-1)
key := c.C... | @@ -0,0 +1,59 @@
+package cmd
+
+import (
+ "math"
+
+ "github.com/dicedb/dice/internal/object"
+ dstore "github.com/dicedb/dice/internal/store"
+ "github.com/dicedb/dice/wire"
+)
+
+var cDECR = &DiceDBCommand{
+ Name: "DECR",
+ HelpShort: "DECR decrements the value of the specified key in args by 1",
+ Eval: ... | internal/cmd/cmd_decr.go | 26 | Go | 0.357 | question | 68 | 48 | 45 | false | feat: port `DECR` command | 1,437 | DiceDB/dice | 10,326 | C | arpitbbhayani | manosriram | Review this pull request change.
Language: Go
File: internal/cmd/cmd_decr.go
PR Title: feat: port `DECR` command
BEFORE CODE: HelpShort: "DECR decrements the value of the specified key in args by 1",
Eval: evalDECR,
}
func init() {
commandRegistry.AddCommand(cDECR)
}
//nolint:gocyclo
func evalDECR(c *Cmd,... | what do you mean type is not "KV"? This seems an inaccurate comment. | 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. |
//nolint:gocyclo
func evalDECR(c *Cmd, s *dstore.Store) (*CmdRes, error) {
if len(c.C.Args) <= 1 {
return cmdResNil, errWrongArgumentCount("DECR")
}
incr := int64(-1)
key := c.C.Args[0]
obj := s.Get(key)
if obj == nil {
obj = s.NewObj(incr, -1, object.ObjTypeInt)
s.Put(key, obj)
return &CmdRes{R: &wire.R... | Club both of these in one. Also, we need not use this `AssertTypeWithError` or `AssertType` function, given now it is super easy to check for type of the object. You can directly compare the type using `struct ObjectType`. | func evalDECR(c *Cmd, s *dstore.Store) (*CmdRes, error) {
if len(c.C.Args) <= 1 {
return cmdResNil, errWrongArgumentCount("DECR")
}
incr := int64(-1)
key := c.C.Args[0]
obj := s.Get(key)
if obj == nil {
obj = s.NewObj(incr, INFINITE_EXPIRATION, object.ObjTypeInt)
s.Put(key, obj)
return &CmdRes{R: &wire.... | @@ -0,0 +1,59 @@
+package cmd
+
+import (
+ "math"
+
+ "github.com/dicedb/dice/internal/object"
+ dstore "github.com/dicedb/dice/internal/store"
+ "github.com/dicedb/dice/wire"
+)
+
+var cDECR = &DiceDBCommand{
+ Name: "DECR",
+ HelpShort: "DECR decrements the value of the specified key in args by 1",
+ Eval: ... | internal/cmd/cmd_decr.go | 26 | Go | 0.786 | suggestion | 222 | 40 | 37 | false | feat: port `DECR` command | 1,437 | DiceDB/dice | 10,326 | C | arpitbbhayani | manosriram | Review this pull request change.
Language: Go
File: internal/cmd/cmd_decr.go
PR Title: feat: port `DECR` command
BEFORE CODE: //nolint:gocyclo
func evalDECR(c *Cmd, s *dstore.Store) (*CmdRes, error) {
if len(c.C.Args) <= 1 {
return cmdResNil, errWrongArgumentCount("DECR")
}
incr := int64(-1)
key := c.C.Args[... | Club both of these in one. Also, we need not use this `AssertTypeWithError` or `AssertType` function, given now it is super easy to check for type of the object. You can directly compare the type using `struct ObjectType`. | 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 (cmd *DiceDBCmd) Key() string {
var c string
if len(cmd.Args) > 0 {
c = cmd.Args[0]
}
return c
}
func errWrongArgumentCount(command string) error {
return fmt.Errorf("wrong number of arguments for '%s' command", strings.ToUpper(command))
}
var errUnknownObjectType = errors.New("unknown object type")
//no... | given the error, we need not pass `command` to this. this should be a genetic `overflow` error. | // This is not true for all commands, however, for now this is only used by the watch manager,
// which as of now only supports a small subset of commands (all of which fit this implementation).
func (cmd *DiceDBCmd) Key() string {
var c string
if len(cmd.Args) > 0 {
c = cmd.Args[0]
}
return c
}
func errWrongArg... | @@ -142,6 +142,21 @@ func errInvalidValue(command, param string) error {
return fmt.Errorf("invalid value for a parameter in '%s' command for %s parameter", strings.ToUpper(command), strings.ToUpper(param))
}
+//nolint:unparam
+func errIntegerOutOfRange(command string) error { | internal/cmd/cmds.go | 26 | Go | 0.571 | bug | 95 | 47 | 40 | false | feat: port `DECR` command | 1,437 | DiceDB/dice | 10,326 | C | arpitbbhayani | manosriram | Review this pull request change.
Language: Go
File: internal/cmd/cmds.go
PR Title: feat: port `DECR` command
BEFORE CODE: func (cmd *DiceDBCmd) Key() string {
var c string
if len(cmd.Args) > 0 {
c = cmd.Args[0]
}
return c
}
func errWrongArgumentCount(command string) error {
return fmt.Errorf("wrong number o... | given the error, we need not pass `command` to this. this should be a genetic `overflow` error. | 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 errUnknownObjectType = errors.New("unknown object type")
//nolint:unparam
func errInvalidSyntax(command string) error {
return fmt.Errorf("invalid syntax for '%s' command", strings.ToUpper(command))
}
//nolint:unparam
func errInvalidValue(command, param string) error {
return fmt.Errorf("invalid value for a pa... | again, this should be a generic `overflow` error. Also, what is the difference between `errOverflow` and `errIntegerOutOfRange`? Seems the same to me. we can club the two in one. | return fmt.Errorf("wrong number of arguments for '%s' command", strings.ToUpper(command))
}
var errUnknownObjectType = errors.New("unknown object type")
var errIntegerOutOfRange = errors.New("integer out of range")
//nolint:unparam
func errInvalidSyntax(command string) error {
return fmt.Errorf("invalid syntax for ... | @@ -142,6 +142,21 @@ func errInvalidValue(command, param string) error {
return fmt.Errorf("invalid value for a parameter in '%s' command for %s parameter", strings.ToUpper(command), strings.ToUpper(param))
}
+//nolint:unparam
+func errIntegerOutOfRange(command string) error {
+ return fmt.Errorf("integer out of r... | internal/cmd/cmds.go | 26 | Go | 0.714 | bug | 178 | 36 | 29 | false | feat: port `DECR` command | 1,437 | DiceDB/dice | 10,326 | C | arpitbbhayani | manosriram | Review this pull request change.
Language: Go
File: internal/cmd/cmds.go
PR Title: feat: port `DECR` command
BEFORE CODE:
var errUnknownObjectType = errors.New("unknown object type")
//nolint:unparam
func errInvalidSyntax(command string) error {
return fmt.Errorf("invalid syntax for '%s' command", strings.ToUppe... | again, this should be a generic `overflow` error. Also, what is the difference between `errOverflow` and `errIntegerOutOfRange`? Seems the same to me. we can club the two in one. | 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 cmd
import (
dstore "github.com/dicedb/dice/internal/store"
"github.com/dicedb/dice/wire"
)
var cDEL = &DiceDBCommand{
Name: "DEL",
HelpShort: "DEL deletes all the specified keys in args list",
Eval: evalDEL,
}
func init() {
commandRegistry.AddCommand(cDEL)
}
// evalDEL deletes all the speci... | @arpitbbhayani It is not specific to this PR but just noticed `init` function and thought I'd mention this -
[You Should Think Twice Before Using the init Function in Go](https://www.bytesizego.com/blog/init-function-golang)
[100 Go Mistakes and How to Avoid Them #3: Misusing init functions](https://medium.com/@liuqi... | package cmd
import (
dstore "github.com/dicedb/dice/internal/store"
"github.com/dicedb/dice/wire"
)
var cDEL = &DiceDBCommand{
Name: "DEL",
HelpShort: "DEL deletes all the specified keys in args list",
Eval: evalDEL,
}
func init() {
commandRegistry.AddCommand(cDEL)
}
// evalDEL deletes all the speci... | @@ -0,0 +1,42 @@
+package cmd
+
+import (
+ dstore "github.com/dicedb/dice/internal/store"
+ "github.com/dicedb/dice/wire"
+)
+
+var cDEL = &DiceDBCommand{
+ Name: "DEL",
+ HelpShort: "DEL deletes all the specified keys in args list",
+ Eval: evalDEL,
+}
+
+func init() {
+ commandRegistry.AddCommand(cDEL) | internal/cmd/cmd_del.go | 15 | Go | 0.786 | bug | 778 | 40 | 40 | false | feat: port DEL command | 1,445 | DiceDB/dice | 10,326 | C | DiabolusGX | manosriram | Review this pull request change.
Language: Go
File: internal/cmd/cmd_del.go
PR Title: feat: port DEL command
BEFORE CODE: package cmd
import (
dstore "github.com/dicedb/dice/internal/store"
"github.com/dicedb/dice/wire"
)
var cDEL = &DiceDBCommand{
Name: "DEL",
HelpShort: "DEL deletes all the specified k... | @arpitbbhayani It is not specific to this PR but just noticed `init` function and thought I'd mention this -
[You Should Think Twice Before Using the init Function in Go](https://www.bytesizego.com/blog/init-function-golang)
[100 Go Mistakes and How to Avoid Them #3: Misusing init functions](https://medium.com/@liuqi... | 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 cmd
import (
dstore "github.com/dicedb/dice/internal/store"
"github.com/dicedb/dice/wire"
)
var cEXISTS = &DiceDBCommand{
Name: "EXISTS",
HelpShort: "Returns the number of keys existing in the db",
Eval: evalEXISTS,
}
func init() {
commandRegistry.AddCommand(cEXISTS)
}
func evalEXISTS(c *Cmd, s *dstor... | The short help does not seem apt. | package cmd
import (
dstore "github.com/dicedb/dice/internal/store"
"github.com/dicedb/dice/wire"
)
var cEXISTS = &DiceDBCommand{
Name: "EXISTS",
HelpShort: "Returns the count of keys that exist among the given arguments without modifying them",
Eval: evalEXISTS,
}
func init() {
commandRegistry.AddCommand(cEXI... | @@ -0,0 +1,35 @@
+package cmd
+
+import (
+ dstore "github.com/dicedb/dice/internal/store"
+ "github.com/dicedb/dice/wire"
+)
+
+var cEXISTS = &DiceDBCommand{
+ Name: "EXISTS",
+ HelpShort: "Returns the number of keys existing in the db", | internal/cmd/cmd_exists.go | 10 | Go | 0.071 | suggestion | 33 | 35 | 35 | false | Migrated EXISTS command to IronHawk engine | 1,447 | DiceDB/dice | 10,326 | C | arpitbbhayani | n4vxn | Review this pull request change.
Language: Go
File: internal/cmd/cmd_exists.go
PR Title: Migrated EXISTS command to IronHawk engine
BEFORE CODE: package cmd
import (
dstore "github.com/dicedb/dice/internal/store"
"github.com/dicedb/dice/wire"
)
var cEXISTS = &DiceDBCommand{
Name: "EXISTS",
HelpShort: "Returns... | The short help does not seem apt. | 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 (
dstore "github.com/dicedb/dice/internal/store"
"github.com/dicedb/dice/wire"
)
var cEXISTS = &DiceDBCommand{
Name: "EXISTS",
HelpShort: "Returns the number of keys existing in the db",
Eval: evalEXISTS,
}
func init() {
commandRegistry.AddCommand(cEXISTS)
}
func evalEXISTS(c *Cmd, s *dstore.Store) (*C... | mention the reason why we used `GetNoTouch` function in the code as a comment. |
import (
dstore "github.com/dicedb/dice/internal/store"
"github.com/dicedb/dice/wire"
)
var cEXISTS = &DiceDBCommand{
Name: "EXISTS",
HelpShort: "Returns the count of keys that exist among the given arguments without modifying them",
Eval: evalEXISTS,
}
func init() {
commandRegistry.AddCommand(cEXISTS)
}
func... | @@ -0,0 +1,35 @@
+package cmd
+
+import (
+ dstore "github.com/dicedb/dice/internal/store"
+ "github.com/dicedb/dice/wire"
+)
+
+var cEXISTS = &DiceDBCommand{
+ Name: "EXISTS",
+ HelpShort: "Returns the number of keys existing in the db",
+ Eval: evalEXISTS,
+}
+
+func init() {
+ commandRegistry.AddCommand(cEXISTS)
+}
... | internal/cmd/cmd_exists.go | 26 | Go | 0.429 | suggestion | 78 | 34 | 35 | false | Migrated EXISTS command to IronHawk engine | 1,447 | DiceDB/dice | 10,326 | C | arpitbbhayani | n4vxn | Review this pull request change.
Language: Go
File: internal/cmd/cmd_exists.go
PR Title: Migrated EXISTS command to IronHawk engine
BEFORE CODE:
import (
dstore "github.com/dicedb/dice/internal/store"
"github.com/dicedb/dice/wire"
)
var cEXISTS = &DiceDBCommand{
Name: "EXISTS",
HelpShort: "Returns the number ... | mention the reason why we used `GetNoTouch` function in the code as a comment. | 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. |
}
// FLUSHDB is used to remove all keys from the currently selected database in a DiceDB instance.
//
// # The function expects no arguments
//
// Parameters:
// - c *Cmd: The command context containing the arguments
// - s *dstore.Store: The data store instance
//
// Returns:
// - *CmdRes: OK or nil
// - erro... | Rename the method `ResetStore` to `Reset` across the codebase. | package cmd
import (
"github.com/dicedb/dice/internal/store"
dstore "github.com/dicedb/dice/internal/store"
)
const (
SYNC string = "sync"
ASYNC string = "async"
)
var cFLUSHDB = &DiceDBCommand{
Name: "FLUSHDB",
HelpShort: "FLUSHDB deletes all keys.",
Eval: evalFLUSHDB,
}
func init() {
commandReg... | @@ -0,0 +1,54 @@
+package cmd
+
+import (
+ "strings"
+
+ "github.com/dicedb/dice/internal/store"
+ dstore "github.com/dicedb/dice/internal/store"
+)
+
+const (
+ SYNC string = "sync"
+ ASYNC string = "async"
+)
+
+var cFLUSHDB = &DiceDBCommand{
+ Name: "FLUSHDB",
+ HelpShort: "FLUSHDB removes all keys from the c... | internal/cmd/cmd_flushdb.go | 26 | Go | 0.429 | suggestion | 62 | 33 | 42 | false | port FLUSHDB command to IronHawk | 1,457 | DiceDB/dice | 10,326 | C | arpitbbhayani | manosriram | Review this pull request change.
Language: Go
File: internal/cmd/cmd_flushdb.go
PR Title: port FLUSHDB command to IronHawk
BEFORE CODE: }
// FLUSHDB is used to remove all keys from the currently selected database in a DiceDB instance.
//
// # The function expects no arguments
//
// Parameters:
// - c *Cmd: The c... | Rename the method `ResetStore` to `Reset` across the codebase. | 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. |
}
// FLUSHDB is used to remove all keys from the currently selected database in a DiceDB instance.
//
// # The function expects no arguments
//
// Parameters:
// - c *Cmd: The command context containing the arguments
// - s *dstore.Store: The data store instance
//
// Returns:
// - *CmdRes: OK or nil
// - erro... | If the function expects no argument when what is the point of having sync/async here? | package cmd
import (
"github.com/dicedb/dice/internal/store"
dstore "github.com/dicedb/dice/internal/store"
)
const (
SYNC string = "sync"
ASYNC string = "async"
)
var cFLUSHDB = &DiceDBCommand{
Name: "FLUSHDB",
HelpShort: "FLUSHDB deletes all keys.",
Eval: evalFLUSHDB,
}
func init() {
commandReg... | @@ -0,0 +1,54 @@
+package cmd
+
+import (
+ "strings"
+
+ "github.com/dicedb/dice/internal/store"
+ dstore "github.com/dicedb/dice/internal/store"
+)
+
+const (
+ SYNC string = "sync"
+ ASYNC string = "async"
+)
+
+var cFLUSHDB = &DiceDBCommand{
+ Name: "FLUSHDB",
+ HelpShort: "FLUSHDB removes all keys from the c... | internal/cmd/cmd_flushdb.go | 26 | Go | 0.214 | question | 85 | 33 | 42 | false | port FLUSHDB command to IronHawk | 1,457 | DiceDB/dice | 10,326 | C | arpitbbhayani | manosriram | Review this pull request change.
Language: Go
File: internal/cmd/cmd_flushdb.go
PR Title: port FLUSHDB command to IronHawk
BEFORE CODE: }
// FLUSHDB is used to remove all keys from the currently selected database in a DiceDB instance.
//
// # The function expects no arguments
//
// Parameters:
// - c *Cmd: The c... | If the function expects no argument when what is the point of having sync/async here? | 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 cmd
import (
"strings"
"github.com/dicedb/dice/internal/store"
dstore "github.com/dicedb/dice/internal/store"
)
const (
SYNC string = "sync"
ASYNC string = "async"
)
var cFLUSHDB = &DiceDBCommand{
Name: "FLUSHDB",
HelpShort: "FLUSHDB removes all keys from the currently selected database.",
Eva... | There is no "selected database", change this to "FLUSHDB deletes all the keys". | package cmd
import (
"github.com/dicedb/dice/internal/store"
dstore "github.com/dicedb/dice/internal/store"
)
const (
SYNC string = "sync"
ASYNC string = "async"
)
var cFLUSHDB = &DiceDBCommand{
Name: "FLUSHDB",
HelpShort: "FLUSHDB deletes all keys.",
Eval: evalFLUSHDB,
}
func init() {
commandReg... | @@ -0,0 +1,54 @@
+package cmd
+
+import (
+ "strings"
+
+ "github.com/dicedb/dice/internal/store"
+ dstore "github.com/dicedb/dice/internal/store"
+)
+
+const (
+ SYNC string = "sync"
+ ASYNC string = "async"
+)
+
+var cFLUSHDB = &DiceDBCommand{
+ Name: "FLUSHDB",
+ HelpShort: "FLUSHDB removes all keys from the c... | internal/cmd/cmd_flushdb.go | 17 | Go | 0.286 | suggestion | 79 | 42 | 42 | false | port FLUSHDB command to IronHawk | 1,457 | DiceDB/dice | 10,326 | C | arpitbbhayani | manosriram | Review this pull request change.
Language: Go
File: internal/cmd/cmd_flushdb.go
PR Title: port FLUSHDB command to IronHawk
BEFORE CODE: package cmd
import (
"strings"
"github.com/dicedb/dice/internal/store"
dstore "github.com/dicedb/dice/internal/store"
)
const (
SYNC string = "sync"
ASYNC string = "async"... | There is no "selected database", change this to "FLUSHDB deletes all the 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. |
package cmd
import (
"strings"
"github.com/dicedb/dice/internal/store"
dstore "github.com/dicedb/dice/internal/store"
)
const (
SYNC string = "sync"
ASYNC string = "async"
)
var cFLUSHDB = &DiceDBCommand{
Name: "FLUSHDB",
HelpShort: "FLUSHDB removes all keys from the currently selected database.",
Eva... | Change this to `FLUSHDB deletes all the keys` | package cmd
import (
"github.com/dicedb/dice/internal/store"
dstore "github.com/dicedb/dice/internal/store"
)
const (
SYNC string = "sync"
ASYNC string = "async"
)
var cFLUSHDB = &DiceDBCommand{
Name: "FLUSHDB",
HelpShort: "FLUSHDB deletes all keys.",
Eval: evalFLUSHDB,
}
func init() {
commandReg... | @@ -0,0 +1,54 @@
+package cmd
+
+import (
+ "strings"
+
+ "github.com/dicedb/dice/internal/store"
+ dstore "github.com/dicedb/dice/internal/store"
+)
+
+const (
+ SYNC string = "sync"
+ ASYNC string = "async"
+)
+
+var cFLUSHDB = &DiceDBCommand{
+ Name: "FLUSHDB",
+ HelpShort: "FLUSHDB removes all keys from the c... | internal/cmd/cmd_flushdb.go | 25 | Go | 0.286 | suggestion | 45 | 50 | 42 | false | port FLUSHDB command to IronHawk | 1,457 | DiceDB/dice | 10,326 | C | arpitbbhayani | manosriram | Review this pull request change.
Language: Go
File: internal/cmd/cmd_flushdb.go
PR Title: port FLUSHDB command to IronHawk
BEFORE CODE: package cmd
import (
"strings"
"github.com/dicedb/dice/internal/store"
dstore "github.com/dicedb/dice/internal/store"
)
const (
SYNC string = "sync"
ASYNC string = "async"... | Change this to `FLUSHDB deletes all the 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(cFLUSHDB)
}
// FLUSHDB is used to remove all keys from the currently selected database in a DiceDB instance.
//
// # The function expects no arguments
//
// Parameters:
// - c *Cmd: The command context containing the arguments
// - s *dstore.Store: The data store instance... |
If the function expects no argument when what is the point of having sync/async here?
| package cmd
import (
"github.com/dicedb/dice/internal/store"
dstore "github.com/dicedb/dice/internal/store"
)
const (
SYNC string = "sync"
ASYNC string = "async"
)
var cFLUSHDB = &DiceDBCommand{
Name: "FLUSHDB",
HelpShort: "FLUSHDB deletes all keys.",
Eval: evalFLUSHDB,
}
func init() {
commandReg... | @@ -0,0 +1,54 @@
+package cmd
+
+import (
+ "strings"
+
+ "github.com/dicedb/dice/internal/store"
+ dstore "github.com/dicedb/dice/internal/store"
+)
+
+const (
+ SYNC string = "sync"
+ ASYNC string = "async"
+)
+
+var cFLUSHDB = &DiceDBCommand{
+ Name: "FLUSHDB",
+ HelpShort: "FLUSHDB removes all keys from the c... | internal/cmd/cmd_flushdb.go | 26 | Go | 0.214 | question | 91 | 36 | 42 | false | port FLUSHDB command to IronHawk | 1,457 | DiceDB/dice | 10,326 | C | arpitbbhayani | manosriram | Review this pull request change.
Language: Go
File: internal/cmd/cmd_flushdb.go
PR Title: port FLUSHDB command to IronHawk
BEFORE CODE:
func init() {
commandRegistry.AddCommand(cFLUSHDB)
}
// FLUSHDB is used to remove all keys from the currently selected database in a DiceDB instance.
//
// # The function expect... |
If the function expects no argument when what is the point of having sync/async here?
| 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 cmd
import (
"github.com/dicedb/dice/internal/object"
dstore "github.com/dicedb/dice/internal/store"
"github.com/dicedb/dicedb-go/wire"
)
var cGETDEL = &DiceDBCommand{
Name: "GETDEL",
HelpShort: "GETDEL returns the value for the queried key in args.",
Eval: evalGETDEL,
}
func init() {
comman... | The short documentation seems wrong here. it should be - `GETDEL returns the value of the key and then deletes the key.` | package cmd
import (
"github.com/dicedb/dice-go/wire"
"github.com/dicedb/dice/internal/object"
dstore "github.com/dicedb/dice/internal/store"
)
var cGETDEL = &DiceDBCommand{
Name: "GETDEL",
HelpShort: "GETDEL returns the value of the key and then deletes the key.",
Eval: evalGETDEL,
}
func init() {
... | @@ -0,0 +1,92 @@
+package cmd
+
+import (
+ "github.com/dicedb/dice/internal/object"
+ dstore "github.com/dicedb/dice/internal/store"
+ "github.com/dicedb/dicedb-go/wire"
+)
+
+var cGETDEL = &DiceDBCommand{
+ Name: "GETDEL",
+ HelpShort: "GETDEL returns the value for the queried key in args.", | internal/cmd/cmd_getdel.go | 11 | Go | 0.571 | bug | 120 | 36 | 36 | false | feat: port GETDEL command | 1,464 | DiceDB/dice | 10,326 | C | arpitbbhayani | manosriram | Review this pull request change.
Language: Go
File: internal/cmd/cmd_getdel.go
PR Title: feat: port GETDEL command
BEFORE CODE: package cmd
import (
"github.com/dicedb/dice/internal/object"
dstore "github.com/dicedb/dice/internal/store"
"github.com/dicedb/dicedb-go/wire"
)
var cGETDEL = &DiceDBCommand{
Name: ... | The short documentation seems wrong here. it should be - `GETDEL returns the value of the key and then deletes the key.` | 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. |
"github.com/dicedb/dicedb-go/wire"
)
var cGETDEL = &DiceDBCommand{
Name: "GETDEL",
HelpShort: "GETDEL returns the value for the queried key in args.",
Eval: evalGETDEL,
}
func init() {
commandRegistry.AddCommand(cGETDEL)
}
// evalGETDEL returns the value for the queried key in args
//
// The function ... | UPdate the documentation accordingly. | dstore "github.com/dicedb/dice/internal/store"
)
var cGETDEL = &DiceDBCommand{
Name: "GETDEL",
HelpShort: "GETDEL returns the value of the key and then deletes the key.",
Eval: evalGETDEL,
}
func init() {
commandRegistry.AddCommand(cGETDEL)
}
// GETDEL returns the value of the key and then deletes the... | @@ -0,0 +1,92 @@
+package cmd
+
+import (
+ "github.com/dicedb/dice/internal/object"
+ dstore "github.com/dicedb/dice/internal/store"
+ "github.com/dicedb/dicedb-go/wire"
+)
+
+var cGETDEL = &DiceDBCommand{
+ Name: "GETDEL",
+ HelpShort: "GETDEL returns the value for the queried key in args.",
+ Eval: evalGET... | internal/cmd/cmd_getdel.go | 26 | Go | 0.071 | suggestion | 37 | 51 | 51 | false | feat: port GETDEL command | 1,464 | DiceDB/dice | 10,326 | C | arpitbbhayani | manosriram | Review this pull request change.
Language: Go
File: internal/cmd/cmd_getdel.go
PR Title: feat: port GETDEL command
BEFORE CODE: "github.com/dicedb/dicedb-go/wire"
)
var cGETDEL = &DiceDBCommand{
Name: "GETDEL",
HelpShort: "GETDEL returns the value for the queried key in args.",
Eval: evalGETDEL,
}
f... | UPdate the documentation accordingly. | 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. |
// - c *Cmd: The command context containing the arguments
// - s *dstore.Store: The data store instance
//
// Returns:
// - *CmdRes: Response containing the value for the queried key.
// - error: Error if wrong number of arguments or wrong value type.
func evalGETDEL(c *Cmd, s *dstore.Store) (*CmdRes, error) {
... | why this check? we can safely remove them. DiceDB will return the value as is and then will delete the key. | // - c *Cmd: The command context containing the arguments
// - s *dstore.Store: The data store instance
//
// Returns:
// - *CmdRes: Response containing the value for the queried key.
// - error: Error if wrong number of arguments or wrong value type.
func evalGETDEL(c *Cmd, s *dstore.Store) (*CmdRes, error) {
... | @@ -0,0 +1,92 @@
+package cmd
+
+import (
+ "github.com/dicedb/dice/internal/object"
+ dstore "github.com/dicedb/dice/internal/store"
+ "github.com/dicedb/dicedb-go/wire"
+)
+
+var cGETDEL = &DiceDBCommand{
+ Name: "GETDEL",
+ HelpShort: "GETDEL returns the value for the queried key in args.",
+ Eval: evalGET... | internal/cmd/cmd_getdel.go | 26 | Go | 0.429 | question | 107 | 51 | 45 | false | feat: port GETDEL command | 1,464 | DiceDB/dice | 10,326 | C | arpitbbhayani | manosriram | Review this pull request change.
Language: Go
File: internal/cmd/cmd_getdel.go
PR Title: feat: port GETDEL command
BEFORE CODE: // - c *Cmd: The command context containing the arguments
// - s *dstore.Store: The data store instance
//
// Returns:
// - *CmdRes: Response containing the value for the queried key... | why this check? we can safely remove them. DiceDB will return the value as is and then will delete the key. | 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. |
Value: &wire.Response_VInt{VInt: objVal.Value.(int64)},
}}, nil
} else if IsString(objVal.Value) {
return cmdResNil, errUnexpectedType("int64", "string")
} else {
return cmdResNil, errUnexpectedType("int64", "unknown")
}
case object.ObjTypeString:
// Value is stored as a string, use type assertion... | As of today, let this raise the error. I am yet to figureout the byte array representation in `protos`. Remove this case and let this raise an error. | package cmd
import (
"github.com/dicedb/dice-go/wire"
"github.com/dicedb/dice/internal/object"
dstore "github.com/dicedb/dice/internal/store"
)
var cGETDEL = &DiceDBCommand{
Name: "GETDEL",
HelpShort: "GETDEL returns the value of the key and then deletes the key.",
Eval: evalGETDEL,
}
func init() {
... | @@ -0,0 +1,92 @@
+package cmd
+
+import (
+ "github.com/dicedb/dice/internal/object"
+ dstore "github.com/dicedb/dice/internal/store"
+ "github.com/dicedb/dicedb-go/wire"
+)
+
+var cGETDEL = &DiceDBCommand{
+ Name: "GETDEL",
+ HelpShort: "GETDEL returns the value for the queried key in args.",
+ Eval: evalGET... | internal/cmd/cmd_getdel.go | 26 | Go | 0.714 | refactor | 149 | 31 | 70 | false | feat: port GETDEL command | 1,464 | DiceDB/dice | 10,326 | C | arpitbbhayani | manosriram | Review this pull request change.
Language: Go
File: internal/cmd/cmd_getdel.go
PR Title: feat: port GETDEL command
BEFORE CODE: Value: &wire.Response_VInt{VInt: objVal.Value.(int64)},
}}, nil
} else if IsString(objVal.Value) {
return cmdResNil, errUnexpectedType("int64", "string")
} else {
return c... | As of today, let this raise the error. I am yet to figureout the byte array representation in `protos`. Remove this case and let this raise an error. | 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. |
objVal := s.GetDel(key)
// Decode and return the value based on its encoding
switch oType := objVal.Type; oType {
case object.ObjTypeInt:
// Value is stored as an int64, so use type assertion
if IsInt64(objVal.Value) {
return &CmdRes{R: &wire.Response{
Value: &wire.Response_VInt{VInt: objVal.Value.(int6... | We do not need these checks, if the objecttype is int then it is end and we need not check for it to be string again. Same for the switch case above. | package cmd
import (
"github.com/dicedb/dice-go/wire"
"github.com/dicedb/dice/internal/object"
dstore "github.com/dicedb/dice/internal/store"
)
var cGETDEL = &DiceDBCommand{
Name: "GETDEL",
HelpShort: "GETDEL returns the value of the key and then deletes the key.",
Eval: evalGETDEL,
}
func init() {
... | @@ -0,0 +1,92 @@
+package cmd
+
+import (
+ "github.com/dicedb/dice/internal/object"
+ dstore "github.com/dicedb/dice/internal/store"
+ "github.com/dicedb/dicedb-go/wire"
+)
+
+var cGETDEL = &DiceDBCommand{
+ Name: "GETDEL",
+ HelpShort: "GETDEL returns the value for the queried key in args.",
+ Eval: evalGET... | internal/cmd/cmd_getdel.go | 26 | Go | 0.5 | suggestion | 149 | 39 | 70 | false | feat: port GETDEL command | 1,464 | DiceDB/dice | 10,326 | C | arpitbbhayani | manosriram | Review this pull request change.
Language: Go
File: internal/cmd/cmd_getdel.go
PR Title: feat: port GETDEL command
BEFORE CODE: objVal := s.GetDel(key)
// Decode and return the value based on its encoding
switch oType := objVal.Type; oType {
case object.ObjTypeInt:
// Value is stored as an int64, so use type... | We do not need these checks, if the objecttype is int then it is end and we need not check for it to be string again. Same for the switch case above. | 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 := c.C.Args[0]
obj := s.Get(key)
if obj == nil {
return &CmdRes{R: &wire.Response{
Value: &wire.Response_VStr{
VStr: "none",
},
}}, nil
}
var typeStr string
switch oType := obj.Type; oType {
case object.ObjTypeString, object.ObjTypeInt, object.ObjTypeByteArray:
typeStr = "string"
case obje... | Why not just define a String method? I recommend add the following method in `object.go` file and call the `String` function here.
```go
// String returns the name of the object type as a string
func (ot ObjectType) String() string {
names := [...]string{
"string",
"",
"",
"json",
"bytes",
"int... | package cmd
import (
dstore "github.com/dicedb/dice/internal/store"
"github.com/dicedb/dicedb-go/wire"
)
var cType = &DiceDBCommand{
Name: "TYPE",
HelpShort: "Determine data type of the value stored at a specified key",
Eval: evalTYPE,
}
func init() {
commandRegistry.AddCommand(cType)
}
func evalTYP... | @@ -0,0 +1,56 @@
+package cmd
+
+import (
+ "github.com/dicedb/dice/internal/object"
+ dstore "github.com/dicedb/dice/internal/store"
+ "github.com/dicedb/dicedb-go/wire"
+)
+
+var cType = &DiceDBCommand{
+ Name: "TYPE",
+ HelpShort: "Determine data type of the value stored at a specified key",
+ Eval: evalTY... | internal/cmd/cmd_type.go | 26 | Go | 0.929 | question | 518 | 34 | 42 | false | Port TYPE command | 1,475 | DiceDB/dice | 10,326 | C | arpitbbhayani | pankajjs | Review this pull request change.
Language: Go
File: internal/cmd/cmd_type.go
PR Title: Port TYPE command
BEFORE CODE: key := c.C.Args[0]
obj := s.Get(key)
if obj == nil {
return &CmdRes{R: &wire.Response{
Value: &wire.Response_VStr{
VStr: "none",
},
}}, nil
}
var typeStr string
switch oType :... | Why not just define a String method? I recommend add the following method in `object.go` file and call the `String` function here.
```go
// String returns the name of the object type as a string
func (ot ObjectType) String() string {
names := [...]string{
"string",
"",
"",
"json",
"bytes",
"int... | 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 object
// Obj represents a basic object structure that includes metadata about the object
// as well as its value. This struct ... | nit: Any reason for two `""` strings? | type ObjectType uint8
// Define object types as constants
const (
ObjTypeString ObjectType = iota
_ // skip 1 and 2 to maintain compatibility
_
ObjTypeJSON
ObjTypeByteArray
ObjTypeInt
ObjTypeSet
ObjTypeHashMap
ObjTypeSortedSet
ObjTypeCountMinSketch
ObjTypeBF
ObjTypeDequeue
ObjTypeHL... | @@ -95,3 +95,28 @@ const (
ObjTypeHLL
ObjTypeFloat
)
+
+// String returns the name of the object type as a string
+func (ot ObjectType) String() string {
+ names := [...]string{
+ "string",
+ "",
+ "", | internal/object/object.go | 26 | Go | 0.214 | question | 37 | 98 | 45 | false | Port TYPE command | 1,475 | DiceDB/dice | 10,326 | C | lucifercr07 | pankajjs | Review this pull request change.
Language: Go
File: internal/object/object.go
PR Title: Port TYPE command
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 obje... | nit: Any reason for two `""` strings? | 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 (
"errors"
"testing"
)
func TestDel(t *testing.T) {
client := getLocalConnection()
defer client.Close()
... | these are wrong. the tests should not have been changed, but rather we had to add a multi-shard support for DEL command. I have added this. Pull from the master and you need not make any changes to this test. | // 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 (
"testing"
)
func TestDEL(t *testing.T) {
client := getLocalConnection()
defer client.Close()
testCases ... | @@ -18,10 +18,11 @@ func TestDel(t *testing.T) {
commands: []string{"SET k1 v1", "DEL k1", "GET k1"},
expected: []interface{}{"OK", 1, nil},
},
+ // TODO: 3rd and 4th commands should be together but delete on multi shard isn't supported as of now
{
name: "DEL multiple keys",
- commands: []strin... | tests/commands/ironhawk/del_test.go | 25 | Go | 0.5 | bug | 208 | 42 | 38 | false | Del, Exists, Get command test cases | 1,515 | DiceDB/dice | 10,326 | C | arpitbbhayani | Abhijeetsng97 | Review this pull request change.
Language: Go
File: tests/commands/ironhawk/del_test.go
PR Title: Del, Exists, Get command test cases
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... | these are wrong. the tests should not have been changed, but rather we had to add a multi-shard support for DEL command. I have added this. Pull from the master and you need not make any changes to this test. | 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: expected response should be updated for all exists command once multi shard is implemented
{
name: "Test EXISTS command with multiple keys",
commands: []string{"SET key value", "SET key2 value2", "EXISTS key key2 key3", "EXISTS key key2 key3 key4", "DEL key", "EXISTS key key2 key3 key4"},
expe... | Pull from the master and add this test case to `exists_test.go`. EXISTS does not return an error when no arg is passed. It just returns 0. Check the current behaviour and add an apt test. | name: "Test EXISTS command with multiple keys",
commands: []string{"SET key value", "SET key2 value2", "EXISTS key key2 key3", "EXISTS key key2 key3 key4", "DEL key", "EXISTS key key2 key3 key4"},
expected: []interface{}{"OK", "OK", 2, 2, 1, 1},
},
{
name: "Test EXISTS an expired key",
comman... | @@ -18,23 +19,32 @@ func TestExists(t *testing.T) {
commands: []string{"SET key value", "EXISTS key", "EXISTS key2"},
expected: []interface{}{"OK", 1, 0},
},
+ // TODO: expected response should be updated for all exists command once multi shard is implemented
{
name: "Test EXISTS command with mul... | tests/commands/ironhawk/exists_test.go | 26 | Go | 0.643 | suggestion | 187 | 31 | 26 | false | Del, Exists, Get command test cases | 1,515 | DiceDB/dice | 10,326 | C | arpitbbhayani | Abhijeetsng97 | Review this pull request change.
Language: Go
File: tests/commands/ironhawk/exists_test.go
PR Title: Del, Exists, Get command test cases
BEFORE CODE: // TODO: expected response should be updated for all exists command once multi shard is implemented
{
name: "Test EXISTS command with multiple keys",
co... | Pull from the master and add this test case to `exists_test.go`. EXISTS does not return an error when no arg is passed. It just returns 0. Check the current behaviour and add an apt test. | 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. |
delta, err := strconv.ParseInt(c.C.Args[1], 10, 64)
if err != nil {
return cmdResNil, errIntegerOutOfRange
}
return doIncr(c, s, delta)
}
func doIncr(c *Cmd, s *dstore.Store, delta int64) (*CmdRes, error) {
key := c.C.Args[0]
obj := s.Get(key)
if obj == nil {
obj = s.NewObj(delta, -1, object.ObjTypeInt)
... | Let's pass an explicit "INCRBY" instead of c.C.Cmd. | }
delta, err := strconv.ParseInt(c.C.Args[1], 10, 64)
if err != nil {
return cmdResNil, errIntegerOutOfRange
}
return doIncr(c, s, delta)
}
func doIncr(c *Cmd, s *dstore.Store, delta int64) (*CmdRes, error) {
key := c.C.Args[0]
obj := s.Get(key)
if obj == nil {
obj = s.NewObj(delta, -1, object.ObjTypeInt... | @@ -49,7 +49,7 @@ func doIncr(c *Cmd, s *dstore.Store, delta int64) (*CmdRes, error) {
case object.ObjTypeInt:
break
default:
- return cmdResNil, errWrongTypeOperation("DECRBY")
+ return cmdResNil, errWrongTypeOperation(c.C.Cmd) | internal/cmd/cmd_incrby.go | 26 | Go | 0.286 | suggestion | 51 | 36 | 43 | false | Integration tests fixes - INCRBY & INCR | 1,516 | DiceDB/dice | 10,326 | C | arpitbbhayani | bipoool | Review this pull request change.
Language: Go
File: internal/cmd/cmd_incrby.go
PR Title: Integration tests fixes - INCRBY & INCR
BEFORE CODE: delta, err := strconv.ParseInt(c.C.Args[1], 10, 64)
if err != nil {
return cmdResNil, errIntegerOutOfRange
}
return doIncr(c, s, delta)
}
func doIncr(c *Cmd, s *dstor... | Let's pass an explicit "INCRBY" instead of c.C.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. |
// 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... | In this file, I see a lot of conversions happening `int64(*)`. See if we can get rid of it. Most should work without an explicit typecast. | // 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 ( | tests/commands/ironhawk/incr_test.go | 6 | Go | 0.714 | suggestion | 138 | 31 | 31 | 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... | In this file, I see a lot of conversions happening `int64(*)`. See if we can get rid of it. Most should work without an explicit typecast. | 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 key1 0",
"INCR key1",
"INCR key1",
"INCR key2",
"GET key1",
"GET key2",
},
expected: []interface{}{"OK", 1, 2, 1, 2, 1},
},
{
name: "Increment to and from max int64",
commands: []string{
"SET max_int " + strconv.FormatInt(int64(math.MaxInt64-1), 10),
"INCR max_int",
... | instead of str concat, use `fmt.Sprintf` | "INCR key2",
"GET key1",
"GET key2",
},
expected: []interface{}{"OK", 1, 2, 1, 2, 1},
},
{
name: "Increment max int64 and expect min int64 (rollover)",
commands: []string{
"SET max_int " + fmt.Sprintf("%d", math.MaxInt64-1),
"INCR max_int",
"INCR max_int",
"SET max_int " + fm... | @@ -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 | suggestion | 40 | 51 | 51 | 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 key1 0",
"INCR key1",
"INCR key1",
"INCR key2",
"GET key1",
"GET key2",
},
expected: []interface{}{"OK", 1, 2, 1, 2, 1},
},
{... | instead of str concat, use `fmt.Sprintf` | 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. |
"testing"
"github.com/dicedb/dicedb-go/wire"
)
func TestINCR(t *testing.T) {
client := getLocalConnection()
defer client.Close()
testCases := []TestCase{
{
name: "Increment multiple keys",
commands: []string{
"SET key1 0",
"INCR key1",
"INCR key1",
"INCR key2",
"GET key1",
"GET k... | instead of str concat, use `fmt.Sprintf` | )
func TestINCR(t *testing.T) {
client := getLocalConnection()
defer client.Close()
testCases := []TestCase{
{
name: "Increment multiple keys",
commands: []string{
"SET key1 0",
"INCR key1",
"INCR key1",
"INCR key2",
"GET key1",
"GET key2",
},
expected: []interface{}{"OK", 1, ... | @@ -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 | suggestion | 40 | 51 | 51 | 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: "testing"
"github.com/dicedb/dicedb-go/wire"
)
func TestINCR(t *testing.T) {
client := getLocalConnection()
defer client.Close()
testCases := []TestCase{
... | instead of str concat, use `fmt.Sprintf` | 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 TestINCR(t *testing.T) {
client := getLocalConnection()
defer client.Close()
testCases := []TestCase{
{
name: "Increment multiple keys",
commands: []string{
"SET key1 0",
"INCR key1",
"INCR key1",
"INCR key2",
"GET key1",
"GET key2",
},
expected: []interface{}{"OK", 1, ... | instead of str concat, use `fmt.Sprintf` | client := getLocalConnection()
defer client.Close()
testCases := []TestCase{
{
name: "Increment multiple keys",
commands: []string{
"SET key1 0",
"INCR key1",
"INCR key1",
"INCR key2",
"GET key1",
"GET key2",
},
expected: []interface{}{"OK", 1, 2, 1, 2, 1},
},
{
name: "I... | @@ -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 | suggestion | 40 | 51 | 51 | 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: )
func TestINCR(t *testing.T) {
client := getLocalConnection()
defer client.Close()
testCases := []TestCase{
{
name: "Increment multiple keys",
command... | instead of str concat, use `fmt.Sprintf` | 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.