Documentation ¶
Index ¶
- Constants
- func DecodeBytesAscending(b []byte, r []byte) ([]byte, []byte, error)
- func DecodeBytesDescending(b []byte, r []byte) ([]byte, []byte, error)
- func DecodeDecimalAscending(buf []byte, tmp []byte) ([]byte, decimal.Decimal, error)
- func DecodeDecimalDescending(buf []byte, tmp []byte) ([]byte, decimal.Decimal, error)
- func DecodeFloatAscending(buf []byte, tmp []byte) ([]byte, float64, error)
- func DecodeFloatDescending(buf []byte, tmp []byte) ([]byte, float64, error)
- func DecodeIfNotNull(b []byte) ([]byte, bool)
- func DecodeIfNull(b []byte) ([]byte, bool)
- func DecodeStringAscending(b []byte, r []byte) ([]byte, string, error)
- func DecodeStringDescending(b []byte, r []byte) ([]byte, string, error)
- func DecodeTimeAscending(b []byte) ([]byte, time.Time, error)
- func DecodeTimeDescending(b []byte) ([]byte, time.Time, error)
- func DecodeUint32Ascending(b []byte) ([]byte, uint32, error)
- func DecodeUint32Descending(b []byte) ([]byte, uint32, error)
- func DecodeUint64Ascending(b []byte) ([]byte, uint64, error)
- func DecodeUint64Descending(b []byte) ([]byte, uint64, error)
- func DecodeUvarintAscending(b []byte) ([]byte, uint64, error)
- func DecodeUvarintDescending(b []byte) ([]byte, uint64, error)
- func DecodeVarintAscending(b []byte) ([]byte, int64, error)
- func DecodeVarintDescending(b []byte) ([]byte, int64, error)
- func EncodeBytesAscending(b []byte, data []byte) []byte
- func EncodeBytesDescending(b []byte, data []byte) []byte
- func EncodeDecimalAscending(b []byte, d decimal.Decimal) []byte
- func EncodeDecimalDescending(b []byte, d decimal.Decimal) []byte
- func EncodeFloatAscending(b []byte, f float64) []byte
- func EncodeFloatDescending(b []byte, f float64) []byte
- func EncodeNotNullAscending(b []byte) []byte
- func EncodeNotNullDescending(b []byte) []byte
- func EncodeNullAscending(b []byte) []byte
- func EncodeNullDescending(b []byte) []byte
- func EncodeStringAscending(b []byte, s string) []byte
- func EncodeStringDescending(b []byte, s string) []byte
- func EncodeTimeAscending(b []byte, t time.Time) []byte
- func EncodeTimeDescending(b []byte, t time.Time) []byte
- func EncodeUint32Ascending(b []byte, v uint32) []byte
- func EncodeUint32Descending(b []byte, v uint32) []byte
- func EncodeUint64Ascending(b []byte, v uint64) []byte
- func EncodeUint64Descending(b []byte, v uint64) []byte
- func EncodeUvarintAscending(b []byte, v uint64) []byte
- func EncodeUvarintDescending(b []byte, v uint64) []byte
- func EncodeVarintAscending(b []byte, v int64) []byte
- func EncodeVarintDescending(b []byte, v int64) []byte
- func PrettyPrintValue(b []byte, sep string) string
- type Direction
- type Type
Constants ¶
const ( // IntMin is chosen such that the range of int tags does not overlap the // ascii character set that is frequently used in testing. IntMin = 0x80 // IntMax is the maximum int tag value. IntMax = 0xfd )
const (
// BytesDescMarker is exported for testing.
BytesDescMarker = bytesDescMarker
)
Variables ¶
This section is empty.
Functions ¶
func DecodeBytesAscending ¶
DecodeBytesAscending decodes a []byte value from the input buffer which was encoded using EncodeBytesAscending. The decoded bytes are appended to r. The remainder of the input buffer and the decoded []byte are returned.
func DecodeBytesDescending ¶
DecodeBytesDescending decodes a []byte value from the input buffer which was encoded using EncodeBytesDescending. The decoded bytes are appended to r. The remainder of the input buffer and the decoded []byte are returned.
func DecodeDecimalAscending ¶
DecodeDecimalAscending returns the remaining byte slice after decoding and the decoded decimal from buf.
func DecodeDecimalDescending ¶
DecodeDecimalDescending decodes floats encoded with EncodeDecimalDescending.
func DecodeFloatAscending ¶
DecodeFloatAscending returns the remaining byte slice after decoding and the decoded float64 from buf.
func DecodeFloatDescending ¶
DecodeFloatDescending decodes floats encoded with EncodeFloatDescending.
func DecodeIfNotNull ¶
DecodeIfNotNull decodes a not-NULL value from the input buffer. If the input buffer contains a not-NULL marker at the start of the buffer then it is removed from the buffer and true is returned for the second result. Otherwise, the buffer is returned unchanged and false is returned for the second result. Note that the not-NULL marker is identical to the empty string encoding, so do not use this routine where it is necessary to distinguish not-NULL from the empty string. This function handles both ascendingly and descendingly encoded NULLs.
func DecodeIfNull ¶
DecodeIfNull decodes a NULL value from the input buffer. If the input buffer contains a null at the start of the buffer then it is removed from the buffer and true is returned for the second result. Otherwise, the buffer is returned unchanged and false is returned for the second result. Since the NULL value encoding is guaranteed to never occur as the prefix for the EncodeVarint, EncodeFloat, EncodeBytes and EncodeString encodings, it is safe to call DecodeIfNull on their encoded values. This function handles both ascendingly and descendingly encoded NULLs.
func DecodeStringAscending ¶
DecodeStringAscending decodes a string value from the input buffer which was encoded using EncodeString or EncodeBytes. The r []byte is used as a temporary buffer in order to avoid memory allocations. The remainder of the input buffer and the decoded string are returned.
func DecodeStringDescending ¶
DecodeStringDescending decodes a string value from the input buffer which was encoded using EncodeStringDescending or EncodeBytesDescending. The r []byte is used as a temporary buffer in order to avoid memory allocations. The remainder of the input buffer and the decoded string are returned.
func DecodeTimeAscending ¶
DecodeTimeAscending decodes a time.Time value which was encoded using EncodeTime. The remainder of the input buffer and the decoded time.Time are returned.
func DecodeTimeDescending ¶
DecodeTimeDescending is the descending version of DecodeTimeAscending.
func DecodeUint32Ascending ¶
DecodeUint32Ascending decodes a uint32 from the input buffer, treating the input as a big-endian 4 byte uint32 representation. The remainder of the input buffer and the decoded uint32 are returned.
func DecodeUint32Descending ¶
DecodeUint32Descending decodes a uint32 value which was encoded using EncodeUint32Descending.
func DecodeUint64Ascending ¶
DecodeUint64Ascending decodes a uint64 from the input buffer, treating the input as a big-endian 8 byte uint64 representation. The remainder of the input buffer and the decoded uint64 are returned.
func DecodeUint64Descending ¶
DecodeUint64Descending decodes a uint64 value which was encoded using EncodeUint64Descending.
func DecodeUvarintAscending ¶
DecodeUvarintAscending decodes a varint encoded uint64 from the input buffer. The remainder of the input buffer and the decoded uint64 are returned.
func DecodeUvarintDescending ¶
DecodeUvarintDescending decodes a uint64 value which was encoded using EncodeUvarintDescending.
func DecodeVarintAscending ¶
DecodeVarintAscending decodes a value encode by EncodeVaringAscending.
func DecodeVarintDescending ¶
DecodeVarintDescending decodes a uint64 value which was encoded using EncodeVarintDescending.
func EncodeBytesAscending ¶
EncodeBytesAscending encodes the []byte value using an escape-based encoding. The encoded value is terminated with the sequence "\x00\x01" which is guaranteed to not occur elsewhere in the encoded value. The encoded bytes are append to the supplied buffer and the resulting buffer is returned.
func EncodeBytesDescending ¶
EncodeBytesDescending encodes the []byte value using an escape-based encoding and then inverts (ones complement) the result so that it sorts in reverse order, from larger to smaller lexicographically.
func EncodeDecimalAscending ¶
EncodeDecimalAscending returns the resulting byte slice with the encoded decimal appended to b.
Values are classified as large, medium, or small according to the value of E. If E is 11 or more, the value is large. For E between 0 and 10, the value is medium. For E less than zero, the value is small.
Large positive values are encoded as a single byte 0x22 followed by E as a varint and then M. Medium positive values are a single byte of 0x17+E followed by M. Small positive values are encoded as a single byte 0x16 followed by the ones-complement of the varint for -E followed by M.
Small negative values are encoded as a single byte 0x14 followed by -E as a varint and then the ones-complement of M. Medium negative values are encoded as a byte 0x13-E followed by the ones-complement of M. Large negative values consist of the single byte 0x08 followed by the ones-complement of the varint encoding of E followed by the ones-complement of M.
func EncodeDecimalDescending ¶
EncodeDecimalDescending is the descending version of EncodeDecimalAscending.
func EncodeFloatAscending ¶
EncodeFloatAscending returns the resulting byte slice with the encoded float64 appended to b.
Values are classified as large, medium, or small according to the value of E. If E is 11 or more, the value is large. For E between 0 and 10, the value is medium. For E less than zero, the value is small.
Large positive values are encoded as a single byte 0x22 followed by E as a varint and then M. Medium positive values are a single byte of 0x17+E followed by M. Small positive values are encoded as a single byte 0x16 followed by the ones-complement of the varint for -E followed by M.
Small negative values are encoded as a single byte 0x14 followed by -E as a varint and then the ones-complement of M. Medium negative values are encoded as a byte 0x13-E followed by the ones-complement of M. Large negative values consist of the single byte 0x08 followed by the ones-complement of the varint encoding of E followed by the ones-complement of M.
func EncodeFloatDescending ¶
EncodeFloatDescending is the descending version of EncodeFloatAscending.
func EncodeNotNullAscending ¶
EncodeNotNullAscending encodes a value that is larger than the NULL marker encoded by EncodeNull but less than any encoded value returned by EncodeVarint, EncodeFloat, EncodeBytes or EncodeString.
func EncodeNotNullDescending ¶
EncodeNotNullDescending is the descending equivalent of EncodeNotNullAscending.
func EncodeNullAscending ¶
EncodeNullAscending encodes a NULL value. The encodes bytes are appended to the supplied buffer and the final buffer is returned. The encoded value for a NULL is guaranteed to not be a prefix for the EncodeVarint, EncodeFloat, EncodeBytes and EncodeString encodings.
func EncodeNullDescending ¶
EncodeNullDescending is the descending equivalent of EncodeNullAscending.
func EncodeStringAscending ¶
EncodeStringAscending encodes the string value using an escape-based encoding. See EncodeBytes for details. The encoded bytes are append to the supplied buffer and the resulting buffer is returned.
func EncodeStringDescending ¶
EncodeStringDescending is the descending version of EncodeStringAscending.
func EncodeTimeAscending ¶
EncodeTimeAscending encodes a time value, appends it to the supplied buffer, and returns the final buffer. The encoding is guaranteed to be ordered Such that if t1.Before(t2) then after EncodeTime(b1, t1), and EncodeTime(b2, t1), Compare(b1, b2) < 0. The time zone offset not included in the encoding.
func EncodeTimeDescending ¶
EncodeTimeDescending is the descending version of EncodeTimeAscending.
func EncodeUint32Ascending ¶
EncodeUint32Ascending encodes the uint32 value using a big-endian 8 byte representation. The bytes are appended to the supplied buffer and the final buffer is returned.
func EncodeUint32Descending ¶
EncodeUint32Descending encodes the uint32 value so that it sorts in reverse order, from largest to smallest.
func EncodeUint64Ascending ¶
EncodeUint64Ascending encodes the uint64 value using a big-endian 8 byte representation. The bytes are appended to the supplied buffer and the final buffer is returned.
func EncodeUint64Descending ¶
EncodeUint64Descending encodes the uint64 value so that it sorts in reverse order, from largest to smallest.
func EncodeUvarintAscending ¶
EncodeUvarintAscending encodes the uint64 value using a variable length (length-prefixed) representation. The length is encoded as a single byte indicating the number of encoded bytes (-8) to follow. See EncodeVarintAscending for rationale. The encoded bytes are appended to the supplied buffer and the final buffer is returned.
func EncodeUvarintDescending ¶
EncodeUvarintDescending encodes the uint64 value so that it sorts in reverse order, from largest to smallest.
func EncodeVarintAscending ¶
EncodeVarintAscending encodes the int64 value using a variable length (length-prefixed) representation. The length is encoded as a single byte. If the value to be encoded is negative the length is encoded as 8-numBytes. If the value is positive it is encoded as 8+numBytes. The encoded bytes are appended to the supplied buffer and the final buffer is returned.
func EncodeVarintDescending ¶
EncodeVarintDescending encodes the int64 value so that it sorts in reverse order, from largest to smallest.
func PrettyPrintValue ¶
PrettyPrintValue returns the string representation of all contiguous decodable values in the provided byte slice, separated by a provided separator.
Types ¶
type Direction ¶
type Direction int
Direction for ordering results.
const ( Ascending Direction Descending )
Direction values.