Skip to content

Remove unused key.Destination.IsUnique()#7565

Merged
systay merged 1 commit intovitessio:masterfrom
jmoldow:DestinationIsUnique
Mar 1, 2021
Merged

Remove unused key.Destination.IsUnique()#7565
systay merged 1 commit intovitessio:masterfrom
jmoldow:DestinationIsUnique

Conversation

@jmoldow
Copy link
Contributor

@jmoldow jmoldow commented Feb 27, 2021

Description

This function is never used.

It is also misleading. "IsUnique returns true if this is a
single destination". As currently implemented, a key.Destination
will return true for this method if it represents a single
object of some type, as opposed to an array of objects of some
type. It is unclear that this is a useful concept.

key.DestinationExactKeyRange and key.DestinationKeyRange both
return true always, even though a KeyRange can represent
multiple KeyspaceIDs, and therefore might cover multiple shards.
Since the IsUnique() interface doesn't accept any information
about the topology, the only safe return value would be false,
if we wanted IsUnique() to represent a useful piece of
information about how the query might end up being served.

If this concept needed to be re-introduced, I would suggest one
of two approaches:

  • Introduce new functions IsUniqueKeyspaceID() and
    IsGuaranteedUniqueShard(). IsUniqueKeyspaceID() would only
    return true for a DestinationKeyspaceID, or a
    DestinationKeyspaceIDs that contains 0-1 unique KeyspaceIDs.
    IsGuaranteedUniqueShard() would return true when
    IsUniqueKeyspaceID() returns true, or for 0-1 shard names.
    IsGuaranteedUniqueShard() would always return false for all
    types of KeyRange destinations.

  • In addition to the first approach (or instead of
    IsGuaranteedUniqueShard()), introduce new function
    IsUniqueShard([]*topodatapb.ShardReference). This would behave
    the same as IsGuaranteedUniqueShard(), except that for KeyRange
    destinations, it could potentially return true if the topo data
    indicates that the KeyRange(s) fit within a single shard.

Signed-off-by: Jordan Moldow jmoldow@alum.mit.edu

Checklist

  • Should this PR be backported? - no
  • Tests were added or are not required - not required
  • Documentation was added or is not required - not required

Impacted Areas in Vitess

Components that this PR will affect:

  • Query Serving - not really any effect, since the function is unused
  • VReplication
  • Cluster Management
  • Build/CI
  • VTAdmin

This function is never used.

It is also misleading. "IsUnique returns true if this is a
single destination". As currently implemented, a key.Destination
will return true for this method if it represents a single
object of some type, as opposed to an array of objects of some
type. It is unclear that this is a useful concept.

key.DestinationExactKeyRange and key.DestinationKeyRange both
return true always, even though a KeyRange can represent
multiple KeyspaceIDs, and therefore might cover multiple shards.
Since the IsUnique() interface doesn't accept any information
about the topology, the only safe return value would be false,
if we wanted IsUnique() to represent a useful piece of
information about how the query might end up being served.

If this concept needed to be re-introduced, I would suggest one
of two approaches:

- Introduce new functions IsUniqueKeyspaceID() and
  IsGuaranteedUniqueShard(). IsUniqueKeyspaceID() would only
  return true for a DestinationKeyspaceID, or a
  DestinationKeyspaceIDs that contains 0-1 unique KeyspaceIDs.
  IsGuaranteedUniqueShard() would return true when
  IsUniqueKeyspaceID() returns true, or for 0-1 shard names.
  IsGuaranteedUniqueShard() would always return false for all
  types of KeyRange destinations.

- In addition to the first approach (or instead of
  IsGuaranteedUniqueShard()), introduce new function
  IsUniqueShard([]*topodatapb.ShardReference). This would behave
  the same as IsGuaranteedUniqueShard(), except that for KeyRange
  destinations, it could potentially return true if the topo data
  indicates that the KeyRange(s) fit within a single shard.

Signed-off-by: Jordan Moldow <jmoldow@alum.mit.edu>
@jmoldow jmoldow requested a review from sougou as a code owner February 27, 2021 05:05
Copy link
Collaborator

@systay systay left a comment

Choose a reason for hiding this comment

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

Nice find!

@systay systay merged commit 693cd6e into vitessio:master Mar 1, 2021
@jmoldow jmoldow deleted the DestinationIsUnique branch March 1, 2021 05:52
@askdba askdba added this to the v10.0 milestone Mar 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants