Documentation
¶
Index ¶
- Constants
- func IsUnique(v Vindex) bool
- func Register(vindexType string, newVindexFunc NewVindexFunc)
- type ByCost
- type ColVindex
- type ColVindexFormal
- type Functional
- type FunctionalGenerator
- type Keyspace
- type KeyspaceFormal
- type Lookup
- type LookupGenerator
- type NewVindexFunc
- type NonUnique
- type Plan
- type PlanID
- type Reversible
- type Schema
- type SchemaFormal
- type Table
- type TableFormal
- type Unique
- type VCursor
- type Vindex
- type VindexFormal
Constants ¶
const ( NoPlan = PlanID(iota) SelectUnsharded SelectEqual SelectIN SelectScatter UpdateUnsharded UpdateEqual DeleteUnsharded DeleteEqual InsertUnsharded InsertSharded NumPlans )
Variables ¶
This section is empty.
Functions ¶
func Register ¶
func Register(vindexType string, newVindexFunc NewVindexFunc)
Register registers a vindex under the specified vindexType. A duplicate vindexType will generate a panic. New vindexes will be created using these functions at the time of schema loading.
Types ¶
type ByCost ¶
type ByCost []*ColVindex
ByCost provides the interface needed for ColVindexes to be sorted by cost order.
type ColVindexFormal ¶
ColVindexFormal is the info for each indexed column of a table as loaded from the source.
type Functional ¶
type Functional interface { Create(cursor VCursor, id interface{}) error Delete(cursor VCursor, id interface{}, keyspace_id key.KeyspaceId) error Unique }
A Functional vindex is an index that can compute the keyspace id from the id without a lookup. This means that the creation of a functional vindex entry does not take the keyspace id as input. In general, the main reason to support creation functions for functional indexes is for auto-generating ids. A Functional vindex is also required to be Unique. If it's not unique, we cannot determine the target shard for an insert operation.
type FunctionalGenerator ¶
type FunctionalGenerator interface { Functional Generate(cursor VCursor) (id interface{}, err error) }
A FunctionalGenerator vindex is a Functional vindex that can generate new ids.
type KeyspaceFormal ¶
type KeyspaceFormal struct { Sharded bool Vindexes map[string]VindexFormal Tables map[string]TableFormal }
KeyspaceFormal is the keyspace info for each keyspace as loaded from the source.
type Lookup ¶
type Lookup interface { Create(cursor VCursor, id interface{}, keyspace_id key.KeyspaceId) error Delete(cursor VCursor, id interface{}, keyspace_id key.KeyspaceId) error }
A Lookup vindex is one that needs to lookup a previously stored map to compute the keyspace id from an id. This means that the creation of a lookup vindex entry requires a keyspace id as input. A Lookup vindex need not be unique because the keyspace_id, which must be supplied, can be used to determine the target shard for an insert operation.
type LookupGenerator ¶
type LookupGenerator interface { Lookup Generate(cursor VCursor, keyspace_id key.KeyspaceId) (id interface{}, err error) }
A LookupGenerator vindex is a Lookup that can generate new ids.
type NewVindexFunc ¶
A NewVindexFunc is a function that creates a Vindex based on the properties specified in the input map. Every vindex must register a NewVindexFunc under a unique vindexType.
type NonUnique ¶
type NonUnique interface {
Map(cursor VCursor, ids []interface{}) ([][]key.KeyspaceId, error)
}
NonUnique defines the interface for a non-unique vindex. This means that an id can map to multiple keyspace ids.
type Plan ¶
type Plan struct { ID PlanID Reason string Table *Table Original string Rewritten string ColVindex *ColVindex Values interface{} }
func (*Plan) IsMulti ¶
IsMulti returns true if the SELECT query can potentially be sent to more than one shard.
func (*Plan) MarshalJSON ¶
type Reversible ¶
type Reversible interface {
ReverseMap(cursor VCursor, ks key.KeyspaceId) (interface{}, error)
}
A Reversible vindex is one that can perform a reverse lookup from a keyspace id to an id. This is optional. If present, VTGate can use it to fill column values based on the target keyspace id.
type Schema ¶
Schema represents the denormalized version of SchemaFormal, used for building routing plans.
func BuildSchema ¶
func BuildSchema(source *SchemaFormal) (schema *Schema, err error)
BuildSchema builds a Schema from a SchemaFormal.
func LoadSchemaJSON ¶
LoadSchemaJSON loads the formal representation of a schema from a JSON file and returns the more usable denormalized representaion (Schema) for it.
type SchemaFormal ¶
type SchemaFormal struct {
Keyspaces map[string]KeyspaceFormal
}
SchemaFormal is the formal representation of the schema as loaded from the source.
type TableFormal ¶
type TableFormal struct {
ColVindexes []ColVindexFormal
}
TableFormal is the info for each table as loaded from the source.
type Unique ¶
type Unique interface {
Map(cursor VCursor, ids []interface{}) ([]key.KeyspaceId, error)
}
Unique defines the interface for a unique vindex. For a vindex to be unique, an id has to map to at most one keyspace id.
type VCursor ¶
type VCursor interface {
Execute(query *tproto.BoundQuery) (*mproto.QueryResult, error)
}
A VCursor is an interface that allows you to execute queries in the current context and session of a VTGate request. Vindexes can use this interface to execute lookup queries.
type Vindex ¶
type Vindex interface { // Cost is used by planbuilder to prioritize vindexes. // The cost can be 0 if the id is basically a keyspace id. // The cost can be 1 if the id can be hashed to a keyspace id. // The cost can be 2 or above if the id needs to be looked up // from an external data source. These guidelines are subject // to change in the future. Cost() int // Verify must be implented by all vindexes. It should return // true if the id can be mapped to the keyspace id. Verify(cursor VCursor, id interface{}, ks key.KeyspaceId) (bool, error) }
Vindex defines the interface required to register a vindex. Additional to these functions, a vindex also needs to satisfy the Unique or NonUnique interface.
type VindexFormal ¶
VindexFormal is the info for each index as loaded from the source.