Skip to content

Commit

Permalink
Remove bits of unused code across various packages (#17785)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbussink authored Feb 16, 2025
1 parent f131dd6 commit 67d081a
Show file tree
Hide file tree
Showing 13 changed files with 4 additions and 106 deletions.
5 changes: 0 additions & 5 deletions go/bytes2/buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ type Buffer struct {
bytes []byte
}

// NewBuffer is equivalent to bytes.NewBuffer.
func NewBuffer(b []byte) *Buffer {
return &Buffer{bytes: b}
}

// Write is equivalent to bytes.Buffer.Write.
func (buf *Buffer) Write(b []byte) (int, error) {
buf.bytes = append(buf.bytes, b...)
Expand Down
2 changes: 1 addition & 1 deletion go/bytes2/buffer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
)

func TestBuffer(t *testing.T) {
b := NewBuffer(nil)
var b Buffer

// Test Write function
b.Write([]byte("ab"))
Expand Down
10 changes: 0 additions & 10 deletions go/cache/theine/bf/bf.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,6 @@ func New(falsePositiveRate float64) *Bloomfilter {
return d
}

// create new bloomfilter with given size in bytes
func NewWithSize(size uint32) *Bloomfilter {
d := &Bloomfilter{}
bits := size * 8
m := nextPowerOfTwo(uint32(bits))
d.M = m
d.Filter = newbv(m)
return d
}

func (d *Bloomfilter) EnsureCapacity(capacity int) {
if capacity <= d.Capacity {
return
Expand Down
5 changes: 1 addition & 4 deletions go/cache/theine/bf/bf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@ import (
)

func TestBloom(t *testing.T) {
bf := NewWithSize(5)
bf.FalsePositiveRate = 0.1
bf.EnsureCapacity(5)
bf := New(0.1)
bf.EnsureCapacity(500)
bf.EnsureCapacity(200)

exist := bf.Insert(123)
require.False(t, exist)
Expand Down
8 changes: 0 additions & 8 deletions go/cmd/vtctldclient/command/framework_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,6 @@ func TabletKeyspaceShard(t *testing.T, keyspace, shard string) TabletOption {
}
}

// ForceInitTablet is the tablet option to set the 'force' flag during InitTablet
func ForceInitTablet() TabletOption {
return func(tablet *topodatapb.Tablet) {
// set the force_init field into the portmap as a hack
tablet.PortMap["force_init"] = 1
}
}

// StartHTTPServer is the tablet option to start the HTTP server when
// starting a tablet.
func StartHTTPServer() TabletOption {
Expand Down
15 changes: 2 additions & 13 deletions go/sqltypes/value_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"math"
"strings"
"testing"
"time"

"github.com/stretchr/testify/assert"

Expand Down Expand Up @@ -612,16 +611,6 @@ func TestToUint32(t *testing.T) {
}
}

var randomLocation = time.FixedZone("Nowhere", 3*60*60)

func DatetimeValue(str string) Value {
return TestValue(Datetime, str)
}

func DateValue(str string) Value {
return TestValue(Date, str)
}

func TestEncodeSQLStringBuilder(t *testing.T) {
testcases := []struct {
in Value
Expand Down Expand Up @@ -680,9 +669,9 @@ func TestEncodeSQLBytes2(t *testing.T) {
outSQL: "\x89\x02\x011\x950\x03foo",
}}
for _, tcase := range testcases {
buf := bytes2.NewBuffer([]byte{})
var buf bytes2.Buffer

tcase.in.EncodeSQLBytes2(buf)
tcase.in.EncodeSQLBytes2(&buf)
assert.Equal(t, tcase.outSQL, buf.String())
}
}
Expand Down
14 changes: 0 additions & 14 deletions go/test/vschemawrapper/vschema_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,20 +288,6 @@ func (vw *VSchemaWrapper) FindTableOrVindex(tab sqlparser.TableName) (*vindexes.
return vw.Vcursor.FindTableOrVindex(tab)
}

func (vw *VSchemaWrapper) getActualKeyspace() string {
if vw.Keyspace == nil {
return ""
}
if !sqlparser.SystemSchema(vw.Keyspace.Name) {
return vw.Keyspace.Name
}
ks, err := vw.AnyKeyspace()
if err != nil {
return ""
}
return ks.Name
}

func (vw *VSchemaWrapper) SelectedKeyspace() (*vindexes.Keyspace, error) {
return vw.AnyKeyspace()
}
Expand Down
10 changes: 0 additions & 10 deletions go/vt/schemadiff/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -1099,16 +1099,6 @@ func (c *CreateTableEntity) TableDiff(other *CreateTableEntity, hints *DiffHints
return parentAlterTableEntityDiff, nil
}

func (c *CreateTableEntity) diffTableCharset(
t1cc *charsetCollate,
t2cc *charsetCollate,
) string {
if t1cc.charset != t2cc.charset {
return t2cc.charset
}
return ""
}

// isDefaultTableOptionValue sees if the value for a TableOption is also its default value
func isDefaultTableOptionValue(option *sqlparser.TableOption) bool {
var value string
Expand Down
9 changes: 0 additions & 9 deletions go/vt/sqlparser/rewriter_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,6 @@ func (c *Cursor) Replace(newNode SQLNode) {
c.node = newNode
}

// ReplacerF returns a replace func that will work even when the cursor has moved to a different node.
func (c *Cursor) ReplacerF() func(newNode SQLNode) {
replacer := c.replacer
parent := c.parent
return func(newNode SQLNode) {
replacer(newNode, parent)
}
}

// ReplaceAndRevisit replaces the current node in the parent field with this new object.
// When used, this will abort the visitation of the current node - no post or children visited,
// and the new node visited.
Expand Down
6 changes: 0 additions & 6 deletions go/vt/sqlparser/tracked_buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,12 +430,6 @@ func CanonicalString(node SQLNode) string {
return buf.String()
}

func FormatSlice[T SQLNode](buf *TrackedBuffer, valueExprs []T) {
for _, expr := range valueExprs {
buf.Myprintf("%v", expr)
}
}

func SliceString[T SQLNode](valueExprs []T) string {
return SliceStringWithSep(valueExprs, ", ")
}
Expand Down
5 changes: 0 additions & 5 deletions go/vt/vttablet/onlineddl/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"errors"
"fmt"
"os"
"path"
"strconv"
"strings"
"sync"
Expand Down Expand Up @@ -425,10 +424,6 @@ func (e *Executor) isAnyConflictingMigrationRunning(onlineDDL *schema.OnlineDDL)
return (conflictingMigration != nil), conflictingMigration
}

func (e *Executor) ptPidFileName(uuid string) string {
return path.Join(os.TempDir(), fmt.Sprintf("pt-online-schema-change.%s.pid", uuid))
}

// tableExists checks if a given table exists.
func (e *Executor) tableExists(ctx context.Context, tableName string) (bool, error) {
tableName = strings.ReplaceAll(tableName, `_`, `\_`)
Expand Down
13 changes: 0 additions & 13 deletions go/vt/vttablet/onlineddl/vrepl.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,19 +226,6 @@ func (v *VRepl) readTableStatus(ctx context.Context, conn *dbconnpool.DBConnecti
return tableRows, err
}

// formalizeColumns
func formalizeColumns(columnsLists ...*schemadiff.ColumnDefinitionEntityList) error {
for _, colList := range columnsLists {
for _, col := range colList.Entities {
col.SetExplicitDefaultAndNull()
if err := col.SetExplicitCharsetCollate(); err != nil {
return err
}
}
}
return nil
}

func (v *VRepl) analyzeAlter() error {
if v.alterTableAnalysis.IsRenameTable {
return fmt.Errorf("renaming the table is not supported in ALTER TABLE")
Expand Down
8 changes: 0 additions & 8 deletions go/vt/wrangler/testlib/fake_tablet.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,6 @@ func TabletKeyspaceShard(t *testing.T, keyspace, shard string) TabletOption {
}
}

// ForceInitTablet is the tablet option to set the 'force' flag during InitTablet
func ForceInitTablet() TabletOption {
return func(tablet *topodatapb.Tablet) {
// set the force_init field into the portmap as a hack
tablet.PortMap["force_init"] = 1
}
}

// StartHTTPServer is the tablet option to start the HTTP server when
// starting a tablet.
func StartHTTPServer() TabletOption {
Expand Down

0 comments on commit 67d081a

Please sign in to comment.