本文整理汇总了Golang中github.com/cockroachdb/cockroach/sql/parser.Datum.HasNext方法的典型用法代码示例。如果您正苦于以下问题:Golang Datum.HasNext方法的具体用法?Golang Datum.HasNext怎么用?Golang Datum.HasNext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cockroachdb/cockroach/sql/parser.Datum
的用法示例。
在下文中一共展示了Datum.HasNext方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: encodeInclusiveEndValue
// Encodes datum at the end of key, using direction `dir` for the encoding.
// The key is a span end key, which is exclusive, but `val` needs to
// be inclusive. So if datum is the last end constraint, we transform it accordingly.
func encodeInclusiveEndValue(
key roachpb.Key, datum parser.Datum, dir encoding.Direction,
isLastEndConstraint bool) roachpb.Key {
// Since the end of a span is exclusive, if the last constraint is an
// inclusive one, we might need to make the key exclusive by applying a
// PrefixEnd(). We normally avoid doing this by transforming "a = x" to
// "a = x±1" for the last end constraint, depending on the encoding direction
// (since this keeps the key nice and pretty-printable).
// However, we might not be able to do the ±1.
needExclusiveKey := false
if isLastEndConstraint {
if dir == encoding.Ascending {
if datum.IsMax() || !datum.HasNext() {
needExclusiveKey = true
} else {
datum = datum.Next()
}
} else {
if datum.IsMin() || !datum.HasPrev() {
needExclusiveKey = true
} else {
datum = datum.Prev()
}
}
}
key, pErr := encodeTableKey(key, datum, dir)
if pErr != nil {
panic(pErr)
}
if needExclusiveKey {
key = key.PrefixEnd()
}
return key
}