Skip to content

vindex & vrepl: multi-column support#5509

Merged
sougou merged 5 commits intovitessio:masterfrom
planetscale:ss-vrepl-multicol
Dec 10, 2019
Merged

vindex & vrepl: multi-column support#5509
sougou merged 5 commits intovitessio:masterfrom
planetscale:ss-vrepl-multicol

Conversation

@sougou
Copy link
Copy Markdown
Contributor

@sougou sougou commented Dec 5, 2019

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.

@sougou sougou requested a review from deepthi December 5, 2019 07:04
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 <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
@sougou sougou force-pushed the ss-vrepl-multicol branch from 9502a71 to 1c50ee9 Compare December 5, 2019 23:00
Copy link
Copy Markdown
Collaborator

@deepthi deepthi left a 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.

@@ -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.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix comment

return nil, vterrors.New(vtrpcpb.Code_INTERNAL, "vindex does not have Map functions")
}

// Verify invokes VerifyMulti or Verify depending on which is available.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix comment

return i, &keyspaceIDResolverFactoryV3{
vindex: colVindex.Vindex,
// Only SingleColumn vindexes are returned by FindVindexForSharding.
vindex: colVindex.Vindex.(vindexes.SingleColumn),
Copy link
Copy Markdown
Collaborator

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?

Copy link
Copy Markdown
Contributor Author

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 <ssougou@gmail.com>
@sougou sougou merged commit cf0ae7d into vitessio:master Dec 10, 2019
@sougou sougou deleted the ss-vrepl-multicol branch December 14, 2019 06:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants