Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change internal vindex type recommendation for integrals to xxhash #13956

Merged
merged 2 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions go/vt/vtgate/vindexes/vschema.go
Original file line number Diff line number Diff line change
Expand Up @@ -1226,11 +1226,12 @@ func LoadFormalKeyspace(filename string) (*vschemapb.Keyspace, error) {
return formal, nil
}

// ChooseVindexForType chooses the most appropriate vindex for the give type.
// ChooseVindexForType chooses the most appropriate vindex type for
// the given SQL data type.
func ChooseVindexForType(typ querypb.Type) (string, error) {
switch {
case sqltypes.IsIntegral(typ):
return "hash", nil
return "xxhash", nil
case sqltypes.IsText(typ):
return "unicode_loose_md5", nil
case sqltypes.IsBinary(typ):
Expand Down
35 changes: 20 additions & 15 deletions go/vt/vtgate/vindexes/vschema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -805,37 +805,37 @@ func TestChooseVindexForType(t *testing.T) {
out: "",
}, {
in: sqltypes.Int8,
out: "hash",
out: "xxhash",
}, {
in: sqltypes.Uint8,
out: "hash",
out: "xxhash",
}, {
in: sqltypes.Int16,
out: "hash",
out: "xxhash",
}, {
in: sqltypes.Uint16,
out: "hash",
out: "xxhash",
}, {
in: sqltypes.Int24,
out: "hash",
out: "xxhash",
}, {
in: sqltypes.Uint24,
out: "hash",
out: "xxhash",
}, {
in: sqltypes.Int32,
out: "hash",
out: "xxhash",
}, {
in: sqltypes.Uint32,
out: "hash",
out: "xxhash",
}, {
in: sqltypes.Int64,
out: "hash",
out: "xxhash",
}, {
in: sqltypes.Uint64,
out: "hash",
out: "xxhash",
}, {
in: sqltypes.Float32,
out: "hash",
out: "",
}, {
in: sqltypes.Float64,
out: "",
Expand All @@ -853,7 +853,7 @@ func TestChooseVindexForType(t *testing.T) {
out: "",
}, {
in: sqltypes.Year,
out: "hash",
out: "xxhash",
}, {
in: sqltypes.Decimal,
out: "",
Expand Down Expand Up @@ -897,11 +897,16 @@ func TestChooseVindexForType(t *testing.T) {

for _, tcase := range testcases {
out, err := ChooseVindexForType(tcase.in)
if out == "" {
assert.Error(t, err, tcase.in)
// If no type is returned then we do not recommend the column be
// used for a vindex. If the test case provides an empty output
// value then we expect an error.
if tcase.out == "" {
assert.Error(t, err, "unexpectedly got a recommended vindex type of %s for input column type %v",
out, tcase.in)
continue
}
assert.Equal(t, out, tcase.out, tcase.in)
assert.Equal(t, out, tcase.out, "expected a recommended vindex type of %s for input column type %v but got %s",
tcase.out, tcase.in, out)
}
}

Expand Down
Loading