本文整理汇总了Golang中github.com/pingcap/tidb/expression.BinaryOperation类的典型用法代码示例。如果您正苦于以下问题:Golang BinaryOperation类的具体用法?Golang BinaryOperation怎么用?Golang BinaryOperation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BinaryOperation类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: VisitBinaryOperation
// VisitBinaryOperation swaps the right side identifier to left side if left side expression is static.
// So it can be used in index plan.
func (iev *IdentEvalVisitor) VisitBinaryOperation(binop *expression.BinaryOperation) (expression.Expression, error) {
var err error
binop.L, err = binop.L.Accept(iev)
if err != nil {
return binop, errors.Trace(err)
}
binop.R, err = binop.R.Accept(iev)
if err != nil {
return binop, errors.Trace(err)
}
if binop.L.IsStatic() {
if _, ok := binop.R.(*expression.Ident); ok {
switch binop.Op {
case opcode.EQ:
case opcode.NE:
case opcode.NullEQ:
case opcode.LT:
binop.Op = opcode.GE
case opcode.LE:
binop.Op = opcode.GT
case opcode.GE:
binop.Op = opcode.LT
case opcode.GT:
binop.Op = opcode.LE
default:
// unsupported opcode
return binop, nil
}
binop.L, binop.R = binop.R, binop.L
}
}
return binop, nil
}
开发者ID:maserg,项目名称:tidb,代码行数:36,代码来源:join.go
示例2: filterBinOp
func (r *TableDefaultPlan) filterBinOp(ctx context.Context, x *expression.BinaryOperation) (plan.Plan, bool, error) {
ok, name, rval, err := x.IsIdentCompareVal()
if err != nil {
return r, false, errors.Trace(err)
}
if !ok {
return r, false, nil
}
if rval == nil {
// if nil, any <, <=, >, >=, =, != operator will do nothing
// any value compared null returns null
// TODO: if we support <=> later, we must handle null
return &NullPlan{r.GetFields()}, true, nil
}
_, tn, cn := field.SplitQualifiedName(name)
t := r.T
if tn != "" && tn != t.TableName().L {
return r, false, nil
}
c := column.FindCol(t.Cols(), cn)
if c == nil {
return nil, false, errors.Errorf("No such column: %s", cn)
}
var seekVal interface{}
if seekVal, err = types.Convert(rval, &c.FieldType); err != nil {
return nil, false, errors.Trace(err)
}
spans := toSpans(x.Op, rval, seekVal)
if c.IsPKHandleColumn(r.T.Meta()) {
if r.rangeScan {
spans = filterSpans(r.spans, spans)
}
return &TableDefaultPlan{
T: r.T,
Fields: r.Fields,
rangeScan: true,
spans: spans,
}, true, nil
} else if r.rangeScan {
// Already filtered on PK handle column, should not switch to index plan.
return r, false, nil
}
ix := t.FindIndexByColName(cn)
if ix == nil { // Column cn has no index.
return r, false, nil
}
return &indexPlan{
src: t,
col: c,
unique: ix.Unique,
idxName: ix.Name.O,
idx: ix.X,
spans: spans,
}, true, nil
}
开发者ID:lovedboy,项目名称:tidb,代码行数:57,代码来源:from.go
示例3: filterBinOp
func (r *TableDefaultPlan) filterBinOp(ctx context.Context, x *expression.BinaryOperation) (plan.Plan, bool, error) {
ok, name, rval, err := x.IsIdentCompareVal()
if err != nil {
return r, false, err
}
if !ok {
return r, false, nil
}
if rval == nil {
// if nil, any <, <=, >, >=, =, != operator will do nothing
// any value compared null returns null
// TODO: if we support <=> later, we must handle null
return &NullPlan{r.GetFields()}, true, nil
}
_, tn, cn := field.SplitQualifiedName(name)
t := r.T
if tn != "" && tn != t.TableName().L {
return r, false, nil
}
c := column.FindCol(t.Cols(), cn)
if c == nil {
return nil, false, errors.Errorf("No such column: %s", cn)
}
ix := t.FindIndexByColName(cn)
if ix == nil { // Column cn has no index.
return r, false, nil
}
var seekVal interface{}
if seekVal, err = types.Convert(rval, &c.FieldType); err != nil {
return nil, false, err
}
return &indexPlan{
src: t,
col: c,
idxName: ix.Name.O,
idx: ix.X,
spans: toSpans(x.Op, rval, seekVal),
}, true, nil
}
开发者ID:kevinhuo88888,项目名称:tidb,代码行数:42,代码来源:from.go
注:本文中的github.com/pingcap/tidb/expression.BinaryOperation类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论