本文整理匯總了Golang中github.com/cockroachdb/cockroach/pkg/sql/parser.Datum.IsMax方法的典型用法代碼示例。如果您正苦於以下問題:Golang Datum.IsMax方法的具體用法?Golang Datum.IsMax怎麽用?Golang Datum.IsMax使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cockroachdb/cockroach/pkg/sql/parser.Datum
的用法示例。
在下文中一共展示了Datum.IsMax方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: encodeInclusiveEndValue
// Encodes datum at the end of key, using direction `dir` for the encoding.
// It takes in an inclusive key and returns an inclusive key if
// isLastEndConstraint is not set, and an exclusive key otherwise (the idea is
// that, for inclusive constraints, the value for the last column in the
// constraint needs to be adapted to an exclusive span.EndKey).
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, err := sqlbase.EncodeTableKey(key, datum, dir)
if err != nil {
panic(err)
}
if needExclusiveKey {
key = key.PrefixEnd()
}
return key
}