Documentation ¶
Index ¶
- Constants
- func ConvertByCollation(raw []byte, tp *types.FieldType) []byte
- func ConvertByCollationStr(str string, tp *types.FieldType) string
- func CutColumnID(b []byte) (remain []byte, n int64, err error)
- func CutOne(b []byte) (data []byte, remain []byte, err error)
- func Decode(b []byte, size int) ([]types.Datum, error)
- func DecodeAsDateTime(b []byte, tp byte, loc *time.Location) (remain []byte, d types.Datum, err error)
- func DecodeAsFloat32(b []byte, tp byte) (remain []byte, d types.Datum, err error)
- func DecodeBytes(b []byte, buf []byte) ([]byte, []byte, error)
- func DecodeBytesDesc(b []byte, buf []byte) ([]byte, []byte, error)
- func DecodeCmpUintToInt(u uint64) int64
- func DecodeCompactBytes(b []byte) ([]byte, []byte, error)
- func DecodeComparableUvarint(b []byte) ([]byte, uint64, error)
- func DecodeComparableVarint(b []byte) ([]byte, int64, error)
- func DecodeDecimal(b []byte) ([]byte, *types.MyDecimal, int, int, error)
- func DecodeFloat(b []byte) ([]byte, float64, error)
- func DecodeFloatDesc(b []byte) ([]byte, float64, error)
- func DecodeInt(b []byte) ([]byte, int64, error)
- func DecodeIntDesc(b []byte) ([]byte, int64, error)
- func DecodeOne(b []byte) (remain []byte, d types.Datum, err error)
- func DecodeRange(b []byte, size int, idxColumnTypes []byte, loc *time.Location) ([]types.Datum, []byte, error)
- func DecodeUint(b []byte) ([]byte, uint64, error)
- func DecodeUintDesc(b []byte) ([]byte, uint64, error)
- func DecodeUvarint(b []byte) ([]byte, uint64, error)
- func DecodeVarint(b []byte) ([]byte, int64, error)
- func EncodeBytes(b []byte, data []byte) []byte
- func EncodeBytesDesc(b []byte, data []byte) []byte
- func EncodeBytesExt(b []byte, data []byte, isRawKv bool) []byte
- func EncodeCompactBytes(b []byte, data []byte) []byte
- func EncodeComparableUvarint(b []byte, v uint64) []byte
- func EncodeComparableVarint(b []byte, v int64) []byte
- func EncodeDecimal(b []byte, dec *types.MyDecimal, precision, frac int) ([]byte, error)
- func EncodeFloat(b []byte, v float64) []byte
- func EncodeFloatDesc(b []byte, v float64) []byte
- func EncodeInt(b []byte, v int64) []byte
- func EncodeIntDesc(b []byte, v int64) []byte
- func EncodeIntToCmpUint(v int64) uint64
- func EncodeKey(sc *stmtctx.StatementContext, b []byte, v ...types.Datum) ([]byte, error)
- func EncodeMySQLTime(sc *stmtctx.StatementContext, t types.Time, tp byte, b []byte) (_ []byte, err error)
- func EncodeUint(b []byte, v uint64) []byte
- func EncodeUintDesc(b []byte, v uint64) []byte
- func EncodeUvarint(b []byte, v uint64) []byte
- func EncodeValue(sc *stmtctx.StatementContext, b []byte, v ...types.Datum) ([]byte, error)
- func EncodeVarint(b []byte, v int64) []byte
- func EncodedBytesLength(dataLen int) int
- func EqualChunkRow(sc *stmtctx.StatementContext, row1 chunk.Row, allTypes1 []*types.FieldType, ...) (bool, error)
- func EstimateValueSize(sc *stmtctx.StatementContext, val types.Datum) (int, error)
- func HashChunkColumns(sc *stmtctx.StatementContext, h []hash.Hash64, chk *chunk.Chunk, ...) (err error)
- func HashChunkRow(sc *stmtctx.StatementContext, w io.Writer, row chunk.Row, ...) (err error)
- func HashChunkSelected(sc *stmtctx.StatementContext, h []hash.Hash64, chk *chunk.Chunk, ...) (err error)
- func HashCode(b []byte, d types.Datum) []byte
- func HashGroupKey(sc *stmtctx.StatementContext, n int, col *chunk.Column, buf [][]byte, ...) ([][]byte, error)
- func SetRawValues(data []byte, values []types.Datum) error
- type Decoder
Constants ¶
const (
NilFlag byte = 0
)
First byte in the encoded value which specifies the encoding type.
Variables ¶
This section is empty.
Functions ¶
func ConvertByCollation ¶
ConvertByCollation converts these bytes according to its collation.
func ConvertByCollationStr ¶
ConvertByCollationStr converts this string according to its collation.
func CutColumnID ¶
CutColumnID cuts the column ID from b. It will return the remains as byte slice and column ID
func CutOne ¶
CutOne cuts the first encoded value from b. It will return the first encoded item and the remains as byte slice.
func Decode ¶
Decode decodes values from a byte slice generated with EncodeKey or EncodeValue before. size is the size of decoded datum slice.
func DecodeAsDateTime ¶
func DecodeAsDateTime(b []byte, tp byte, loc *time.Location) (remain []byte, d types.Datum, err error)
DecodeAsDateTime decodes on datum from []byte of `KindMysqlTime`.
func DecodeAsFloat32 ¶
DecodeAsFloat32 decodes value for mysql.TypeFloat
func DecodeBytes ¶
DecodeBytes decodes bytes which is encoded by EncodeBytes before, returns the leftover bytes and decoded value if no error. `buf` is used to buffer data to avoid the cost of makeslice in decodeBytes when DecodeBytes is called by Decoder.DecodeOne.
func DecodeBytesDesc ¶
DecodeBytesDesc decodes bytes which is encoded by EncodeBytesDesc before, returns the leftover bytes and decoded value if no error.
func DecodeCmpUintToInt ¶
DecodeCmpUintToInt decodes the u that encoded by EncodeIntToCmpUint
func DecodeCompactBytes ¶
DecodeCompactBytes decodes bytes which is encoded by EncodeCompactBytes before.
func DecodeComparableUvarint ¶
DecodeComparableUvarint decodes mem-comparable uvarint.
func DecodeComparableVarint ¶
DecodeComparableVarint decodes mem-comparable varint.
func DecodeDecimal ¶
DecodeDecimal decodes bytes to decimal.
func DecodeFloat ¶
DecodeFloat decodes a float from a byte slice generated with EncodeFloat before.
func DecodeFloatDesc ¶
DecodeFloatDesc decodes a float from a byte slice generated with EncodeFloatDesc before.
func DecodeInt ¶
DecodeInt decodes value encoded by EncodeInt before. It returns the leftover un-decoded slice, decoded value if no error.
func DecodeIntDesc ¶
DecodeIntDesc decodes value encoded by EncodeInt before. It returns the leftover un-decoded slice, decoded value if no error.
func DecodeOne ¶
DecodeOne decodes on datum from a byte slice generated with EncodeKey or EncodeValue.
func DecodeRange ¶
func DecodeRange(b []byte, size int, idxColumnTypes []byte, loc *time.Location) ([]types.Datum, []byte, error)
DecodeRange decodes the range values from a byte slice that generated by EncodeKey. It handles some special values like `MinNotNull` and `MaxValueDatum`. loc can be nil and only used in when the corresponding type is `mysql.TypeTimestamp`.
func DecodeUint ¶
DecodeUint decodes value encoded by EncodeUint before. It returns the leftover un-decoded slice, decoded value if no error.
func DecodeUintDesc ¶
DecodeUintDesc decodes value encoded by EncodeInt before. It returns the leftover un-decoded slice, decoded value if no error.
func DecodeUvarint ¶
DecodeUvarint decodes value encoded by EncodeUvarint before. It returns the leftover un-decoded slice, decoded value if no error.
func DecodeVarint ¶
DecodeVarint decodes value encoded by EncodeVarint before. It returns the leftover un-decoded slice, decoded value if no error.
func EncodeBytes ¶
EncodeBytes guarantees the encoded value is in ascending order for comparison, encoding with the following rule:
[group1][marker1]...[groupN][markerN] group is 8 bytes slice which is padding with 0. marker is `0xFF - padding 0 count`
For example:
[] -> [0, 0, 0, 0, 0, 0, 0, 0, 247] [1, 2, 3] -> [1, 2, 3, 0, 0, 0, 0, 0, 250] [1, 2, 3, 0] -> [1, 2, 3, 0, 0, 0, 0, 0, 251] [1, 2, 3, 4, 5, 6, 7, 8] -> [1, 2, 3, 4, 5, 6, 7, 8, 255, 0, 0, 0, 0, 0, 0, 0, 0, 247]
Refer: https://github.com/facebook/mysql-5.6/wiki/MyRocks-record-format#memcomparable-format
func EncodeBytesDesc ¶
EncodeBytesDesc first encodes bytes using EncodeBytes, then bitwise reverses encoded value to guarantee the encoded value is in descending order for comparison.
func EncodeBytesExt ¶
EncodeBytesExt is an extension of `EncodeBytes`, which will not encode for `isRawKv = true` but just append `data` to `b`.
func EncodeCompactBytes ¶
EncodeCompactBytes joins bytes with its length into a byte slice. It is more efficient in both space and time compare to EncodeBytes. Note that the encoded result is not memcomparable.
func EncodeComparableUvarint ¶
EncodeComparableUvarint encodes uint64 into mem-comparable bytes.
func EncodeComparableVarint ¶
EncodeComparableVarint encodes an int64 to a mem-comparable bytes.
func EncodeDecimal ¶
EncodeDecimal encodes a decimal into a byte slice which can be sorted lexicographically later.
func EncodeFloat ¶
EncodeFloat encodes a float v into a byte slice which can be sorted lexicographically later. EncodeFloat guarantees that the encoded value is in ascending order for comparison.
func EncodeFloatDesc ¶
EncodeFloatDesc encodes a float v into a byte slice which can be sorted lexicographically later. EncodeFloatDesc guarantees that the encoded value is in descending order for comparison.
func EncodeInt ¶
EncodeInt appends the encoded value to slice b and returns the appended slice. EncodeInt guarantees that the encoded value is in ascending order for comparison.
func EncodeIntDesc ¶
EncodeIntDesc appends the encoded value to slice b and returns the appended slice. EncodeIntDesc guarantees that the encoded value is in descending order for comparison.
func EncodeIntToCmpUint ¶
EncodeIntToCmpUint make int v to comparable uint type
func EncodeKey ¶
EncodeKey appends the encoded values to byte slice b, returns the appended slice. It guarantees the encoded value is in ascending order for comparison. For decimal type, datum must set datum's length and frac.
func EncodeMySQLTime ¶
func EncodeMySQLTime(sc *stmtctx.StatementContext, t types.Time, tp byte, b []byte) (_ []byte, err error)
EncodeMySQLTime encodes datum of `KindMysqlTime` to []byte.
func EncodeUint ¶
EncodeUint appends the encoded value to slice b and returns the appended slice. EncodeUint guarantees that the encoded value is in ascending order for comparison.
func EncodeUintDesc ¶
EncodeUintDesc appends the encoded value to slice b and returns the appended slice. EncodeUintDesc guarantees that the encoded value is in descending order for comparison.
func EncodeUvarint ¶
EncodeUvarint appends the encoded value to slice b and returns the appended slice. Note that the encoded result is not memcomparable.
func EncodeValue ¶
EncodeValue appends the encoded values to byte slice b, returning the appended slice. It does not guarantee the order for comparison.
func EncodeVarint ¶
EncodeVarint appends the encoded value to slice b and returns the appended slice. Note that the encoded result is not memcomparable.
func EncodedBytesLength ¶
EncodedBytesLength returns the length of data after encoded
func EqualChunkRow ¶
func EqualChunkRow(sc *stmtctx.StatementContext, row1 chunk.Row, allTypes1 []*types.FieldType, colIdx1 []int, row2 chunk.Row, allTypes2 []*types.FieldType, colIdx2 []int, ) (bool, error)
EqualChunkRow returns a boolean reporting whether row1 and row2 with their types and column index are logically equal.
func EstimateValueSize ¶
EstimateValueSize uses to estimate the value size of the encoded values.
func HashChunkColumns ¶
func HashChunkColumns(sc *stmtctx.StatementContext, h []hash.Hash64, chk *chunk.Chunk, tp *types.FieldType, colIdx int, buf []byte, isNull []bool) (err error)
HashChunkColumns writes the encoded value of each row's column, which of index `colIdx`, to h.
func HashChunkRow ¶
func HashChunkRow(sc *stmtctx.StatementContext, w io.Writer, row chunk.Row, allTypes []*types.FieldType, colIdx []int, buf []byte) (err error)
HashChunkRow writes the encoded values to w. If two rows are logically equal, it will generate the same bytes.
func HashChunkSelected ¶
func HashChunkSelected(sc *stmtctx.StatementContext, h []hash.Hash64, chk *chunk.Chunk, tp *types.FieldType, colIdx int, buf []byte, isNull, sel []bool, ignoreNull bool) (err error)
HashChunkSelected writes the encoded value of selected row's column, which of index `colIdx`, to h. sel indicates which rows are selected. If it is nil, all rows are selected.
func HashCode ¶
HashCode encodes a Datum into a unique byte slice. It is mostly the same as EncodeValue, but it doesn't contain truncation or verification logic in order to make the encoding lossless.
Types ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder is used to decode value to chunk.
func NewDecoder ¶
NewDecoder creates a Decoder.