-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
vindex & vrepl: multi-column support #5509
Conversation
This new change extends the Vindex protocol slightly differently from the previous approach. In the previous approach, a Vindex had the option of supporting an additional MultiColumn Map API on top of the existing single column Map. This allowed for a Vindex to be a functional one through the MultiColumn API, and a lookup one through the regular Map. But the same functionality can be achieved by two vindexes, and leads to a more flexible and composable design. In the new design, a Vindex can decide if it wants to provide a SingleColumn of MultiColumn API. If the caller is capable of using the MultiColumn API, they use it. Otherwise, they treat the vindex as non-existent. This is the initial cut. With this change, we can bring back the restriction to disallow owned vindexes from being primary. Insert and VReplication will use MultiColumn. The rest of v3 will continue to use SingleColumn for now. Signed-off-by: Sugu Sougoumarane <[email protected]>
Signed-off-by: Sugu Sougoumarane <[email protected]>
Signed-off-by: Sugu Sougoumarane <[email protected]>
Signed-off-by: Sugu Sougoumarane <[email protected]>
9502a71
to
1c50ee9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice clean design. Better than the previous iteration.
A couple of nits and a question inline.
go/vt/vtgate/vindexes/vindex.go
Outdated
@@ -142,18 +148,24 @@ func CreateVindex(vindexType, name string, params map[string]string) (Vindex, er | |||
|
|||
// Map invokes MapMulti or Map depending on which is available. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix comment
go/vt/vtgate/vindexes/vindex.go
Outdated
} | ||
return vindex.Map(vcursor, firstColsOnly(rowsColValues)) | ||
return nil, vterrors.New(vtrpcpb.Code_INTERNAL, "vindex does not have Map functions") | ||
} | ||
|
||
// Verify invokes VerifyMulti or Verify depending on which is available. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix comment
@@ -147,7 +147,8 @@ func newKeyspaceIDResolverFactoryV3(ctx context.Context, ts *topo.Server, keyspa | |||
if col.Name.EqualString(shardingColumnName) { | |||
// We found the column. | |||
return i, &keyspaceIDResolverFactoryV3{ | |||
vindex: colVindex.Vindex, | |||
// Only SingleColumn vindexes are returned by FindVindexForSharding. | |||
vindex: colVindex.Vindex.(vindexes.SingleColumn), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can bad things happen if this turns out to be nil?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous function guarantees that the value won't be nil.
Signed-off-by: Sugu Sougoumarane <[email protected]>
This new change extends the Vindex protocol slightly differently
from the previous approach.
In the previous approach, a Vindex had the option of supporting
an additional MultiColumn Map API on top of the existing single
column Map. This allowed for a Vindex to be a functional one
through the MultiColumn API, and a lookup one through the regular
Map.
But the same functionality can be achieved by two vindexes, and
leads to a more flexible and composable design.
In the new design, a Vindex can decide if it wants to provide
a SingleColumn of MultiColumn API. If the caller is capable of
using the MultiColumn API, they use it. Otherwise, they treat
the vindex as non-existent.
This is the initial cut. With this change, we can bring back
the restriction to disallow owned vindexes from being primary.
Insert and VReplication use MultiColumn. The rest of v3
will continue to use SingleColumn for now.