Documentation ¶
Index ¶
- Constants
- Variables
- func Add(labels *[]pd.RegionLabel, label pd.RegionLabel) error
- func NewLabel(attr string) (pd.RegionLabel, error)
- func NewLabels(attrs []string) ([]pd.RegionLabel, error)
- func NewRulePatch(setRules []*Rule, deleteRules []string) *pd.LabelRulePatch
- func RestoreRegionLabel(l *pd.RegionLabel) string
- func RestoreRegionLabels(labels *[]pd.RegionLabel) string
- type AttributesCompatibility
- type Rule
Constants ¶
View Source
const ( // RuleIndexDefault is the default index for a rule. RuleIndexDefault int = iota // RuleIndexDatabase is the index for a rule of database. RuleIndexDatabase // RuleIndexTable is the index for a rule of table. RuleIndexTable // RuleIndexPartition is the index for a rule of partition. RuleIndexPartition )
View Source
const (
// IDPrefix is the prefix for label rule ID.
IDPrefix = "schema"
)
Variables ¶
View Source
var ( // TableIDFormat is the format of the label rule ID for a table. // The format follows "schema/database_name/table_name". TableIDFormat = "%s/%s/%s" // PartitionIDFormat is the format of the label rule ID for a partition. // The format follows "schema/database_name/table_name/partition_name". PartitionIDFormat = "%s/%s/%s/%s" )
View Source
var ( // ErrInvalidAttributesFormat is from attributes.go ErrInvalidAttributesFormat = errors.New("attributes should be in format 'key=value'") )
Functions ¶
func Add ¶
func Add(labels *[]pd.RegionLabel, label pd.RegionLabel) error
Add will add a new attribute, with validation of all attributes.
func NewLabel ¶
func NewLabel(attr string) (pd.RegionLabel, error)
NewLabel creates a new label for a given string.
func NewLabels ¶
func NewLabels(attrs []string) ([]pd.RegionLabel, error)
NewLabels creates a slice of Label for given attributes.
func NewRulePatch ¶
func NewRulePatch(setRules []*Rule, deleteRules []string) *pd.LabelRulePatch
NewRulePatch returns a patch of rules which need to be set or deleted.
func RestoreRegionLabel ¶
func RestoreRegionLabel(l *pd.RegionLabel) string
RestoreRegionLabel converts a Attribute to a string.
func RestoreRegionLabels ¶
func RestoreRegionLabels(labels *[]pd.RegionLabel) string
RestoreRegionLabels converts Attributes to a string.
Types ¶
type AttributesCompatibility ¶
type AttributesCompatibility byte
AttributesCompatibility is the return type of CompatibleWith.
const ( // AttributesCompatible indicates two attributes are compatible. AttributesCompatible AttributesCompatibility = iota // AttributesIncompatible indicates two attributes are incompatible. AttributesIncompatible // AttributesDuplicated indicates two attributes are duplicated. AttributesDuplicated )
func CompatibleWith ¶
func CompatibleWith(l *pd.RegionLabel, o *pd.RegionLabel) AttributesCompatibility
CompatibleWith will check if two constraints are compatible. Return (compatible, duplicated).
type Rule ¶
Rule is used to establish the relationship between labels and a key range.
func (*Rule) ApplyAttributesSpec ¶
func (r *Rule) ApplyAttributesSpec(spec *ast.AttributesSpec) error
ApplyAttributesSpec will transfer attributes defined in AttributesSpec to the labels.
Click to show internal directories.
Click to hide internal directories.