本文整理汇总了Golang中github.com/cockroachdb/cockroach/util/encoding.EncodeNullDescending函数的典型用法代码示例。如果您正苦于以下问题:Golang EncodeNullDescending函数的具体用法?Golang EncodeNullDescending怎么用?Golang EncodeNullDescending使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了EncodeNullDescending函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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(fmt.Sprintf("expected NULL operand for IS operator, found %v", c.Right))
}
for i := range spans {
spans[i].start = encoding.EncodeNullDescending(spans[i].start)
}
case parser.NE:
panic("'!=' operators should have been transformed to 'IS NOT NULL'")
case parser.LE, parser.EQ:
datum := c.Right.(parser.Datum)
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(). Note that a "<" is usually transformed to a "<=".
datum := c.Right.(parser.Datum)
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.Sprintf("unexpected operator: %s", c))
}
}
开发者ID:petermattis,项目名称:cockroach,代码行数:43,代码来源:index_selection.go
示例2: 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
示例3: EncodeTableKey
// EncodeTableKey encodes `val` into `b` and returns the new buffer.
func EncodeTableKey(b []byte, val parser.Datum, dir encoding.Direction) ([]byte, error) {
if (dir != encoding.Ascending) && (dir != encoding.Descending) {
return nil, util.Errorf("invalid direction: %d", dir)
}
if val == parser.DNull {
if dir == encoding.Ascending {
return encoding.EncodeNullAscending(b), nil
}
return encoding.EncodeNullDescending(b), nil
}
switch t := val.(type) {
case *parser.DBool:
var x int64
if *t {
x = 1
} else {
x = 0
}
if dir == encoding.Ascending {
return encoding.EncodeVarintAscending(b, x), nil
}
return encoding.EncodeVarintDescending(b, x), nil
case *parser.DInt:
if dir == encoding.Ascending {
return encoding.EncodeVarintAscending(b, int64(*t)), nil
}
return encoding.EncodeVarintDescending(b, int64(*t)), nil
case *parser.DFloat:
if dir == encoding.Ascending {
return encoding.EncodeFloatAscending(b, float64(*t)), nil
}
return encoding.EncodeFloatDescending(b, float64(*t)), nil
case *parser.DDecimal:
if dir == encoding.Ascending {
return encoding.EncodeDecimalAscending(b, &t.Dec), nil
}
return encoding.EncodeDecimalDescending(b, &t.Dec), nil
case *parser.DString:
if dir == encoding.Ascending {
return encoding.EncodeStringAscending(b, string(*t)), nil
}
return encoding.EncodeStringDescending(b, string(*t)), nil
case *parser.DBytes:
if dir == encoding.Ascending {
return encoding.EncodeStringAscending(b, string(*t)), nil
}
return encoding.EncodeStringDescending(b, string(*t)), nil
case *parser.DDate:
if dir == encoding.Ascending {
return encoding.EncodeVarintAscending(b, int64(*t)), nil
}
return encoding.EncodeVarintDescending(b, int64(*t)), nil
case *parser.DTimestamp:
if dir == encoding.Ascending {
return encoding.EncodeTimeAscending(b, t.Time), nil
}
return encoding.EncodeTimeDescending(b, t.Time), nil
case *parser.DTimestampTZ:
if dir == encoding.Ascending {
return encoding.EncodeTimeAscending(b, t.Time), nil
}
return encoding.EncodeTimeDescending(b, t.Time), nil
case *parser.DInterval:
if dir == encoding.Ascending {
return encoding.EncodeDurationAscending(b, t.Duration)
}
return encoding.EncodeDurationDescending(b, t.Duration)
case *parser.DTuple:
for _, datum := range *t {
var err error
b, err = EncodeTableKey(b, datum, dir)
if err != nil {
return nil, err
}
}
return b, nil
}
return nil, util.Errorf("unable to encode table key: %T", val)
}
开发者ID:GitGoldie,项目名称:cockroach,代码行数:82,代码来源:table.go
示例4: encodeTableKey
// Encodes `val` into `b` and returns the new buffer.
func encodeTableKey(b []byte, val parser.Datum, dir encoding.Direction) ([]byte, *roachpb.Error) {
if (dir != encoding.Ascending) && (dir != encoding.Descending) {
return nil, roachpb.NewErrorf("invalid direction: %d", dir)
}
if val == parser.DNull {
if dir == encoding.Ascending {
return encoding.EncodeNullAscending(b), nil
}
return encoding.EncodeNullDescending(b), nil
}
switch t := val.(type) {
case parser.DBool:
var x int64
if t {
x = 1
} else {
x = 0
}
if dir == encoding.Ascending {
return encoding.EncodeVarintAscending(b, x), nil
}
return encoding.EncodeVarintDescending(b, x), nil
case parser.DInt:
if dir == encoding.Ascending {
return encoding.EncodeVarintAscending(b, int64(t)), nil
}
return encoding.EncodeVarintDescending(b, int64(t)), nil
case parser.DFloat:
if dir == encoding.Ascending {
return encoding.EncodeFloatAscending(b, float64(t)), nil
}
return encoding.EncodeFloatDescending(b, float64(t)), nil
case parser.DDecimal:
if dir == encoding.Ascending {
return encoding.EncodeDecimalAscending(b, t.Decimal), nil
}
return encoding.EncodeDecimalDescending(b, t.Decimal), nil
case parser.DString:
if dir == encoding.Ascending {
return encoding.EncodeStringAscending(b, string(t)), nil
}
return encoding.EncodeStringDescending(b, string(t)), nil
case parser.DBytes:
if dir == encoding.Ascending {
return encoding.EncodeStringAscending(b, string(t)), nil
}
return encoding.EncodeStringDescending(b, string(t)), nil
case parser.DDate:
if dir == encoding.Ascending {
return encoding.EncodeVarintAscending(b, int64(t)), nil
}
return encoding.EncodeVarintDescending(b, int64(t)), nil
case parser.DTimestamp:
if dir == encoding.Ascending {
return encoding.EncodeTimeAscending(b, t.Time), nil
}
return encoding.EncodeTimeDescending(b, t.Time), nil
case parser.DInterval:
if dir == encoding.Ascending {
return encoding.EncodeVarintAscending(b, int64(t.Duration)), nil
}
return encoding.EncodeVarintDescending(b, int64(t.Duration)), nil
}
return nil, roachpb.NewUErrorf("unable to encode table key: %T", val)
}
开发者ID:ekkotron,项目名称:cockroach,代码行数:68,代码来源:table.go
注:本文中的github.com/cockroachdb/cockroach/util/encoding.EncodeNullDescending函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论