cond

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2022 License: Apache-2.0 Imports: 13 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 MonthMod

type MonthMod struct {
	ShardNum int
}

func (*MonthMod) Shard

func (shard *MonthMod) Shard(value interface{}) (int, error)

type NumberMod

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

func NewNumberMod

func NewNumberMod(shardingKey string, allowFullScan bool, topology *topo.Topology) *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) Shard

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

func (*NumberMod) ShardRange

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

type ShardingAlgorithm

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

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

type YearMod

type YearMod struct {
	ShardNum int
}

func (*YearMod) Shard

func (shard *YearMod) Shard(value interface{}) (int, error)

Jump to

Keyboard shortcuts

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