cond

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ComplexCondition

type ComplexCondition struct {
	Op         opcode.Op
	Conditions []Condition
}

func (*ComplexCondition) And

func (cond *ComplexCondition) And(cond2 Condition) Condition

func (*ComplexCondition) Or

func (cond *ComplexCondition) Or(cond2 Condition) Condition

func (*ComplexCondition) Shard

type Condition

type Condition interface {
	And(cond Condition) Condition
	Or(cond Condition) Condition
}

func And

func And(alg ShardingAlgorithm, k1, k2 *KeyCondition) (Condition, error)

And condition1, condition2 TrueCondition FalseCondition KeyCondition return TrueCondition FalseCondition TableIndexSliceCondition

func Or

func Or(alg ShardingAlgorithm, condition1, condition2 Condition) (Condition, error)

Or condition1, condition2 TrueCondition FalseCondition KeyCondition return TrueCondition FalseCondition TableIndexSliceCondition

func ParseBetweenCondition

func ParseBetweenCondition(expr *ast.BetweenExpr, args ...interface{}) (Condition, error)

func ParseCompareExpression

func ParseCompareExpression(expr *ast.BinaryOperationExpr, args ...interface{}) (Condition, error)

func ParseCondition

func ParseCondition(cond ast.ExprNode, args ...interface{}) (Condition, error)

func ParseInCondition

func ParseInCondition(expr *ast.PatternInExpr, args ...interface{}) (Condition, error)

func ParseLikeCondition

func ParseLikeCondition(expr *ast.PatternLikeExpr, args ...interface{}) (Condition, error)

func ParseLogicalCondition

func ParseLogicalCondition(expr *ast.BinaryOperationExpr, args ...interface{}) (Condition, error)

func ParseMathCondition

func ParseMathCondition(expr *ast.BinaryOperationExpr, args ...interface{}) (Condition, error)

func ParseValCondition

func ParseValCondition(expr ast.ExprNode, args ...interface{}) (Condition, error)

type ConditionShard

type ConditionShard interface {
	Shard(alg ShardingAlgorithm) (TableIndexSliceCondition, error)
}

type ConditionSlice

type ConditionSlice []Condition

func (ConditionSlice) Len

func (s ConditionSlice) Len() int

func (ConditionSlice) Less

func (s ConditionSlice) Less(i, j int) bool

func (ConditionSlice) Swap

func (s ConditionSlice) Swap(i, j int)

type FalseCondition

type FalseCondition struct{}

func (FalseCondition) And

func (cond FalseCondition) And(cond2 Condition) Condition

func (FalseCondition) Or

func (cond FalseCondition) Or(cond2 Condition) Condition

func (FalseCondition) Shard

type KeyCondition

type KeyCondition struct {
	Key   string
	Op    opcode.Op
	Value interface{}
}

func (*KeyCondition) And

func (cond *KeyCondition) And(cond2 Condition) Condition

func (*KeyCondition) Or

func (cond *KeyCondition) Or(cond2 Condition) Condition

func (*KeyCondition) Shard

type NumberMod

type NumberMod struct {
	// contains filtered or unexported fields
}

func NewNumberMod

func NewNumberMod(shardingKey string, allowFullScan bool, topology *topo.Topology, generator proto.SequenceGenerator) *NumberMod

func (*NumberMod) AllShards

func (shard *NumberMod) AllShards() Condition

func (*NumberMod) AllowFullScan

func (shard *NumberMod) AllowFullScan() bool

func (*NumberMod) HasShardingKey

func (shard *NumberMod) HasShardingKey(key string) bool

func (*NumberMod) NextID added in v0.5.0

func (shard *NumberMod) NextID() (int64, error)

func (*NumberMod) Shard

func (shard *NumberMod) Shard(condition *KeyCondition) (Condition, error)

func (*NumberMod) ShardRange

func (shard *NumberMod) ShardRange(cond1, cond2 *KeyCondition) (Condition, error)

type NumberRange added in v0.5.0

type NumberRange struct {
	// contains filtered or unexported fields
}

func NewNumberRange added in v0.5.0

func NewNumberRange(shardingKey string,
	allowFullScan bool,
	topology *topo.Topology,
	config map[string]interface{},
	generator proto.SequenceGenerator) (*NumberRange, error)

func (*NumberRange) AllShards added in v0.5.0

func (shard *NumberRange) AllShards() Condition

func (*NumberRange) AllowFullScan added in v0.5.0

func (shard *NumberRange) AllowFullScan() bool

func (*NumberRange) HasShardingKey added in v0.5.0

func (shard *NumberRange) HasShardingKey(key string) bool

func (*NumberRange) NextID added in v0.5.0

func (shard *NumberRange) NextID() (int64, error)

func (*NumberRange) Shard added in v0.5.0

func (shard *NumberRange) Shard(condition *KeyCondition) (Condition, error)

func (*NumberRange) ShardRange added in v0.5.0

func (shard *NumberRange) ShardRange(cond1, cond2 *KeyCondition) (Condition, error)

type Range added in v0.5.0

type Range struct {
	From int64
	To   int64
}

type ShardingAlgorithm

type ShardingAlgorithm interface {
	HasShardingKey(key string) bool
	Shard(condition *KeyCondition) (Condition, error)
	ShardRange(cond1, cond2 *KeyCondition) (Condition, error)
	AllShards() Condition
	AllowFullScan() bool
	proto.SequenceGenerator
}

func NewShardingAlgorithm added in v0.5.0

func NewShardingAlgorithm(algorithm, shardingKey string,
	allowFullScan bool, topology *topo.Topology, config map[string]interface{}, generator proto.SequenceGenerator) (ShardingAlgorithm, error)

type TableIndexSliceCondition

type TableIndexSliceCondition []int

func (TableIndexSliceCondition) And

func (TableIndexSliceCondition) Or

func (TableIndexSliceCondition) ParseTopology

func (cond TableIndexSliceCondition) ParseTopology(topology *topo.Topology) (bool, map[string][]string)

ParseTopology return whether you need full scan, and db tables map

type TrueCondition

type TrueCondition struct{}

func (TrueCondition) And

func (cond TrueCondition) And(cond2 Condition) Condition

func (TrueCondition) Or

func (cond TrueCondition) Or(cond2 Condition) Condition

func (TrueCondition) Shard

Jump to

Keyboard shortcuts

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