label

package
v1.1.0-beta.0...-4e6468d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

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

type Rule pd.LabelRule

Rule is used to establish the relationship between labels and a key range.

func NewRule

func NewRule() *Rule

NewRule creates a rule.

func (*Rule) ApplyAttributesSpec

func (r *Rule) ApplyAttributesSpec(spec *ast.AttributesSpec) error

ApplyAttributesSpec will transfer attributes defined in AttributesSpec to the labels.

func (*Rule) Clone

func (r *Rule) Clone() *Rule

Clone clones a rule.

func (*Rule) Reset

func (r *Rule) Reset(dbName, tableName, partName string, ids ...int64) *Rule

Reset will reset the label rule for a table/partition with a given ID and names.

func (*Rule) String

func (r *Rule) String() string

String implements fmt.Stringer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL