当前位置: 首页>>代码示例>>Golang>>正文


Golang ComparisonExpr.String方法代码示例

本文整理汇总了Golang中github.com/cockroachdb/cockroach/sql/parser.ComparisonExpr.String方法的典型用法代码示例。如果您正苦于以下问题:Golang ComparisonExpr.String方法的具体用法?Golang ComparisonExpr.String怎么用?Golang ComparisonExpr.String使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/cockroachdb/cockroach/sql/parser.ComparisonExpr的用法示例。


在下文中一共展示了ComparisonExpr.String方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: encodeStartConstraintDescending

func encodeStartConstraintDescending(
	spans []span, c *parser.ComparisonExpr) {
	switch c.Operator {
	case parser.Is:
		// An IS NULL expressions allows us to constrain the start of the range
		// to begin at NULL.
		if c.Right != parser.DNull {
			panic("Expected NULL operand for IS operator.")
		}
		for i := range spans {
			spans[i].start = encoding.EncodeNullDescending(spans[i].start)
		}
	case parser.LE, parser.EQ:
		if datum, ok := c.Right.(parser.Datum); ok {
			key, pErr := encodeTableKey(nil, datum, encoding.Descending)
			if pErr != nil {
				panic(pErr)
			}
			// Append the constraint to all of the existing spans.
			for i := range spans {
				spans[i].start = append(spans[i].start, key...)
			}
		}
	case parser.LT:
		// A "<" constraint is the last start constraint. Since the constraint
		// is exclusive and the start key is inclusive, we're going to apply
		// a .PrefixEnd().
		if datum, ok := c.Right.(parser.Datum); ok {
			key, pErr := encodeTableKey(nil, datum, encoding.Descending)
			if pErr != nil {
				panic(pErr)
			}
			// Append the constraint to all of the existing spans.
			for i := range spans {
				spans[i].start = append(spans[i].start, key...)
				spans[i].start = spans[i].start.PrefixEnd()
			}
		}
	default:
		panic(fmt.Errorf("unexpected operator: %s", c.String()))
	}
}
开发者ID:surpass,项目名称:cockroach,代码行数:42,代码来源:select.go

示例2: encodeEndConstraintDescending

func encodeEndConstraintDescending(spans []span, c *parser.ComparisonExpr,
	isLastEndConstraint bool) {
	switch c.Operator {
	case parser.IsNot:
		// An IS NULL expressions allows us to constrain the end of the range
		// to stop at NULL.
		if c.Right != parser.DNull {
			panic("Expected NULL operand for IS NOT operator.")
		}
		for i := range spans {
			spans[i].end = encoding.EncodeNotNullDescending(spans[i].end)
		}
	case parser.GE, parser.EQ:
		datum := c.Right.(parser.Datum)
		for i := range spans {
			spans[i].end = encodeInclusiveEndValue(
				spans[i].end, datum, encoding.Descending, isLastEndConstraint)
		}
	case parser.GT:
		panic("'>' operators should have been transformed to '>='.")
	default:
		panic(fmt.Errorf("unexpected operator: %s", c.String()))
	}
}
开发者ID:surpass,项目名称:cockroach,代码行数:24,代码来源:select.go


注:本文中的github.com/cockroachdb/cockroach/sql/parser.ComparisonExpr.String方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。