{"modulePath":"github.com/cockroachdb/cockroachdb-parser","version":"v0.25.2","isLatest":true,"isStandardLibrary":false,"goos":"linux","goarch":"amd64","docs":"# package encoding\n\nPackage encoding exposes some utilities for encoding data as bytes.\n\n## Constants\n\n```go\nconst (\n\n\t// IntMin is chosen such that the range of int tags does not overlap the\n\t// ascii character set that is frequently used in testing.\n\tIntMin = 0x80 // 128\n\n\t// IntMax is the maximum int tag value.\n\tIntMax = 0xfd // 253\n\n)\n```\n\n```go\nconst (\n\t// EncodedDurationMaxLen is the largest number of bytes used when encoding a\n\t// Duration.\n\tEncodedDurationMaxLen = 1 + 3*binary.MaxVarintLen64 // 3 varints are encoded.\n\t// EncodedTimeTZMaxLen is the largest number of bytes used when encoding a\n\t// TimeTZ.\n\tEncodedTimeTZMaxLen = 1 + binary.MaxVarintLen64 + binary.MaxVarintLen32\n)\n```\n\n```go\nconst MaxGeoInvertedBBoxLen = 1 + 4*uint64AscendingEncodedLength\n```\nMaxGeoInvertedBBoxLen is the maximum length of the encoded bounding box for geo inverted keys.\n\n```go\nconst MaxNonsortingUvarintLen = 10\n```\nMaxNonsortingUvarintLen is the maximum length of an EncodeNonsortingUvarint encoded value.\n\n```go\nconst MaxNonsortingVarintLen = binary.MaxVarintLen64\n```\nMaxNonsortingVarintLen is the maximum length of an EncodeNonsortingVarint encoded value.\n\n```go\nconst MaxVarintLen = 9\n```\nMaxVarintLen is the maximum length of a value encoded using any of: - EncodeVarintAscending - EncodeVarintDescending - EncodeUvarintAscending - EncodeUvarintDescending\n\n```go\nconst NoColumnID uint32 = 0\n```\nNoColumnID is a sentinel for the EncodeFooValue methods representing an invalid column id.\n\n## Variables\n\n```go\nvar PrettyPrintArrayValueEncoded func([]byte) (string, error)\n```\nPrettyPrintArrayValueEncoded returns a string representation of the encoded array object if possible. It is injected from rowenc/valueside to avoid an import cycle.\n\n```go\nvar PrettyPrintJSONValueEncoded func([]byte) (string, error)\n```\nPrettyPrintJSONValueEncoded returns a string representation of the encoded JSON object. It is injected from util/json to avoid an import cycle.\n\n```go\nvar PrettyPrintTupleValueEncoded func([]byte) ([]byte, string, error)\n```\nPrettyPrintTupleValueEncoded returns a string representation of the encoded tuple object if possible. It is injected from rowenc/valueside to avoid an import cycle.\n\n## Functions\n\n```go\nfunc AddJSONPathSeparator(b []byte) []byte\n```\nAddJSONPathSeparator adds a json path separator to a byte array.\n\n```go\nfunc AddJSONPathTerminator(b []byte) []byte\n```\nAddJSONPathTerminator adds a json path terminator to a byte array.\n\n```go\nfunc BytesNext(b []byte) []byte\n```\nBytesNext returns the next possible byte slice, using the extra capacity of the provided slice if possible, and if not, appending an \\\\x00.\n\n```go\nfunc BytesPrevish(b []byte, length int) []byte\n```\nBytesPrevish returns a previous byte slice in lexicographical ordering. It is impossible in general to find the exact previous byte slice, because it has an infinite number of 0xff bytes at the end, so this returns the nearest previous slice right-padded with 0xff up to length bytes. It may reuse the given slice when possible.\n\n```go\nfunc DecodeBitArrayAscending(b []byte) ([]byte, bitarray.BitArray, error)\n```\nDecodeBitArrayAscending decodes a bit array which was encoded using EncodeBitArrayAscending. The remainder of the input buffer and the decoded bit array are returned.\n\n```go\nfunc DecodeBitArrayDescending(b []byte) ([]byte, bitarray.BitArray, error)\n```\nDecodeBitArrayDescending is the descending version of DecodeBitArrayAscending.\n\n```go\nfunc DecodeBitArrayValue(b []byte) (remaining []byte, d bitarray.BitArray, err error)\n```\nDecodeBitArrayValue decodes a value encoded by EncodeUntaggedBitArrayValue.\n\n```go\nfunc DecodeBoolValue(buf []byte) (remaining []byte, b bool, err error)\n```\nDecodeBoolValue decodes a value encoded by EncodeBoolValue.\n\n```go\nfunc DecodeBox2DAscending(b []byte) ([]byte, geopb.BoundingBox, error)\n```\nDecodeBox2DAscending decodes a box2D object in ascending order.\n\n```go\nfunc DecodeBox2DDescending(b []byte) ([]byte, geopb.BoundingBox, error)\n```\nDecodeBox2DDescending decodes a box2D object in descending order.\n\n```go\nfunc DecodeBytesAscending(b []byte, r []byte) ([]byte, []byte, error)\n```\nDecodeBytesAscending 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.\n\n```go\nfunc DecodeBytesAscendingDeepCopy(b []byte, r []byte) ([]byte, []byte, error)\n```\nDecodeBytesAscendingDeepCopy is the same as DecodeBytesAscending, but the decoded \\[]byte will never alias memory of b.\n\n```go\nfunc DecodeBytesDescending(b []byte, r []byte) ([]byte, []byte, error)\n```\nDecodeBytesDescending 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.\n\nNote that this method internally will always perform a deep copy, so there is no need to introduce DecodeBytesDescendingDeepCopy to mirror DecodeBytesAscendingDeepCopy.\n\n```go\nfunc DecodeBytesValue(b []byte) (remaining []byte, data []byte, err error)\n```\nDecodeBytesValue decodes a value encoded by EncodeBytesValue.\n\n```go\nfunc DecodeDecimalAscending(buf []byte, tmp []byte) ([]byte, apd.Decimal, error)\n```\nDecodeDecimalAscending returns the remaining byte slice after decoding and the decoded decimal from buf.\n\n```go\nfunc DecodeDecimalDescending(buf []byte, tmp []byte) ([]byte, apd.Decimal, error)\n```\nDecodeDecimalDescending decodes decimals encoded with EncodeDecimalDescending.\n\n```go\nfunc DecodeDecimalValue(b []byte) (remaining []byte, d apd.Decimal, err error)\n```\nDecodeDecimalValue decodes a value encoded by EncodeDecimalValue.\n\n```go\nfunc DecodeDurationAscending(b []byte) ([]byte, duration.Duration, error)\n```\nDecodeDurationAscending decodes a duration.Duration value which was encoded using EncodeDurationAscending. The remainder of the input buffer and the decoded duration.Duration are returned.\n\n```go\nfunc DecodeDurationDescending(b []byte) ([]byte, duration.Duration, error)\n```\nDecodeDurationDescending is the descending version of DecodeDurationAscending.\n\n```go\nfunc DecodeDurationValue(b []byte) (remaining []byte, d duration.Duration, err error)\n```\nDecodeDurationValue decodes a value encoded by EncodeUntaggedDurationValue.\n\n```go\nfunc DecodeFloatAscending(buf []byte) ([]byte, float64, error)\n```\nDecodeFloatAscending returns the remaining byte slice after decoding and the decoded float64 from buf.\n\n```go\nfunc DecodeFloatDescending(buf []byte) ([]byte, float64, error)\n```\nDecodeFloatDescending decodes floats encoded with EncodeFloatDescending.\n\n```go\nfunc DecodeFloatValue(b []byte) (remaining []byte, f float64, err error)\n```\nDecodeFloatValue decodes a value encoded by EncodeFloatValue.\n\n```go\nfunc DecodeGeoAscending(b []byte, so *geopb.SpatialObject) ([]byte, error)\n```\nDecodeGeoAscending decodes a geopb.SpatialObject value that was encoded in ascending order back into a geopb.SpatialObject. The so parameter must already be empty/reset.\n\n```go\nfunc DecodeGeoDescending(b []byte, so *geopb.SpatialObject) ([]byte, error)\n```\nDecodeGeoDescending decodes a geopb.SpatialObject value that was encoded in descending order back into a geopb.SpatialObject. The so parameter must already be empty/reset.\n\n```go\nfunc DecodeGeoInvertedKey(b []byte) (loX, loY, hiX, hiY float64, remaining []byte, err error)\n```\nDecodeGeoInvertedKey decodes the bounding box from the geo inverted key. The cellid is skipped in the decoding.\n\n```go\nfunc DecodeIPAddrValue(b []byte) (remaining []byte, u ipaddr.IPAddr, err error)\n```\nDecodeIPAddrValue decodes a value encoded by EncodeIPAddrValue.\n\n```go\nfunc DecodeIfNotNull(b []byte) ([]byte, bool)\n```\nDecodeIfNotNull 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.\n\n```go\nfunc DecodeIfNull(b []byte) ([]byte, bool)\n```\nDecodeIfNull 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.\n\n```go\nfunc DecodeIntValue(b []byte) (remaining []byte, i int64, err error)\n```\nDecodeIntValue decodes a value encoded by EncodeIntValue.\n\n```go\nfunc DecodeIntoNonsortingDecimal(dec *apd.Decimal, buf []byte, tmp []byte) error\n```\nDecodeIntoNonsortingDecimal is like DecodeNonsortingDecimal, but it operates on the passed-in \\*apd.Decimal instead of producing a new one.\n\n```go\nfunc DecodeIntoUntaggedDecimalValue(d *apd.Decimal, b []byte) (remaining []byte, err error)\n```\nDecodeIntoUntaggedDecimalValue is like DecodeUntaggedDecimalValue except it writes the new Decimal into the input apd.Decimal pointer, which must be non-nil.\n\n```go\nfunc DecodeJSONValueLength(buf []byte, dir Direction) ([]byte, int64, error)\n```\n\n```go\nfunc DecodeNonsortingDecimal(buf []byte, tmp []byte) (apd.Decimal, error)\n```\nDecodeNonsortingDecimal returns the decoded decimal from buf encoded with EncodeNonsortingDecimal. buf is assumed to contain only the encoded decimal, as the function does not know from the encoding itself what the length of the encoded value is.\n\n```go\nfunc DecodeNonsortingStdlibUvarint(\n\tbuf []byte,\n) (remaining []byte, length int, value uint64, err error)\n```\nDecodeNonsortingStdlibUvarint decodes a value encoded with binary.PutUvarint. It returns the length of the encoded varint and value.\n\n```go\nfunc DecodeNonsortingStdlibVarint(b []byte) (remaining []byte, length int, value int64, err error)\n```\nDecodeNonsortingStdlibVarint decodes a value encoded by EncodeNonsortingVarint. It returns the length of the encoded varint and value.\n\n```go\nfunc DecodeNonsortingUvarint(buf []byte) (remaining []byte, length int, value uint64, err error)\n```\nDecodeNonsortingUvarint decodes a value encoded by EncodeNonsortingUvarint. It returns the length of the encoded varint and value.\n\n```go\nfunc DecodeTimeAscending(b []byte) ([]byte, time.Time, error)\n```\nDecodeTimeAscending decodes a time.Time value which was encoded using EncodeTime. The remainder of the input buffer and the decoded time.Time are returned.\n\n```go\nfunc DecodeTimeDescending(b []byte) ([]byte, time.Time, error)\n```\nDecodeTimeDescending is the descending version of DecodeTimeAscending.\n\n```go\nfunc DecodeTimeTZAscending(b []byte) ([]byte, timetz.TimeTZ, error)\n```\nDecodeTimeTZAscending decodes a timetz.TimeTZ value which was encoded using encodeTimeTZ. The remainder of the input buffer and the decoded timetz.TimeTZ are returned.\n\n```go\nfunc DecodeTimeTZDescending(b []byte) ([]byte, timetz.TimeTZ, error)\n```\nDecodeTimeTZDescending is the descending version of DecodeTimeTZAscending.\n\n```go\nfunc DecodeTimeTZValue(b []byte) (remaining []byte, t timetz.TimeTZ, err error)\n```\nDecodeTimeTZValue decodes a value encoded by EncodeTimeTZValue.\n\n```go\nfunc DecodeTimeValue(b []byte) (remaining []byte, t time.Time, err error)\n```\nDecodeTimeValue decodes a value encoded by EncodeTimeValue.\n\n```go\nfunc DecodeUUIDValue(b []byte) (remaining []byte, u uuid.UUID, err error)\n```\nDecodeUUIDValue decodes a value encoded by EncodeUUIDValue.\n\n```go\nfunc DecodeUint16Ascending(b []byte) ([]byte, uint16, error)\n```\nDecodeUint16Ascending decodes a uint16 from the input buffer, treating the input as a big-endian 2 byte uint16 representation. The remainder of the input buffer and the decoded uint16 are returned.\n\n```go\nfunc DecodeUint32Ascending(b []byte) ([]byte, uint32, error)\n```\nDecodeUint32Ascending 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.\n\n```go\nfunc DecodeUint32Descending(b []byte) ([]byte, uint32, error)\n```\nDecodeUint32Descending decodes a uint32 value which was encoded using EncodeUint32Descending.\n\n```go\nfunc DecodeUint64Ascending(b []byte) ([]byte, uint64, error)\n```\nDecodeUint64Ascending 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.\n\n```go\nfunc DecodeUint64Descending(b []byte) ([]byte, uint64, error)\n```\nDecodeUint64Descending decodes a uint64 value which was encoded using EncodeUint64Descending.\n\n```go\nfunc DecodeUnsafeStringAscending(b []byte, r []byte) ([]byte, string, error)\n```\nDecodeUnsafeStringAscending 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. Note that the returned string may share storage with the input buffer.\n\n```go\nfunc DecodeUnsafeStringAscendingDeepCopy(b []byte, r []byte) ([]byte, string, error)\n```\nDecodeUnsafeStringAscendingDeepCopy is the same as DecodeUnsafeStringAscending but the returned string will never share storage with the input buffer.\n\n```go\nfunc DecodeUnsafeStringDescending(b []byte, r []byte) ([]byte, string, error)\n```\nDecodeUnsafeStringDescending 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. Note that the returned string may share storage with the input buffer.\n\n```go\nfunc DecodeUntaggedBitArrayValue(b []byte) (remaining []byte, d bitarray.BitArray, err error)\n```\nDecodeUntaggedBitArrayValue decodes a value encoded by EncodeUntaggedBitArrayValue.\n\n```go\nfunc DecodeUntaggedBox2DValue(b []byte) (remaining []byte, box geopb.BoundingBox, err error)\n```\nDecodeUntaggedBox2DValue decodes a value encoded by EncodeUntaggedBox2DValue.\n\n```go\nfunc DecodeUntaggedBytesValue(b []byte) (remaining, data []byte, err error)\n```\nDecodeUntaggedBytesValue decodes a value encoded by EncodeUntaggedBytesValue.\n\n```go\nfunc DecodeUntaggedDecimalValue(b []byte) (remaining []byte, d apd.Decimal, err error)\n```\nDecodeUntaggedDecimalValue decodes a value encoded by EncodeUntaggedDecimalValue.\n\n```go\nfunc DecodeUntaggedDurationValue(b []byte) (remaining []byte, d duration.Duration, err error)\n```\nDecodeUntaggedDurationValue decodes a value encoded by EncodeUntaggedDurationValue.\n\n```go\nfunc DecodeUntaggedFloat32Value(b []byte) (remaining []byte, f float32, err error)\n```\nDecodeUntaggedFloat32Value decodes a value encoded by EncodeUntaggedFloat32Value.\n\n```go\nfunc DecodeUntaggedFloatValue(b []byte) (remaining []byte, f float64, err error)\n```\nDecodeUntaggedFloatValue decodes a value encoded by EncodeUntaggedFloatValue.\n\n```go\nfunc DecodeUntaggedGeoValue(b []byte, so *geopb.SpatialObject) (remaining []byte, err error)\n```\nDecodeUntaggedGeoValue decodes a value encoded by EncodeUntaggedGeoValue into the provided geopb.SpatialObject reference. The so parameter must already be empty/reset.\n\n```go\nfunc DecodeUntaggedIPAddrValue(b []byte) (remaining []byte, u ipaddr.IPAddr, err error)\n```\nDecodeUntaggedIPAddrValue decodes a value encoded by EncodeUntaggedIPAddrValue.\n\n```go\nfunc DecodeUntaggedIntValue(b []byte) (remaining []byte, i int64, err error)\n```\nDecodeUntaggedIntValue decodes a value encoded by EncodeUntaggedIntValue.\n\n```go\nfunc DecodeUntaggedTimeTZValue(b []byte) (remaining []byte, t timetz.TimeTZ, err error)\n```\nDecodeUntaggedTimeTZValue decodes a value encoded by EncodeUntaggedTimeTZValue.\n\n```go\nfunc DecodeUntaggedTimeValue(b []byte) (remaining []byte, t time.Time, err error)\n```\nDecodeUntaggedTimeValue decodes a value encoded by EncodeUntaggedTimeValue.\n\n```go\nfunc DecodeUntaggedUUIDValue(b []byte) (remaining []byte, u uuid.UUID, err error)\n```\nDecodeUntaggedUUIDValue decodes a value encoded by EncodeUntaggedUUIDValue.\n\n```go\nfunc DecodeUvarintAscending(b []byte) ([]byte, uint64, error)\n```\nDecodeUvarintAscending decodes a uint64 encoded uint64 from the input buffer. The remainder of the input buffer and the decoded uint64 are returned.\n\n```go\nfunc DecodeUvarintDescending(b []byte) ([]byte, uint64, error)\n```\nDecodeUvarintDescending decodes a uint64 value which was encoded using EncodeUvarintDescending.\n\n```go\nfunc DecodeVarintAscending(b []byte) ([]byte, int64, error)\n```\nDecodeVarintAscending decodes a value encoded by EncodeVarintAscending.\n\n```go\nfunc DecodeVarintDescending(b []byte) ([]byte, int64, error)\n```\nDecodeVarintDescending decodes a int64 value which was encoded using EncodeVarintDescending.\n\n```go\nfunc DecodeVoidAscendingOrDescending(b []byte) ([]byte, error)\n```\nDecodeVoidAscendingOrDescending decodes a void  (valid for both ascending and descending order).\n\n```go\nfunc EncLenUvarintAscending(v uint64) int\n```\nEncLenUvarintAscending returns the encoding length for EncodeUvarintAscending without actually encoding.\n\n```go\nfunc EncLenUvarintDescending(v uint64) int\n```\nEncLenUvarintDescending returns the encoding length for EncodeUvarintDescending without actually encoding.\n\n```go\nfunc EncodeArrayAscending(b []byte) []byte\n```\nEncodeArrayAscending encodes a value used to signify membership of an array for JSON objects.\n\n```go\nfunc EncodeArrayKeyMarker(buf []byte, dir Direction) []byte\n```\nEncodeArrayKeyMarker adds the array key encoding marker to buf and returns the new buffer.\n\n```go\nfunc EncodeArrayKeyTerminator(buf []byte, dir Direction) []byte\n```\nEncodeArrayKeyTerminator adds the array key terminator to buf and returns the new buffer.\n\n```go\nfunc EncodeArrayValue(appendTo []byte, colIDDelta uint32, data []byte) []byte\n```\nEncodeArrayValue encodes a byte array value with its value tag, appends it to the supplied buffer, and returns the final buffer.\n\n```go\nfunc EncodeBitArrayAscending(b []byte, d bitarray.BitArray) []byte\n```\nEncodeBitArrayAscending encodes a bitarray.BitArray value, appends it to the supplied buffer, and returns the final buffer. The encoding is guaranteed to be ordered such that if t1.Compare(t2) \\\u003c 0 (or = 0 or \u003e 0) then bytes.Compare will order them the same way after encoding.\n\nThe encoding uses varint encoding for each word of the backing array. This is a trade-off. The alternative is to encode the entire backing word array as a byte array, using byte array encoding and escaped special bytes (via  \\`encodeBytesAscendingWithoutTerminatorOrPrefix\\`). There are two arguments against this alternative:\n\n  - the bytes must be encoded big endian, but the most common architectures running CockroachDB are little-endian, so the bytes would need to be reordered prior to encoding.\n  - when decoding or skipping over a value, the decoding/sizing loop would need to look at every byte of the encoding to find the terminator.\n\nIn contrast, the chosen encoding using varints is endianness-agnostic and enables fast decoding/skipping thanks ot the tag bytes.\n\n```go\nfunc EncodeBitArrayDescending(b []byte, d bitarray.BitArray) []byte\n```\nEncodeBitArrayDescending is the descending version of EncodeBitArrayAscending.\n\n```go\nfunc EncodeBitArrayValue(appendTo []byte, colIDDelta uint32, d bitarray.BitArray) []byte\n```\nEncodeBitArrayValue encodes a bit array value with its value tag, appends it to the supplied buffer, and returns the final buffer.\n\n```go\nfunc EncodeBoolValue(appendTo []byte, colIDDelta uint32, b bool) []byte\n```\nEncodeBoolValue encodes a bool value, appends it to the supplied buffer, and returns the final buffer.\n\n```go\nfunc EncodeBox2DAscending(b []byte, box geopb.BoundingBox) ([]byte, error)\n```\nEncodeBox2DAscending encodes a bounding box in ascending order.\n\n```go\nfunc EncodeBox2DDescending(b []byte, box geopb.BoundingBox) ([]byte, error)\n```\nEncodeBox2DDescending encodes a bounding box in descending order.\n\n```go\nfunc EncodeBox2DValue(appendTo []byte, colIDDelta uint32, b geopb.BoundingBox) ([]byte, error)\n```\nEncodeBox2DValue encodes a geopb.BoundingBox with its value tag, appends it to the supplied buffer and returns the final buffer.\n\n```go\nfunc EncodeBytesAscending(b []byte, data []byte) []byte\n```\nEncodeBytesAscending 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.\n\n```go\nfunc EncodeBytesDescending(b []byte, data []byte) []byte\n```\nEncodeBytesDescending 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.\n\n```go\nfunc EncodeBytesSize(data []byte) int\n```\nEncodeBytesSize returns the size of the \\[]byte value when encoded using EncodeBytes{Ascending,Descending}. The function accounts for the encoding marker, escaping, and the terminator.\n\n```go\nfunc EncodeBytesValue(appendTo []byte, colIDDelta uint32, data []byte) []byte\n```\nEncodeBytesValue encodes a byte array value with its value tag, appends it to the supplied buffer, and returns the final buffer.\n\n```go\nfunc EncodeDecimalAscending(appendTo []byte, d *apd.Decimal) []byte\n```\nEncodeDecimalAscending returns the resulting byte slice with the encoded decimal appended to the given buffer.\n\nValues 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.\n\nLarge positive values are encoded as a single byte 0x34 followed by E as a varint and then M. Medium positive values are a single byte of 0x29+E followed by M. Small positive values are encoded as a single byte 0x28 followed by a descending varint encoding for -E followed by M.\n\nSmall negative values are encoded as a single byte 0x26 followed by -E as a varint and then the ones-complement of M. Medium negative values are encoded as a byte 0x25-E followed by the ones-complement of M. Large negative values consist of the single byte 0x1a followed by a descending  varint encoding of E followed by the ones-complement of M.\n\n```go\nfunc EncodeDecimalDescending(appendTo []byte, d *apd.Decimal) []byte\n```\nEncodeDecimalDescending is the descending version of EncodeDecimalAscending.\n\n```go\nfunc EncodeDecimalValue(appendTo []byte, colIDDelta uint32, d *apd.Decimal) []byte\n```\nEncodeDecimalValue encodes an apd.Decimal value with its value tag, appends it to the supplied buffer, and returns the final buffer.\n\n```go\nfunc EncodeDurationAscending(b []byte, d duration.Duration) ([]byte, error)\n```\nEncodeDurationAscending encodes a duration.Duration value, appends it to the supplied buffer, and returns the final buffer. The encoding is guaranteed to be ordered such that if t1.Compare(t2) \\\u003c 0 (or = 0 or \u003e 0) then bytes.Compare will order them the same way after encoding.\n\n```go\nfunc EncodeDurationDescending(b []byte, d duration.Duration) ([]byte, error)\n```\nEncodeDurationDescending is the descending version of EncodeDurationAscending.\n\n```go\nfunc EncodeDurationValue(appendTo []byte, colIDDelta uint32, d duration.Duration) []byte\n```\nEncodeDurationValue encodes a duration.Duration value with its value tag, appends it to the supplied buffer, and returns the final buffer.\n\n```go\nfunc EncodeEmptyArray(b []byte) []byte\n```\nEncodeEmptyArray returns a byte array b with a byte to signify an empty array.\n\n```go\nfunc EncodeFalseAscending(b []byte) []byte\n```\nEncodeFalseAscending encodes the boolean value false for use with JSON inverted indexes.\n\n```go\nfunc EncodeFloatAscending(b []byte, f float64) []byte\n```\nEncodeFloatAscending returns the resulting byte slice with the encoded float64 appended to b. The encoded format for a float64 value f is, for positive f, the encoding of the 64 bits (in IEEE 754 format) re-interpreted as an int64 and encoded using EncodeUint64Ascending. For negative f, we keep the sign bit and invert all other bits, encoding this value using EncodeUint64Descending. This approach was inspired by in github.com/google/orderedcode/orderedcode.go.\n\nOne of five single-byte prefix tags are appended to the front of the encoding. These tags enforce logical ordering of keys for both ascending and descending encoding directions. The tags split the encoded floats into five categories: - NaN for an ascending encoding direction - Negative valued floats - Zero (positive and negative) - Positive valued floats - NaN for a descending encoding direction This ordering ensures that NaNs are always sorted first in either encoding direction, and that after them a logical ordering is followed.\n\n```go\nfunc EncodeFloatDescending(b []byte, f float64) []byte\n```\nEncodeFloatDescending is the descending version of EncodeFloatAscending.\n\n```go\nfunc EncodeFloatValue(appendTo []byte, colIDDelta uint32, f float64) []byte\n```\nEncodeFloatValue encodes a float value with its value tag, appends it to the supplied buffer, and returns the final buffer.\n\n```go\nfunc EncodeGeoAscending(b []byte, curveIndex uint64, so *geopb.SpatialObject) ([]byte, error)\n```\nEncodeGeoAscending encodes a geopb.SpatialObject value in ascending order and returns the new buffer. It is sorted by the given curve index, followed by the bytes of the spatial object.\n\n```go\nfunc EncodeGeoDescending(b []byte, curveIndex uint64, so *geopb.SpatialObject) ([]byte, error)\n```\nEncodeGeoDescending encodes a geopb.SpatialObject value in descending order and returns the new buffer. It is sorted by the given curve index, followed by the bytes of the spatial object.\n\n```go\nfunc EncodeGeoInvertedAscending(b []byte) []byte\n```\nEncodeGeoInvertedAscending appends the geoInvertedIndexMarker.\n\n```go\nfunc EncodeGeoInvertedBBox(b []byte, loX, loY, hiX, hiY float64) []byte\n```\nEncodeGeoInvertedBBox encodes the bounding box for the geo inverted index.\n\n```go\nfunc EncodeGeoValue(appendTo []byte, colIDDelta uint32, so *geopb.SpatialObject) ([]byte, error)\n```\nEncodeGeoValue encodes a geopb.SpatialObject value with its value tag, appends it to the supplied buffer, and returns the final buffer.\n\n```go\nfunc EncodeIPAddrValue(appendTo []byte, colIDDelta uint32, u ipaddr.IPAddr) []byte\n```\nEncodeIPAddrValue encodes a ipaddr.IPAddr value with its value tag, appends it to the supplied buffer, and returns the final buffer.\n\n```go\nfunc EncodeIntValue(appendTo []byte, colIDDelta uint32, i int64) []byte\n```\nEncodeIntValue encodes an int value with its value tag, appends it to the supplied buffer, and returns the final buffer.\n\n```go\nfunc EncodeJSONArrayKeyMarker(buf []byte, dir Direction, arrayLength int64) []byte\n```\nEncodeJSONArrayKeyMarker adds a JSON Array key encoding marker to buf and returns the new buffer.\n\n```go\nfunc EncodeJSONAscending(b []byte) []byte\n```\nEncodeJSONAscending encodes a JSON Type. The encoded bytes are appended to the supplied buffer and the final buffer is returned.\n\n```go\nfunc EncodeJSONEmptyArray(b []byte) []byte\n```\nEncodeJSONEmptyArray returns a byte array b with a byte to signify an empty JSON array.\n\n```go\nfunc EncodeJSONEmptyObject(b []byte) []byte\n```\nEncodeJSONEmptyObject returns a byte array b with a byte to signify an empty JSON object.\n\n```go\nfunc EncodeJSONFalseKeyMarker(buf []byte, dir Direction) []byte\n```\nEncodeJSONFalseKeyMarker adds a JSON False key encoding marker to buf and returns the new buffer.\n\n```go\nfunc EncodeJSONKeyStringAscending(b []byte, s string, end bool) []byte\n```\nEncodeJSONKeyStringAscending encodes the JSON key string value with a JSON specific escaped terminator. This allows us to encode keys in the same number of bytes as a string, while at the same time giving us a sentinel to identify JSON keys. The end parameter is used to determine if this is the last key in a a JSON path. If it is we don't add a separator after it.\n\n```go\nfunc EncodeJSONKeyTerminator(buf []byte, dir Direction) []byte\n```\nEncodeJSONKeyTerminator adds a JSON Key terminator to buf and returns the buffer.\n\n```go\nfunc EncodeJSONNullKeyMarker(buf []byte, dir Direction) []byte\n```\nEncodeJSONNullKeyMarker adds a JSON Null key encoding marker to buf and returns the new buffer.\n\n```go\nfunc EncodeJSONNumberKeyMarker(buf []byte, dir Direction) []byte\n```\nEncodeJSONNumberKeyMarker adds a JSON Number key encoding marker to buf and returns the new buffer.\n\n```go\nfunc EncodeJSONObjectKeyMarker(buf []byte, dir Direction) []byte\n```\nEncodeJSONObjectKeyMarker adds a JSON Object key encoding marker to buf and returns the new buffer.\n\n```go\nfunc EncodeJSONObjectSpanStartAscending(b []byte) []byte\n```\nEncodeJSONObjectSpanStartAscending encodes the first possible value for JSON objects, which is \\\\x00\\\\xff. Non-objects (i.e., scalars and arrays) will start with \\\\x00\\\\x01 or \\\\x00\\\\x03 (see AddJSONPathTerminator and EncodeArrayAscending), so all objects will be ordered after them.\n\n```go\nfunc EncodeJSONStringKeyMarker(buf []byte, dir Direction) []byte\n```\nEncodeJSONStringKeyMarker adds a JSON String key encoding marker to buf and returns the new buffer.\n\n```go\nfunc EncodeJSONTrueKeyMarker(buf []byte, dir Direction) []byte\n```\nEncodeJSONTrueKeyMarker adds a JSON True key encoding marker to buf and returns the new buffer.\n\n```go\nfunc EncodeJSONValue(appendTo []byte, colIDDelta uint32, data []byte) []byte\n```\nEncodeJSONValue encodes an already-byte-encoded JSON value with no value tag but with a length prefix, appends it to the supplied buffer, and returns the final buffer.\n\n```go\nfunc EncodeJSONValueLength(buf []byte, dir Direction, v int64) []byte\n```\n\n```go\nfunc EncodeNextBytesAscending(b []byte, data []byte) []byte\n```\nEncodeNextBytesAscending encodes the \\[]byte value with an extra 0x00 byte appended before encoding. It's equivalent to\n\n\tEncodeBytesAscending(b, append(data, 0x00))\n\nbut may avoid an allocation when the data slice does not have additional capacity.\n\n```go\nfunc EncodeNextBytesSize(data []byte) int\n```\nEncodeNextBytesSize returns the size of the \\[]byte value when suffixed with a zero byte and then encoded using EncodeNextBytes{Ascending,Descending}. The function accounts for the encoding marker, escaping, and the terminator.\n\n```go\nfunc EncodeNonsortingDecimal(b []byte, d *apd.Decimal) []byte\n```\nEncodeNonsortingDecimal returns the resulting byte slice with the encoded decimal appended to b. The encoding is limited compared to standard encodings in this package in that\n\n  - It will not sort lexicographically\n  - It does not encode its length or terminate itself, so decoding functions must be provided the exact encoded bytes\n\nThe encoding assumes that any number can be written as ±0.xyz... \\* 10^exp, where xyz is a digit string, x != 0, and the last decimal in xyz is also not 0.\n\nThe encoding uses its first byte to split decimals into 7 distinct ordered groups (no NaN or Infinity support yet). The groups can be seen in encoding.go's const definition. Following this, the absolute value of the exponent of the decimal (as defined above) is encoded as an unsigned varint. Second, the absolute value of the digit string is added as a big-endian byte slice.\n\nAll together, the encoding looks like:\n\n\t\u003cmarker\u003e\u003cuvarint exponent\u003e\u003cbig-endian encoded big.Int\u003e.\n\nThe markers are shared with the sorting decimal encoding as follows:\n\n\tdecimalNaN              -\u003e decimalNaN\n\tdecimalNegativeInfinity -\u003e decimalNegativeInfinity\n\tdecimalNegLarge         -\u003e decimalNegValPosExp\n\tdecimalNegMedium        -\u003e decimalNegValZeroExp\n\tdecimalNegSmall         -\u003e decimalNegValNegExp\n\tdecimalZero             -\u003e decimalZero\n\tdecimalPosSmall         -\u003e decimalPosValNegExp\n\tdecimalPosMedium        -\u003e decimalPosValZeroExp\n\tdecimalPosLarge         -\u003e decimalPosValPosExp\n\tdecimalInfinity         -\u003e decimalInfinity\n\tdecimalNaNDesc          -\u003e decimalNaNDesc\n\n```go\nfunc EncodeNonsortingStdlibVarint(appendTo []byte, x int64) []byte\n```\nEncodeNonsortingStdlibVarint encodes an int value using encoding/binary, appends it to the supplied buffer, and returns the final buffer.\n\n```go\nfunc EncodeNonsortingUvarint(appendTo []byte, x uint64) []byte\n```\nEncodeNonsortingUvarint encodes a uint64, appends it to the supplied buffer, and returns the final buffer. The encoding used is similar to encoding/binary, but with the most significant bits first:\n\n  - Unsigned integers are serialized 7 bits at a time, starting with the most significant bits.\n  - The most significant bit (msb) in each output byte indicates if there is a continuation byte (msb = 1).\n\n```go\nfunc EncodeNotNullAscending(b []byte) []byte\n```\nEncodeNotNullAscending 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.\n\n```go\nfunc EncodeNotNullDescending(b []byte) []byte\n```\nEncodeNotNullDescending is the descending equivalent of EncodeNotNullAscending.\n\n```go\nfunc EncodeNotNullValue(appendTo []byte, colIDDelta uint32) []byte\n```\nEncodeNotNullValue encodes a not null value, appends it to the supplied buffer, and returns the final buffer.\n\n```go\nfunc EncodeNullAscending(b []byte) []byte\n```\nEncodeNullAscending 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.\n\n```go\nfunc EncodeNullDescending(b []byte) []byte\n```\nEncodeNullDescending is the descending equivalent of EncodeNullAscending.\n\n```go\nfunc EncodeNullValue(appendTo []byte, colIDDelta uint32) []byte\n```\nEncodeNullValue encodes a null value, appends it to the supplied buffer, and returns the final buffer.\n\n```go\nfunc EncodeNullWithinArrayKey(buf []byte, dir Direction) []byte\n```\nEncodeNullWithinArrayKey encodes NULL within a key encoded array.\n\n```go\nfunc EncodePGVectorValue(appendTo []byte, colIDDelta uint32, data []byte) []byte\n```\nEncodePGVectorValue encodes an already-byte-encoded PGVector value with no value tag but with a length prefix, appends it to the supplied buffer, and returns the final buffer.\n\n```go\nfunc EncodeStringAscending(b []byte, s string) []byte\n```\nEncodeStringAscending 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.\n\n```go\nfunc EncodeStringDescending(b []byte, s string) []byte\n```\nEncodeStringDescending is the descending version of EncodeStringAscending.\n\n```go\nfunc EncodeTSQueryValue(appendTo []byte, colIDDelta uint32, data []byte) []byte\n```\nEncodeTSQueryValue encodes an already-byte-encoded TSQuery value with no value tag but with a length prefix, appends it to the supplied buffer, and returns the final buffer.\n\n```go\nfunc EncodeTSVectorValue(appendTo []byte, colIDDelta uint32, data []byte) []byte\n```\nEncodeTSVectorValue encodes an already-byte-encoded TSVector value with no value tag but with a length prefix, appends it to the supplied buffer, and returns the final buffer.\n\n```go\nfunc EncodeTimeAscending(b []byte, t time.Time) []byte\n```\nEncodeTimeAscending 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, t2), Compare(b1, b2) \\\u003c 0. The time zone offset not included in the encoding.\n\n```go\nfunc EncodeTimeDescending(b []byte, t time.Time) []byte\n```\nEncodeTimeDescending is the descending version of EncodeTimeAscending.\n\n```go\nfunc EncodeTimeTZAscending(b []byte, t timetz.TimeTZ) []byte\n```\nEncodeTimeTZAscending encodes a timetz.TimeTZ value and 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 encodeTimeTZ(b1, t1) and encodeTimeTZ(b2, t2), Compare(b1, b2) \\\u003c 0. The time zone offset is included in the encoding.\n\n```go\nfunc EncodeTimeTZDescending(b []byte, t timetz.TimeTZ) []byte\n```\nEncodeTimeTZDescending is the descending version of EncodeTimeTZAscending.\n\n```go\nfunc EncodeTimeTZValue(appendTo []byte, colIDDelta uint32, t timetz.TimeTZ) []byte\n```\nEncodeTimeTZValue encodes a timetz.TimeTZ value with its value tag, appends it to the supplied buffer, and returns the final buffer.\n\n```go\nfunc EncodeTimeValue(appendTo []byte, colIDDelta uint32, t time.Time) []byte\n```\nEncodeTimeValue encodes a time.Time value with its value tag, appends it to the supplied buffer, and returns the final buffer.\n\n```go\nfunc EncodeTrueAscending(b []byte) []byte\n```\nEncodeTrueAscending encodes the boolean value true for use with JSON inverted indexes.\n\n```go\nfunc EncodeUUIDValue(appendTo []byte, colIDDelta uint32, u uuid.UUID) []byte\n```\nEncodeUUIDValue encodes a uuid.UUID value with its value tag, appends it to the supplied buffer, and returns the final buffer.\n\n```go\nfunc EncodeUint16Ascending(b []byte, v uint16) []byte\n```\nEncodeUint16Ascending encodes the uint16 value using a big-endian 2 byte representation. The bytes are appended to the supplied buffer and the final buffer is returned.\n\n```go\nfunc EncodeUint32Ascending(b []byte, v uint32) []byte\n```\nEncodeUint32Ascending encodes the uint32 value using a big-endian 4 byte representation. The bytes are appended to the supplied buffer and the final buffer is returned.\n\n```go\nfunc EncodeUint32Descending(b []byte, v uint32) []byte\n```\nEncodeUint32Descending encodes the uint32 value so that it sorts in reverse order, from largest to smallest.\n\n```go\nfunc EncodeUint64Ascending(b []byte, v uint64) []byte\n```\nEncodeUint64Ascending 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.\n\n```go\nfunc EncodeUint64Descending(b []byte, v uint64) []byte\n```\nEncodeUint64Descending encodes the uint64 value so that it sorts in reverse order, from largest to smallest.\n\n```go\nfunc EncodeUntaggedBitArrayValue(appendTo []byte, d bitarray.BitArray) []byte\n```\nEncodeUntaggedBitArrayValue encodes a bit array value, appends it to the supplied buffer, and returns the final buffer.\n\n```go\nfunc EncodeUntaggedBox2DValue(appendTo []byte, b geopb.BoundingBox) ([]byte, error)\n```\nEncodeUntaggedBox2DValue encodes a geopb.BoundingBox value, appends it to the supplied buffer, and returns the final buffer.\n\n```go\nfunc EncodeUntaggedBytesValue(appendTo []byte, data []byte) []byte\n```\nEncodeUntaggedBytesValue encodes a byte array value, appends it to the supplied buffer, and returns the final buffer.\n\n```go\nfunc EncodeUntaggedDecimalValue(appendTo []byte, d *apd.Decimal) []byte\n```\nEncodeUntaggedDecimalValue encodes an apd.Decimal value, appends it to the supplied buffer, and returns the final buffer.\n\n```go\nfunc EncodeUntaggedDurationValue(appendTo []byte, d duration.Duration) []byte\n```\nEncodeUntaggedDurationValue encodes a duration.Duration value, appends it to the supplied buffer, and returns the final buffer.\n\n```go\nfunc EncodeUntaggedFloat32Value(appendTo []byte, f float32) []byte\n```\nEncodeUntaggedFloat32Value encodes a float32 value, appends it to the supplied buffer, and returns the final buffer.\n\n```go\nfunc EncodeUntaggedFloatValue(appendTo []byte, f float64) []byte\n```\nEncodeUntaggedFloatValue encodes a float value, appends it to the supplied buffer, and returns the final buffer.\n\n```go\nfunc EncodeUntaggedGeoValue(appendTo []byte, so *geopb.SpatialObject) ([]byte, error)\n```\nEncodeUntaggedGeoValue encodes a geopb.SpatialObject value, appends it to the supplied buffer, and returns the final buffer.\n\n```go\nfunc EncodeUntaggedIPAddrValue(appendTo []byte, u ipaddr.IPAddr) []byte\n```\nEncodeUntaggedIPAddrValue encodes a ipaddr.IPAddr value, appends it to the supplied buffer, and returns the final buffer.\n\n```go\nfunc EncodeUntaggedIntValue(appendTo []byte, i int64) []byte\n```\nEncodeUntaggedIntValue encodes an int value, appends it to the supplied buffer, and returns the final buffer.\n\n```go\nfunc EncodeUntaggedTimeTZValue(appendTo []byte, t timetz.TimeTZ) []byte\n```\nEncodeUntaggedTimeTZValue encodes a time.Time value, appends it to the supplied buffer, and returns the final buffer.\n\n```go\nfunc EncodeUntaggedTimeValue(appendTo []byte, t time.Time) []byte\n```\nEncodeUntaggedTimeValue encodes a time.Time value, appends it to the supplied buffer, and returns the final buffer.\n\n```go\nfunc EncodeUntaggedUUIDValue(appendTo []byte, u uuid.UUID) []byte\n```\nEncodeUntaggedUUIDValue encodes a uuid.UUID value, appends it to the supplied buffer, and returns the final buffer.\n\n```go\nfunc EncodeUvarintAscending(b []byte, v uint64) []byte\n```\nEncodeUvarintAscending 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.\n\n```go\nfunc EncodeUvarintDescending(b []byte, v uint64) []byte\n```\nEncodeUvarintDescending encodes the uint64 value so that it sorts in reverse order, from largest to smallest.\n\n```go\nfunc EncodeValueTag(appendTo []byte, colIDDelta uint32, typ Type) []byte\n```\nEncodeValueTag encodes the prefix that is used by each of the EncodeFooValue methods.\n\nThe prefix uses varints to encode a column id and type, packing them into a single byte when they're small (colIDDelta \\\u003c 8 and typ \\\u003c 15). This works by shifting the colIDDelta \"left\" by 4 and putting any type less than 15 in the low bytes. The result is uvarint encoded and fits in one byte if the original column id fit in 3 bits. If it doesn't fit in one byte, the most significant bits spill to the \"left\", leaving the type bits always at the very \"right\".\n\nIf the type is \u003e 15, the reserved sentinel of 15 is placed in the type bits and a uvarint follows with the type value. This means that there are always one or two uvarints.\n\nTogether, this means the everything but the last byte of the first uvarint can be dropped if the column id isn't needed.\n\n```go\nfunc EncodeVarintAscending(b []byte, v int64) []byte\n```\nEncodeVarintAscending 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.\n\n```go\nfunc EncodeVarintDescending(b []byte, v int64) []byte\n```\nEncodeVarintDescending encodes the int64 value so that it sorts in reverse order, from largest to smallest.\n\n```go\nfunc EncodeVoidAscendingOrDescending(b []byte) []byte\n```\nEncodeVoidAscendingOrDescending encodes a void (valid for both ascending and descending order).\n\n```go\nfunc EncodeVoidValue(appendTo []byte, colIDDelta uint32) []byte\n```\nEncodeVoidValue encodes a void with its value tag, appends it to the supplied buffer and returns the final buffer.\n\n```go\nfunc EncodedLengthUvarintAscending(v uint64) int\n```\nEncodedLengthUvarintAscending returns the length of the variable length representation, i.e. the number of bytes appended by EncodeUvarintAscending.\n\n```go\nfunc GetMultiVarintLen(b []byte, num int) (int, error)\n```\nGetMultiVarintLen find the length of \\\u003cnum\u003e encoded varints that follow a 1-byte tag.\n\n```go\nfunc GetUvarintLen(b []byte) (int, error)\n```\nGetUvarintLen is similar to DecodeUvarintAscending except that it returns the length of the prefix that encodes a uint64 value in bytes without actually decoding the value. An error is returned if b does not contain a valid encoding of an unsigned int datum.\n\n```go\nfunc IsArrayKeyDone(buf []byte, dir Direction) bool\n```\nIsArrayKeyDone returns if the first byte in the input is the array terminator for the input direction.\n\n```go\nfunc IsJSONKeyDone(buf []byte, dir Direction) bool\n```\nisJSONKeyDone returns if the first byte in the input is the JSON terminator for the input direction.\n\n```go\nfunc IsNextByteArrayEncodedNull(buf []byte, dir Direction) bool\n```\nIsNextByteArrayEncodedNull returns if the first byte in the input is the NULL encoded byte within an array key.\n\n```go\nfunc PeekLength(b []byte) (int, error)\n```\nPeekLength returns the length of the encoded value at the start of b.  Note: if this function succeeds, it's not a guarantee that decoding the value will succeed. PeekLength is meant to be used on key encoded data only.\n\n```go\nfunc PeekLengthNonsortingUvarint(buf []byte) int\n```\nPeekLengthNonsortingUvarint returns the length of the value that starts at the beginning of buf and was encoded by EncodeNonsortingUvarint.\n\n```go\nfunc PeekValueLength(b []byte) (typeOffset int, length int, err error)\n```\nPeekValueLength returns the length of the encoded value at the start of b. Note: If this function succeeds, it's not a guarantee that decoding the value will succeed.\n\n\\`b\\` can point either at beginning of the \"full tag\" with the column id, or it can point to the beginning of the type part of the tag, as indicated by the \\`typeOffset\\` returned by this or DecodeValueTag.\n\nThe length returned is the full length of the encoded value, including the entire tag.\n\n```go\nfunc PeekValueLengthWithOffsetsAndType(b []byte, dataOffset int, typ Type) (length int, err error)\n```\nPeekValueLengthWithOffsetsAndType is the same as PeekValueLength, except it expects a dataOffset and typ value from a previous call to DecodeValueTag on its input byte slice. Use this if you've already called DecodeValueTag on the input for another reason, to avoid it getting called twice.\n\n```go\nfunc PrettyPrintValue(buf *redact.StringBuilder, valDirs []Direction, b []byte, sep string)\n```\nPrettyPrintValue returns the string representation of all contiguous decodable values in the provided byte slice, separated by a provided separator. The directions each value is encoded may be provided. If valDirs is nil, all values are decoded and printed with the default direction (ascending).\n\n```go\nfunc PrettyPrintValueEncoded(b []byte) ([]byte, string, error)\n```\nPrettyPrintValueEncoded returns a string representation of the first decodable value in the provided byte slice, along with the remaining byte slice after decoding.\n\n```go\nfunc PrintableBytes(b []byte) bool\n```\nPrintableBytes returns true iff the given byte array is a valid UTF-8 sequence and it is printable.\n\n```go\nfunc PutUint16Ascending(b []byte, v uint16, idx int) []byte\n```\nPutUint16Ascending encodes the uint16 value using a big-endian 2 byte representation at the specified index, lengthening the input slice if necessary.\n\n```go\nfunc PutUint32Ascending(b []byte, v uint32, idx int) []byte\n```\nPutUint32Ascending encodes the uint32 value using a big-endian 4 byte representation at the specified index, lengthening the input slice if necessary.\n\n```go\nfunc UndoPrefixEnd(b []byte) (_ []byte, ok bool)\n```\nUndoPrefixEnd is a partial inverse for roachpb.Key.PrefixEnd.\n\nIn general, we can't undo PrefixEnd because it is lossy; we don't know how many FFs were stripped from the original key. For example:\n\n  - key:            01 02 03 FF FF\n  - PrefixEnd:      01 02 04\n  - UndoPrefixEnd:  01 02 03\n\nSome keys are not possible results of PrefixEnd; in particular, PrefixEnd keys never end in 00. If an impossible key is passed, the second return value is false.\n\nSpecifically, calling UndoPrefixEnd will reverse the effects of calling a PrefixEnd on a byte sequence, except when the byte sequence represents a maximal prefix (i.e., 0xff...). This is because PrefixEnd is a lossy operation: PrefixEnd(0xff) returns 0xff rather than wrapping around to the minimal prefix 0x00. For consistency, UndoPrefixEnd is also lossy: UndoPrefixEnd(0x00) returns 0x00 rather than wrapping around to the maximal prefix 0xff.\n\nFormally:\n\n\tPrefixEnd(UndoPrefixEnd(p)) = p for all non-minimal prefixes p\n\tUndoPrefixEnd(PrefixEnd(p)) = p for all non-maximal prefixes p\n\nA minimal prefix is any prefix that consists only of one or more 0x00 bytes; analogously, a maximal prefix is any prefix that consists only of one or more 0xff bytes.\n\nUndoPrefixEnd is implemented here to avoid a circular dependency on roachpb, but arguably belongs in a byte-manipulation utility package.\n\n```go\nfunc Unsafe(args any) any\n```\n\n```go\nfunc UnsafeConvertBytesToString(b []byte) string\n```\nUnsafeConvertBytesToString performs an unsafe conversion from a \\[]byte to a string. The returned string will share the underlying memory with the \\[]byte which thus allows the string to be mutable through the \\[]byte. We're careful to use this method only in situations in which the \\[]byte will not be modified.\n\n```go\nfunc UnsafeConvertStringToBytes(s string) []byte\n```\nUnsafeConvertStringToBytes converts a string to a byte array to be used with string encoding functions. Note that the output byte array should not be modified if the input string is expected to be used again - doing so could violate Go semantics.\n\n```go\nfunc UpperBoundNonsortingDecimalSize(d *apd.Decimal) int\n```\nUpperBoundNonsortingDecimalSize returns the upper bound number of bytes that the decimal will need for the non-sorting encoding.\n\n```go\nfunc ValidateAndConsumeArrayKeyMarker(buf []byte, dir Direction) ([]byte, error)\n```\nValidateAndConsumeArrayKeyMarker checks that the marker at the front of buf is valid for an array of the given direction, and consumes it if so. It returns an error if the tag is invalid.\n\n```go\nfunc ValidateDecodeBytesAscending(b []byte) ([]byte, error)\n```\nValidateDecodeBytesAscending is like DecodeBytesAscending, but discards the decoded bytes. The remainder of the input buffer is returned on success.\n\n```go\nfunc WordLen(nat []big.Word) int\n```\nWordLen returns the size in bytes of the given array of Words.\n\n## Types\n\n```go\ntype Direction int\n```\nDirection for ordering results.\n\n```go\nconst (\n\tAscending Direction\n\tDescending\n)\n```\nDirection values.\n\n```go\ntype Type encodingtype.T\n```\nType represents the type of a value encoded by Encode{Null,NotNull,Varint,Uvarint,Float,Bytes}.\n\n```go\nconst (\n\tUnknown   Type = 0\n\tNull      Type = 1\n\tNotNull   Type = 2\n\tInt       Type = 3\n\tFloat     Type = 4\n\tDecimal   Type = 5\n\tBytes     Type = 6\n\tBytesDesc Type = 7 // Bytes encoded descendingly\n\tTime      Type = 8\n\tDuration  Type = 9\n\tTrue      Type = 10\n\tFalse     Type = 11\n\tUUID      Type = 12\n\tArray     Type = 13\n\tIPAddr    Type = 14\n\t// SentinelType is used for bit manipulation to check if the encoded type\n\t// value requires more than 4 bits, and thus will be encoded in two bytes. It\n\t// is not used as a type value, and thus intentionally overlaps with the\n\t// subsequent type value. The 'Type' annotation is intentionally omitted here.\n\tSentinelType        = 15\n\tJSON           Type = 15\n\tTuple          Type = 16\n\tBitArray       Type = 17\n\tBitArrayDesc   Type = 18 // BitArray encoded descendingly\n\tTimeTZ         Type = 19\n\tGeo            Type = 20\n\tGeoDesc        Type = 21\n\tArrayKeyAsc    Type = 22 // Array key encoding\n\tArrayKeyDesc   Type = 23 // Array key encoded descendingly\n\tBox2D          Type = 24\n\tVoid           Type = 25\n\tTSQuery        Type = 26\n\tTSVector       Type = 27\n\tJSONNull       Type = 28\n\tJSONNullDesc   Type = 29\n\tJSONString     Type = 30\n\tJSONStringDesc Type = 31\n\tJSONNumber     Type = 32\n\tJSONNumberDesc Type = 33\n\tJSONFalse      Type = 34\n\tJSONFalseDesc  Type = 35\n\tJSONTrue       Type = 36\n\tJSONTrueDesc   Type = 37\n\tJSONArray      Type = 38\n\tJSONArrayDesc  Type = 39\n\tJSONObject     Type = 40\n\tJSONObjectDesc Type = 41\n\t// Special case\n\tJsonEmptyArray     Type = 42\n\tJsonEmptyArrayDesc Type = 43\n\tPGVector           Type = 44\n)\n```\nType values. TODO(dan, arjun): Make this into a proto enum. The 'Type' annotations are necessary for producing stringer-generated values.\n\n```go\nfunc DecodeValueTag(\n\tb []byte,\n) (typeOffset int, dataOffset int, colIDDelta uint32, typ Type, err error)\n```\nDecodeValueTag decodes a value encoded by EncodeValueTag, used as a prefix in each of the other EncodeFooValue methods.\n\nThe tag is structured such that the encoded column id can be dropped from the front by removing the first \\`typeOffset\\` bytes. DecodeValueTag, PeekValueLength and each of the DecodeFooValue methods will still work as expected with \\`b\\[typeOffset:]\\`. (Except, obviously, the column id is no longer encoded so if this suffix is passed back to DecodeValueTag, the returned colIDDelta should be discarded.)\n\nConcretely:\n\n\tb := ...\n\ttypeOffset, _, colIDDelta, typ, err := DecodeValueTag(b)\n\t_, _, _, typ, err := DecodeValueTag(b[typeOffset:])\n\nwill return the same typ and err and\n\n\tDecodeFooValue(b)\n\tDecodeFooValue(b[typeOffset:])\n\nwill return the same thing. PeekValueLength works as expected with either of \\`b\\` or \\`b\\[typeOffset:]\\`.\n\n```go\nfunc PeekType(b []byte) Type\n```\nPeekType peeks at the type of the value encoded at the start of b.\n\n```go\nfunc PrettyPrintValuesWithTypes(valDirs []Direction, b []byte) (vals []string, types []Type)\n```\nPrettyPrintValuesWithTypes returns a slice containing each contiguous decodable value in the provided byte slice along with a slice containing the type of each value. The directions each value is encoded may be provided. If valDirs is nil, all values are decoded and printed with the default direction (ascending).\n\n```go\nfunc ValidateAndConsumeJSONKeyMarker(buf []byte, dir Direction) ([]byte, Type, error)\n```\nValidateAndConsumeJSONKeyMarker checks that the marker at the front of buf is valid/invalid for a given JSON value for the given direction. If the JSON marker is valid, the marker is consumed and the remaining bytes in the array are returned.\n\n```go\nfunc (i Type) String() string\n```\n\n","path":"github.com/cockroachdb/cockroachdb-parser/pkg/util/encoding","name":"encoding","synopsis":"Package encoding exposes some utilities for encoding data as bytes.","isRedistributable":true}
