Skip to content

Commit

Permalink
*: remove unused package and functions (pingcap#5003)
Browse files Browse the repository at this point in the history
* *: remove unused package and functions
  • Loading branch information
coocood authored and zimulala committed Nov 4, 2017
1 parent 0182bfd commit ad1c532
Show file tree
Hide file tree
Showing 19 changed files with 0 additions and 623 deletions.
7 changes: 0 additions & 7 deletions ddl/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,13 +498,6 @@ func (d *ddl) WorkerVars() *variable.SessionVars {
return d.workerVars
}

func filterError(err, exceptErr error) error {
if terror.ErrorEqual(err, exceptErr) {
return nil
}
return errors.Trace(err)
}

// DDL error codes.
const (
codeInvalidWorker terror.ErrCode = 1
Expand Down
5 changes: 0 additions & 5 deletions distsql/distsql.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,6 @@ func Analyze(ctx goctx.Context, client kv.Client, kvReq *kv.Request) (SelectResu
return result, nil
}

type resultWithErr struct {
result []byte
err error
}

// XAPI error codes.
const (
codeInvalidResp = 1
Expand Down
12 changes: 0 additions & 12 deletions executor/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -1171,18 +1171,6 @@ func (e *InsertExec) onDuplicateUpdate(row []types.Datum, h int64, cols []*expre
return nil
}

func findColumnByName(t table.Table, tableName, colName string) (*table.Column, error) {
if len(tableName) > 0 && !strings.EqualFold(tableName, t.Meta().Name.O) {
return nil, errors.Errorf("unknown field %s.%s", tableName, colName)
}

c := table.FindCol(t.Cols(), colName)
if c == nil {
return nil, errors.Errorf("unknown field %s", colName)
}
return c, nil
}

// ReplaceExec represents a replace executor.
type ReplaceExec struct {
*InsertValues
Expand Down
5 changes: 0 additions & 5 deletions expression/expression.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,6 @@ func TableInfo2SchemaWithDBName(dbName model.CIStr, tbl *model.TableInfo) *Schem
return schema
}

// ColumnInfos2Columns converts a slice of ColumnInfo to a slice of Column with empty DBName.
func ColumnInfos2Columns(tblName model.CIStr, colInfos []*model.ColumnInfo) []*Column {
return ColumnInfos2ColumnsWithDBName(model.CIStr{}, tblName, colInfos)
}

// ColumnInfos2ColumnsWithDBName converts a slice of ColumnInfo to a slice of Column.
func ColumnInfos2ColumnsWithDBName(dbName, tblName model.CIStr, colInfos []*model.ColumnInfo) []*Column {
columns := make([]*Column, 0, len(colInfos))
Expand Down
25 changes: 0 additions & 25 deletions expression/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,31 +147,6 @@ func SubstituteCorCol2Constant(expr Expression) (Expression, error) {
return expr.Clone(), nil
}

// ConvertCol2CorCol will convert the column in the condition which can be found in outerSchema to a correlated column whose
// Column is this column. And please make sure the outerSchema.Columns[i].Equal(corCols[i].Column)) holds when you call this.
func ConvertCol2CorCol(cond Expression, corCols []*CorrelatedColumn, outerSchema *Schema) Expression {
switch x := cond.(type) {
case *ScalarFunction:
newArgs := make([]Expression, 0, len(x.GetArgs()))
for _, arg := range x.GetArgs() {
newArg := ConvertCol2CorCol(arg, corCols, outerSchema)
newArgs = append(newArgs, newArg)
}
var newSf Expression
if x.FuncName.L == ast.Cast {
newSf = BuildCastFunction(x.GetCtx(), newArgs[0], x.RetType)
} else {
newSf = NewFunctionInternal(x.GetCtx(), x.FuncName.L, x.GetType(), newArgs...)
}
return newSf
case *Column:
if pos := outerSchema.ColumnIndex(x); pos >= 0 {
return corCols[pos]
}
}
return cond
}

// timeZone2Duration converts timezone whose format should satisfy the regular condition
// `(^(+|-)(0?[0-9]|1[0-2]):[0-5]?\d$)|(^+13:00$)` to time.Duration.
func timeZone2Duration(tz string) time.Duration {
Expand Down
8 changes: 0 additions & 8 deletions kv/mem_buffer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,6 @@ func checkNewIterator(c *C, buffer MemBuffer) {
iter.Close()
}

func mustNotGet(c *C, buffer MemBuffer) {
for i := startIndex; i < testCount; i++ {
s := encodeInt(i * indexStep)
_, err := buffer.Get(s)
c.Assert(err, NotNil)
}
}

func mustGet(c *C, buffer MemBuffer) {
for i := startIndex; i < testCount; i++ {
s := encodeInt(i * indexStep)
Expand Down
4 changes: 0 additions & 4 deletions parser/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ func isIdentFirstChar(ch rune) bool {
return isLetter(ch) || ch == '_'
}

func isASCII(ch rune) bool {
return ch >= 0 && ch <= 0177
}

type trieNode struct {
childs [256]*trieNode
token int
Expand Down
27 changes: 0 additions & 27 deletions plan/logical_plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/pingcap/tidb/mysql"
"github.com/pingcap/tidb/parser"
"github.com/pingcap/tidb/sessionctx"
"github.com/pingcap/tidb/statistics"
"github.com/pingcap/tidb/store/tikv/oracle"
"github.com/pingcap/tidb/terror"
"github.com/pingcap/tidb/util/mock"
Expand Down Expand Up @@ -394,32 +393,6 @@ func mockContext() context.Context {
return ctx
}

func mockStatsTable(tbl *model.TableInfo, rowCount int64) *statistics.Table {
statsTbl := &statistics.Table{
TableID: tbl.ID,
Count: rowCount,
Columns: make(map[int64]*statistics.Column, len(tbl.Columns)),
Indices: make(map[int64]*statistics.Index, len(tbl.Indices)),
}
return statsTbl
}

// mockStatsHistogram will create a statistics.Histogram, of which the data is uniform distribution.
func mockStatsHistogram(id int64, values []types.Datum, repeat int64) *statistics.Histogram {
ndv := len(values)
histogram := &statistics.Histogram{
ID: id,
NDV: int64(ndv),
Buckets: make([]statistics.Bucket, ndv),
}
for i := 0; i < ndv; i++ {
histogram.Buckets[i].Repeats = repeat
histogram.Buckets[i].Count = repeat * int64(i+1)
histogram.Buckets[i].UpperBound = values[i]
}
return histogram
}

func (s *testPlanSuite) TestPredicatePushDown(c *C) {
defer testleak.AfterTest(c)()
tests := []struct {
Expand Down
23 changes: 0 additions & 23 deletions server/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,29 +217,6 @@ func dumpBinaryDateTime(t types.Time, loc *time.Location) (data []byte, err erro
return
}

func uniformValue(value interface{}) interface{} {
switch v := value.(type) {
case int8:
return int64(v)
case int16:
return int64(v)
case int32:
return int64(v)
case int64:
return v
case uint8:
return uint64(v)
case uint16:
return uint64(v)
case uint32:
return uint64(v)
case uint64:
return v
default:
return value
}
}

func dumpRowValuesBinary(buffer []byte, columns []*ColumnInfo, row []types.Datum) ([]byte, error) {
if len(columns) != len(row) {
return nil, mysql.ErrMalformPacket
Expand Down
10 changes: 0 additions & 10 deletions sessionctx/variable/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,13 +489,3 @@ func (sc *StatementContext) ResetForRetry() {
sc.mu.warnings = nil
sc.mu.Unlock()
}

// MostRestrictStateContext gets a most restrict StatementContext.
func MostRestrictStateContext() *StatementContext {
return &StatementContext{
IgnoreTruncate: false,
OverflowAsWarning: false,
TruncateAsWarning: false,
TimeZone: time.UTC,
}
}
14 changes: 0 additions & 14 deletions store/tikv/kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,6 @@ func WithHijackClient(wrap func(Client) Client) MockTiKVStoreOption {
}
}

// WithHijackPDClient hijacks PD client's behavior, makes it easy to simulate the network
// problem between TiDB and PD, such as GetTS too slow, GetStore or GetRegion fail.
func WithHijackPDClient(wrap func(pd.Client) pd.Client) MockTiKVStoreOption {
return func(c *mockOptions) {
c.pdClientHijack = wrap
}
}

// WithCluster provides the customized cluster.
func WithCluster(cluster *mocktikv.Cluster) MockTiKVStoreOption {
return func(c *mockOptions) {
Expand Down Expand Up @@ -445,12 +437,6 @@ func (s *tikvStore) GetTiKVClient() (client Client) {
return s.client
}

// ParseEtcdAddr parses path to etcd address list
func ParseEtcdAddr(path string) (etcdAddrs []string, err error) {
etcdAddrs, _, err = parsePath(path)
return
}

func parsePath(path string) (etcdAddrs []string, disableGC bool, err error) {
var u *url.URL
u, err = url.Parse(path)
Expand Down
11 changes: 0 additions & 11 deletions store/tikv/region_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,17 +483,6 @@ func (c *RegionCache) PDClient() pd.Client {
return c.pdClient
}

// moveLeaderToFirst moves the leader peer to the first and makes it easier to
// try the next peer if the current peer does not respond.
func moveLeaderToFirst(r *metapb.Region, leaderStoreID uint64) {
for i := range r.Peers {
if r.Peers[i].GetStoreId() == leaderStoreID {
r.Peers[0], r.Peers[i] = r.Peers[i], r.Peers[0]
return
}
}
}

// llrbItem is llrbTree's Item that uses []byte to compare.
type llrbItem struct {
key []byte
Expand Down
46 changes: 0 additions & 46 deletions tablecodec/tablecodec.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,46 +336,6 @@ func CutRowNew(data []byte, colIDs map[int64]int) ([][]byte, error) {
return row, nil
}

// CutRow cuts encoded row into byte slices and return interested columns' byte slice.
// Row layout: colID1, value1, colID2, value2, .....
func CutRow(data []byte, cols map[int64]*types.FieldType) (map[int64][]byte, error) {
if data == nil {
return nil, nil
}
if len(data) == 1 && data[0] == codec.NilFlag {
return nil, nil
}
row := make(map[int64][]byte, len(cols))
cnt := 0
var (
b []byte
err error
)
for len(data) > 0 && cnt < len(cols) {
// Get col id.
b, data, err = codec.CutOne(data)
if err != nil {
return nil, errors.Trace(err)
}
_, cid, err := codec.DecodeOne(b)
if err != nil {
return nil, errors.Trace(err)
}
// Get col value.
b, data, err = codec.CutOne(data)
if err != nil {
return nil, errors.Trace(err)
}
id := cid.GetInt64()
_, ok := cols[id]
if ok {
row[id] = b
cnt++
}
}
return row, nil
}

// unflatten converts a raw datum to a column datum.
func unflatten(datum types.Datum, ft *types.FieldType, loc *time.Location) (types.Datum, error) {
if datum.IsNull() {
Expand Down Expand Up @@ -443,12 +403,6 @@ func EncodeIndexSeekKey(tableID int64, idxID int64, encodedValue []byte) kv.Key
return key
}

// DecodeIndexKey decodes datums from an index key.
func DecodeIndexKey(key kv.Key) ([]types.Datum, error) {
b := key[prefixLen+idLen:]
return codec.Decode(b, 1)
}

// CutIndexKey cuts encoded index key into colIDs to bytes slices map.
// The returned value b is the remaining bytes of the key which would be empty if it is unique index or handle data
// if it is non-unique index.
Expand Down
90 changes: 0 additions & 90 deletions util/bytespool/bytespool.go

This file was deleted.

Loading

0 comments on commit ad1c532

Please sign in to comment.