Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into bump-go
Browse files Browse the repository at this point in the history
* origin/main:
  linter shenanigans
  bump linter to 1.62.2
  bump linter to 1.62.2
  • Loading branch information
kolbe committed Dec 3, 2024
2 parents 8a14699 + cfc195d commit 3a24639
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ linters:
- wsl
- funlen
- gocognit
- gomnd
- goprintffuncname
- paralleltest
- nlreturn
Expand All @@ -51,6 +50,7 @@ linters:
- thelper
- godox
- goconst
- exportloopref

linters-settings:
govet:
Expand Down
8 changes: 4 additions & 4 deletions pkg/migration/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ func TestCheckpoint(t *testing.T) {
// gives feedback back to table.
watermark, err := r.copier.GetLowWatermark()
assert.NoError(t, err)
assert.Equal(t, "{\"Key\":[\"id\"],\"ChunkSize\":1000,\"LowerBound\":{\"Value\": [\"1001\"],\"Inclusive\":true},\"UpperBound\":{\"Value\": [\"2001\"],\"Inclusive\":false}}", watermark)
assert.JSONEq(t, "{\"Key\":[\"id\"],\"ChunkSize\":1000,\"LowerBound\":{\"Value\": [\"1001\"],\"Inclusive\":true},\"UpperBound\":{\"Value\": [\"2001\"],\"Inclusive\":false}}", watermark)
// Dump a checkpoint
assert.NoError(t, r.dumpCheckpoint(context.TODO()))

Expand Down Expand Up @@ -856,7 +856,7 @@ func TestCheckpoint(t *testing.T) {
// the last checkpoint because on restore, the LowerBound is taken.
watermark, err = r.copier.GetLowWatermark()
assert.NoError(t, err)
assert.Equal(t, "{\"Key\":[\"id\"],\"ChunkSize\":1000,\"LowerBound\":{\"Value\": [\"1001\"],\"Inclusive\":true},\"UpperBound\":{\"Value\": [\"2001\"],\"Inclusive\":false}}", watermark)
assert.JSONEq(t, "{\"Key\":[\"id\"],\"ChunkSize\":1000,\"LowerBound\":{\"Value\": [\"1001\"],\"Inclusive\":true},\"UpperBound\":{\"Value\": [\"2001\"],\"Inclusive\":false}}", watermark)
// Dump a checkpoint
assert.NoError(t, r.dumpCheckpoint(context.TODO()))

Expand All @@ -869,7 +869,7 @@ func TestCheckpoint(t *testing.T) {

watermark, err = r.copier.GetLowWatermark()
assert.NoError(t, err)
assert.Equal(t, "{\"Key\":[\"id\"],\"ChunkSize\":1000,\"LowerBound\":{\"Value\": [\"11001\"],\"Inclusive\":true},\"UpperBound\":{\"Value\": [\"12001\"],\"Inclusive\":false}}", watermark)
assert.JSONEq(t, "{\"Key\":[\"id\"],\"ChunkSize\":1000,\"LowerBound\":{\"Value\": [\"11001\"],\"Inclusive\":true},\"UpperBound\":{\"Value\": [\"12001\"],\"Inclusive\":false}}", watermark)
assert.NoError(t, r.db.Close())
}

Expand Down Expand Up @@ -1128,7 +1128,7 @@ func TestCheckpointDifferentRestoreOptions(t *testing.T) {

watermark, err := m.copier.GetLowWatermark()
assert.NoError(t, err)
assert.Equal(t, "{\"Key\":[\"id\"],\"ChunkSize\":1000,\"LowerBound\":{\"Value\": [\"1001\"],\"Inclusive\":true},\"UpperBound\":{\"Value\": [\"2001\"],\"Inclusive\":false}}", watermark)
assert.JSONEq(t, "{\"Key\":[\"id\"],\"ChunkSize\":1000,\"LowerBound\":{\"Value\": [\"1001\"],\"Inclusive\":true},\"UpperBound\":{\"Value\": [\"2001\"],\"Inclusive\":false}}", watermark)
// Dump a checkpoint
assert.NoError(t, m.dumpCheckpoint(context.TODO()))

Expand Down
4 changes: 2 additions & 2 deletions pkg/table/chunker_composite.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (t *chunkerComposite) nextQueryToDatums(query string) ([]Datum, error) {
}
columns := make([]sql.RawBytes, len(columnNames))
columnPointers := make([]interface{}, len(columnNames))
for i := range len(columnNames) {
for i := range columnNames {
columnPointers[i] = &columns[i]
}
rowsFound := false
Expand Down Expand Up @@ -330,7 +330,7 @@ applyStoredChunks:
}

func (t *chunkerComposite) waterMarkMapNotEmpty() bool {
return t.lowerBoundWatermarkMap != nil && len(t.lowerBoundWatermarkMap) != 0
return len(t.lowerBoundWatermarkMap) != 0
}

func (t *chunkerComposite) open() (err error) {
Expand Down
14 changes: 7 additions & 7 deletions pkg/table/chunker_composite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,15 +305,15 @@ func TestCompositeLowWatermark(t *testing.T) {

watermark, err := chunker.GetLowWatermark()
assert.NoError(t, err)
assert.Equal(t, "{\"Key\":[\"pk\"],\"ChunkSize\":1000,\"LowerBound\":{\"Value\": [\"1008\"],\"Inclusive\":true},\"UpperBound\":{\"Value\": [\"2032\"],\"Inclusive\":false}}", watermark)
assert.JSONEq(t, "{\"Key\":[\"pk\"],\"ChunkSize\":1000,\"LowerBound\":{\"Value\": [\"1008\"],\"Inclusive\":true},\"UpperBound\":{\"Value\": [\"2032\"],\"Inclusive\":false}}", watermark)

chunk, err = chunker.Next()
assert.NoError(t, err)
assert.Equal(t, "`pk` >= 2032 AND `pk` < 2133", chunk.String())
chunker.Feedback(chunk, time.Second)
watermark, err = chunker.GetLowWatermark()
assert.NoError(t, err)
assert.Equal(t, "{\"Key\":[\"pk\"],\"ChunkSize\":100,\"LowerBound\":{\"Value\": [\"2032\"],\"Inclusive\":true},\"UpperBound\":{\"Value\": [\"2133\"],\"Inclusive\":false}}", watermark)
assert.JSONEq(t, "{\"Key\":[\"pk\"],\"ChunkSize\":100,\"LowerBound\":{\"Value\": [\"2032\"],\"Inclusive\":true},\"UpperBound\":{\"Value\": [\"2133\"],\"Inclusive\":false}}", watermark)

chunkAsync1, err := chunker.Next()
assert.NoError(t, err)
Expand All @@ -330,28 +330,28 @@ func TestCompositeLowWatermark(t *testing.T) {
chunker.Feedback(chunkAsync2, time.Second)
watermark, err = chunker.GetLowWatermark()
assert.NoError(t, err)
assert.Equal(t, "{\"Key\":[\"pk\"],\"ChunkSize\":100,\"LowerBound\":{\"Value\": [\"2032\"],\"Inclusive\":true},\"UpperBound\":{\"Value\": [\"2133\"],\"Inclusive\":false}}", watermark)
assert.JSONEq(t, "{\"Key\":[\"pk\"],\"ChunkSize\":100,\"LowerBound\":{\"Value\": [\"2032\"],\"Inclusive\":true},\"UpperBound\":{\"Value\": [\"2133\"],\"Inclusive\":false}}", watermark)

chunker.Feedback(chunkAsync3, time.Second)
watermark, err = chunker.GetLowWatermark()
assert.NoError(t, err)
assert.Equal(t, "{\"Key\":[\"pk\"],\"ChunkSize\":100,\"LowerBound\":{\"Value\": [\"2032\"],\"Inclusive\":true},\"UpperBound\":{\"Value\": [\"2133\"],\"Inclusive\":false}}", watermark)
assert.JSONEq(t, "{\"Key\":[\"pk\"],\"ChunkSize\":100,\"LowerBound\":{\"Value\": [\"2032\"],\"Inclusive\":true},\"UpperBound\":{\"Value\": [\"2133\"],\"Inclusive\":false}}", watermark)

chunker.Feedback(chunkAsync1, time.Second)
watermark, err = chunker.GetLowWatermark()
assert.NoError(t, err)
assert.Equal(t, "{\"Key\":[\"pk\"],\"ChunkSize\":10,\"LowerBound\":{\"Value\": [\"2155\"],\"Inclusive\":true},\"UpperBound\":{\"Value\": [\"2166\"],\"Inclusive\":false}}", watermark)
assert.JSONEq(t, "{\"Key\":[\"pk\"],\"ChunkSize\":10,\"LowerBound\":{\"Value\": [\"2155\"],\"Inclusive\":true},\"UpperBound\":{\"Value\": [\"2166\"],\"Inclusive\":false}}", watermark)

chunk, err = chunker.Next()
assert.NoError(t, err)
assert.Equal(t, "`pk` >= 2166 AND `pk` < 2177", chunk.String())
watermark, err = chunker.GetLowWatermark()
assert.NoError(t, err)
assert.Equal(t, "{\"Key\":[\"pk\"],\"ChunkSize\":10,\"LowerBound\":{\"Value\": [\"2155\"],\"Inclusive\":true},\"UpperBound\":{\"Value\": [\"2166\"],\"Inclusive\":false}}", watermark)
assert.JSONEq(t, "{\"Key\":[\"pk\"],\"ChunkSize\":10,\"LowerBound\":{\"Value\": [\"2155\"],\"Inclusive\":true},\"UpperBound\":{\"Value\": [\"2166\"],\"Inclusive\":false}}", watermark)
chunker.Feedback(chunk, time.Second)
watermark, err = chunker.GetLowWatermark()
assert.NoError(t, err)
assert.Equal(t, "{\"Key\":[\"pk\"],\"ChunkSize\":10,\"LowerBound\":{\"Value\": [\"2166\"],\"Inclusive\":true},\"UpperBound\":{\"Value\": [\"2177\"],\"Inclusive\":false}}", watermark)
assert.JSONEq(t, "{\"Key\":[\"pk\"],\"ChunkSize\":10,\"LowerBound\":{\"Value\": [\"2166\"],\"Inclusive\":true},\"UpperBound\":{\"Value\": [\"2177\"],\"Inclusive\":false}}", watermark)

// Give enough feedback that the chunk size recalculation runs.
assert.Equal(t, 10, int(chunker.chunkSize))
Expand Down
2 changes: 1 addition & 1 deletion pkg/table/chunker_optimistic.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ applyStoredChunks:
}

func (t *chunkerOptimistic) waterMarkMapNotEmpty() bool {
return t.lowerBoundWatermarkMap != nil && len(t.lowerBoundWatermarkMap) != 0
return len(t.lowerBoundWatermarkMap) != 0
}

func (t *chunkerOptimistic) open() (err error) {
Expand Down
16 changes: 8 additions & 8 deletions pkg/table/chunker_optimistic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ func TestLowWatermark(t *testing.T) {
chunker.Feedback(chunk, time.Second)
watermark, err := chunker.GetLowWatermark()
assert.NoError(t, err)
assert.Equal(t, "{\"Key\":[\"id\"],\"ChunkSize\":1000,\"LowerBound\":{\"Value\": [\"1\"],\"Inclusive\":true},\"UpperBound\":{\"Value\": [\"1001\"],\"Inclusive\":false}}", watermark)
assert.JSONEq(t, "{\"Key\":[\"id\"],\"ChunkSize\":1000,\"LowerBound\":{\"Value\": [\"1\"],\"Inclusive\":true},\"UpperBound\":{\"Value\": [\"1001\"],\"Inclusive\":false}}", watermark)

chunk, err = chunker.Next()
assert.NoError(t, err)
assert.Equal(t, "`id` >= 1001 AND `id` < 2001", chunk.String()) // first chunk
chunker.Feedback(chunk, time.Second)
watermark, err = chunker.GetLowWatermark()
assert.NoError(t, err)
assert.Equal(t, "{\"Key\":[\"id\"],\"ChunkSize\":1000,\"LowerBound\":{\"Value\": [\"1001\"],\"Inclusive\":true},\"UpperBound\":{\"Value\": [\"2001\"],\"Inclusive\":false}}", watermark)
assert.JSONEq(t, "{\"Key\":[\"id\"],\"ChunkSize\":1000,\"LowerBound\":{\"Value\": [\"1001\"],\"Inclusive\":true},\"UpperBound\":{\"Value\": [\"2001\"],\"Inclusive\":false}}", watermark)

chunkAsync1, err := chunker.Next()
assert.NoError(t, err)
Expand All @@ -139,29 +139,29 @@ func TestLowWatermark(t *testing.T) {
chunker.Feedback(chunkAsync2, time.Second)
watermark, err = chunker.GetLowWatermark()
assert.NoError(t, err)
assert.Equal(t, "{\"Key\":[\"id\"],\"ChunkSize\":1000,\"LowerBound\":{\"Value\": [\"1001\"],\"Inclusive\":true},\"UpperBound\":{\"Value\": [\"2001\"],\"Inclusive\":false}}", watermark)
assert.JSONEq(t, "{\"Key\":[\"id\"],\"ChunkSize\":1000,\"LowerBound\":{\"Value\": [\"1001\"],\"Inclusive\":true},\"UpperBound\":{\"Value\": [\"2001\"],\"Inclusive\":false}}", watermark)

chunker.Feedback(chunkAsync3, time.Second)
watermark, err = chunker.GetLowWatermark()
assert.NoError(t, err)
assert.Equal(t, "{\"Key\":[\"id\"],\"ChunkSize\":1000,\"LowerBound\":{\"Value\": [\"1001\"],\"Inclusive\":true},\"UpperBound\":{\"Value\": [\"2001\"],\"Inclusive\":false}}", watermark)
assert.JSONEq(t, "{\"Key\":[\"id\"],\"ChunkSize\":1000,\"LowerBound\":{\"Value\": [\"1001\"],\"Inclusive\":true},\"UpperBound\":{\"Value\": [\"2001\"],\"Inclusive\":false}}", watermark)

chunker.Feedback(chunkAsync1, time.Second)
watermark, err = chunker.GetLowWatermark()
assert.NoError(t, err)
assert.Equal(t, "{\"Key\":[\"id\"],\"ChunkSize\":1000,\"LowerBound\":{\"Value\": [\"4001\"],\"Inclusive\":true},\"UpperBound\":{\"Value\": [\"5001\"],\"Inclusive\":false}}", watermark)
assert.JSONEq(t, "{\"Key\":[\"id\"],\"ChunkSize\":1000,\"LowerBound\":{\"Value\": [\"4001\"],\"Inclusive\":true},\"UpperBound\":{\"Value\": [\"5001\"],\"Inclusive\":false}}", watermark)

chunk, err = chunker.Next()
assert.NoError(t, err)
assert.Equal(t, "`id` >= 5001 AND `id` < 6001", chunk.String()) // should bump immediately
watermark, err = chunker.GetLowWatermark()
assert.NoError(t, err)
assert.Equal(t, "{\"Key\":[\"id\"],\"ChunkSize\":1000,\"LowerBound\":{\"Value\": [\"4001\"],\"Inclusive\":true},\"UpperBound\":{\"Value\": [\"5001\"],\"Inclusive\":false}}", watermark)
assert.JSONEq(t, "{\"Key\":[\"id\"],\"ChunkSize\":1000,\"LowerBound\":{\"Value\": [\"4001\"],\"Inclusive\":true},\"UpperBound\":{\"Value\": [\"5001\"],\"Inclusive\":false}}", watermark)

chunker.Feedback(chunk, time.Second)
watermark, err = chunker.GetLowWatermark()
assert.NoError(t, err)
assert.Equal(t, "{\"Key\":[\"id\"],\"ChunkSize\":1000,\"LowerBound\":{\"Value\": [\"5001\"],\"Inclusive\":true},\"UpperBound\":{\"Value\": [\"6001\"],\"Inclusive\":false}}", watermark)
assert.JSONEq(t, "{\"Key\":[\"id\"],\"ChunkSize\":1000,\"LowerBound\":{\"Value\": [\"5001\"],\"Inclusive\":true},\"UpperBound\":{\"Value\": [\"6001\"],\"Inclusive\":false}}", watermark)

// Test that we have applied all stored chunks and the map is empty,
// as we gave Feedback for all chunks.
Expand Down Expand Up @@ -233,7 +233,7 @@ func TestOptimisticDynamicChunking(t *testing.T) {
watermark, err := chunker.GetLowWatermark()
assert.NoError(t, err)

assert.Equal(t, "{\"Key\":[\"id\"],\"ChunkSize\":22,\"LowerBound\":{\"Value\": [\"584\"],\"Inclusive\":true},\"UpperBound\":{\"Value\": [\"606\"],\"Inclusive\":false}}", watermark)
assert.JSONEq(t, "{\"Key\":[\"id\"],\"ChunkSize\":22,\"LowerBound\":{\"Value\": [\"584\"],\"Inclusive\":true},\"UpperBound\":{\"Value\": [\"606\"],\"Inclusive\":false}}", watermark)

// Start everything over again as t2.
t2 := newTableInfo4Test("test", "t1")
Expand Down
8 changes: 4 additions & 4 deletions pkg/table/tableinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,17 +257,17 @@ func (t *TableInfo) setMinMax(ctx context.Context) error {
return nil // we don't min/max binary types for now.
}
query := fmt.Sprintf("SELECT IFNULL(min(%s),'0'), IFNULL(max(%s),'0') FROM %s", t.KeyColumns[0], t.KeyColumns[0], t.QuotedName)
var min, max string
err := t.db.QueryRowContext(ctx, query).Scan(&min, &max)
var minimum, maximum string
err := t.db.QueryRowContext(ctx, query).Scan(&minimum, &maximum)
if err != nil {
return err
}

t.minValue, err = newDatumFromMySQL(min, t.keyColumnsMySQLTp[0])
t.minValue, err = newDatumFromMySQL(minimum, t.keyColumnsMySQLTp[0])
if err != nil {
return err
}
t.maxValue, err = newDatumFromMySQL(max, t.keyColumnsMySQLTp[0])
t.maxValue, err = newDatumFromMySQL(maximum, t.keyColumnsMySQLTp[0])
if err != nil {
return err
}
Expand Down

0 comments on commit 3a24639

Please sign in to comment.