Skip to content

Commit

Permalink
*: tiny update
Browse files Browse the repository at this point in the history
  • Loading branch information
zimulala committed Sep 11, 2024
1 parent fb7f123 commit ca22b96
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 37 deletions.
4 changes: 0 additions & 4 deletions pkg/ddl/cancel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,6 @@ func TestCancelVariousJobs(t *testing.T) {
partition p3 values less than (4096),
partition p4 values less than (7096)
);`)
testfailpoint.Enable(t, "github.com/pingcap/tidb/infoschema/mockTiFlashStoreCount", `return(true)`)
defer func() {
testfailpoint.Disable(t, "github.com/pingcap/tidb/infoschema/mockTiFlashStoreCount")
}()
tk.MustExec(`create table t (
c1 int, c2 int, c3 int, c11 tinyint, v2 vector(3), index fk_c1(c1)
);`)
Expand Down
2 changes: 1 addition & 1 deletion pkg/ddl/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -4636,7 +4636,7 @@ func (e *executor) createVectorIndex(ctx sessionctx.Context, ti ast.Ident, index
if err != nil {
return errors.Trace(err)
}
_, funcExpr, err := buildVectorInfoWithCheck(indexPartSpecifications, indexOption, tblInfo)
_, funcExpr, err := buildVectorInfoWithCheck(indexPartSpecifications, tblInfo)
if err != nil {
return errors.Trace(err)
}
Expand Down
6 changes: 2 additions & 4 deletions pkg/ddl/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ func BuildIndexInfo(
}

if isVector {
vectorInfo, _, err := buildVectorInfoWithCheck(indexPartSpecifications, indexOption, tblInfo)
vectorInfo, _, err := buildVectorInfoWithCheck(indexPartSpecifications, tblInfo)
if err != nil {
return nil, errors.Trace(err)
}
Expand Down Expand Up @@ -388,7 +388,7 @@ func BuildIndexInfo(
return idxInfo, nil
}

func buildVectorInfoWithCheck(indexPartSpecifications []*ast.IndexPartSpecification, indexOption *ast.IndexOption,
func buildVectorInfoWithCheck(indexPartSpecifications []*ast.IndexPartSpecification,
tblInfo *model.TableInfo) (*model.VectorIndexInfo, string, error) {
if len(indexPartSpecifications) != 1 {
return nil, "", dbterror.ErrUnsupportedAddVectorIndex.FastGenByArgs("unsupported no function")
Expand Down Expand Up @@ -438,7 +438,6 @@ func buildVectorInfoWithCheck(indexPartSpecifications []*ast.IndexPartSpecificat
idxPart.Length = types.UnspecifiedLength

return &model.VectorIndexInfo{
Kind: model.VectorIndexKind(indexOption.Tp.String()),
Dimension: uint64(colInfo.FieldType.GetFlen()),
DistanceMetric: distanceMetric,
}, exprStr, nil
Expand Down Expand Up @@ -897,7 +896,6 @@ func (w *worker) checkVectorIndexProcessOnce(jobCtx *jobContext, tbl table.Table
}
})

// TODO: Wait support tiflash_indexes, otherwise it will return an error.
// TODO: We need to add error_msg and error_count for to show error information.
sql := fmt.Sprintf("select rows_stable_not_indexed, rows_stable_indexed from information_schema.tiflash_indexes where table_id = %d and index_id = %d;",
tbl.Meta().ID, indexID)
Expand Down
8 changes: 0 additions & 8 deletions pkg/ddl/index_modify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1122,10 +1122,6 @@ func TestAddVectorIndex(t *testing.T) {
tk.MustExec("use test")
tk.MustExec("drop table if exists t, pt;")

testfailpoint.Enable(t, "github.com/pingcap/tidb/infoschema/mockTiFlashStoreCount", `return(true)`)
defer func() {
testfailpoint.Disable(t, "github.com/pingcap/tidb/infoschema/mockTiFlashStoreCount")
}()
tiflash := infosync.NewMockTiFlash()
infosync.SetMockTiFlash(tiflash)
defer func() {
Expand Down Expand Up @@ -1249,10 +1245,6 @@ func TestAddVectorIndexRollback(t *testing.T) {
}()

// mock TiFlash replicas
testfailpoint.Enable(t, "github.com/pingcap/tidb/infoschema/mockTiFlashStoreCount", `return(true)`)
defer func() {
testfailpoint.Disable(t, "github.com/pingcap/tidb/infoschema/mockTiFlashStoreCount")
}()
tk.MustExec("create table t1 (c1 int, b vector, c vector(3), unique key(c1));")
tk.MustExec("alter table t1 set tiflash replica 2 location labels 'a','b';")

Expand Down
5 changes: 3 additions & 2 deletions pkg/infoschema/tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -1514,11 +1514,12 @@ var tableTableTiFlashSegmentsCols = []columnInfo{
}

var tableTiFlashIndexesCols = []columnInfo{
{name: "TIDB_DATABASE", tp: mysql.TypeVarchar, size: 21},
{name: "TIDB_TABLE", tp: mysql.TypeVarchar, size: 21},
{name: "TIDB_DATABASE", tp: mysql.TypeVarchar, size: 64},
{name: "TIDB_TABLE", tp: mysql.TypeVarchar, size: 64},
{name: "TABLE_ID", tp: mysql.TypeLonglong, size: 21},
{name: "COLUMN_NAME", tp: mysql.TypeVarchar, size: 64},
{name: "COLUMN_ID", tp: mysql.TypeLonglong, size: 64},
{name: "INDEX_ID", tp: mysql.TypeLonglong, size: 21},
{name: "INDEX_KIND", tp: mysql.TypeVarchar, size: 64},
{name: "ROWS_STABLE_INDEXED", tp: mysql.TypeLonglong, size: 64},
{name: "ROWS_STABLE_NOT_INDEXED", tp: mysql.TypeLonglong, size: 64},
Expand Down
13 changes: 0 additions & 13 deletions pkg/meta/model/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@ import (
"github.com/pingcap/tidb/pkg/parser/types"
)

// VectorIndexKind is the kind of vector index.
type VectorIndexKind string

// Note: tipb.VectorIndexKind's enum names must be aligned with these constant values.
const (
// VectorIndexKindHNSW is HNSW index.
VectorIndexKindHNSW VectorIndexKind = "HNSW"
)

// DistanceMetric is the distance metric used by the vector index.
// `DistanceMetric` is actually vector functions in ast package. Use `DistanceMetric` to avoid cycle dependency
type DistanceMetric string
Expand All @@ -43,10 +34,6 @@ const (

// VectorIndexInfo is the information of vector index of a column.
type VectorIndexInfo struct {
// Kind is the kind of vector index. Currently only HNSW is supported.
// TODO: Consider deprecate this field, because of we have IndexInfo's Tp.
Kind VectorIndexKind `json:"kind"`

// Dimension is the dimension of the vector.
Dimension uint64 `json:"dimension"` // Set to 0 when initially parsed from comment. Will be assigned to flen later.
// DistanceMetric is the distance metric used by the index.
Expand Down
2 changes: 1 addition & 1 deletion pkg/meta/model/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ func (job *Job) DecodeArgs(args ...any) error {

// DecodeDropIndexFinishedArgs decodes the drop index job's args when it's finished.
func (job *Job) DecodeDropIndexFinishedArgs() (
indexName interface{}, ifExists []bool, indexIDs []int64, partitionIDs []int64, hasVectors []bool, err error) {
indexName any, ifExists []bool, indexIDs []int64, partitionIDs []int64, hasVectors []bool, err error) {
ifExists = make([]bool, 1)
indexIDs = make([]int64, 1)
hasVectors = make([]bool, 1)
Expand Down
4 changes: 0 additions & 4 deletions pkg/planner/core/indexmerge_path_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,10 +446,6 @@ func TestAnalyzeVectorIndex(t *testing.T) {
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t;")
testfailpoint.Enable(t, "github.com/pingcap/tidb/infoschema/mockTiFlashStoreCount", `return(true)`)
defer func() {
testfailpoint.Disable(t, "github.com/pingcap/tidb/infoschema/mockTiFlashStoreCount")
}()

tiflash := infosync.NewMockTiFlash()
infosync.SetMockTiFlash(tiflash)
Expand Down

0 comments on commit ca22b96

Please sign in to comment.