codec

package
v0.0.0-...-959c02d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const EdgeKeyLen = 1 + 8 + 8 + 1 + 8 /*dstVertexID*/
View Source
const VertexKeyLen = 1 + 8 + 8 /*vertexID*/

Variables

This section is empty.

Functions

func DecodeBytes

func DecodeBytes(b []byte, buf []byte) ([]byte, []byte, error)

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

func DecodeBytesDesc(b []byte, buf []byte) ([]byte, []byte, error)

DecodeBytesDesc decodes bytes which is encoded by EncodeBytesDesc before, returns the leftover bytes and decoded value if no error.

func DecodeCmpUintToInt

func DecodeCmpUintToInt(u uint64) int64

DecodeCmpUintToInt decodes the u that encoded by EncodeIntToCmpUint

func DecodeComparableUvarint

func DecodeComparableUvarint(b []byte) ([]byte, uint64, error)

DecodeComparableUvarint decodes mem-comparable uvarint.

func DecodeComparableVarint

func DecodeComparableVarint(b []byte) ([]byte, int64, error)

DecodeComparableVarint decodes mem-comparable varint.

func DecodeFloat

func DecodeFloat(b []byte) ([]byte, float64, error)

DecodeFloat decodes a float from a byte slice generated with EncodeFloat before.

func DecodeFloatDesc

func DecodeFloatDesc(b []byte) ([]byte, float64, error)

DecodeFloatDesc decodes a float from a byte slice generated with EncodeFloatDesc before.

func DecodeInt

func DecodeInt(b []byte) ([]byte, int64, error)

DecodeInt decodes value encoded by EncodeInt before. It returns the leftover un-decoded slice, decoded value if no error.

func DecodeIntDesc

func DecodeIntDesc(b []byte) ([]byte, int64, error)

DecodeIntDesc decodes value encoded by EncodeInt before. It returns the leftover un-decoded slice, decoded value if no error.

func DecodeUint

func DecodeUint(b []byte) ([]byte, uint64, error)

DecodeUint decodes value encoded by EncodeUint before. It returns the leftover un-decoded slice, decoded value if no error.

func DecodeUintDesc

func DecodeUintDesc(b []byte) ([]byte, uint64, error)

DecodeUintDesc decodes value encoded by EncodeInt before. It returns the leftover un-decoded slice, decoded value if no error.

func DecodeUvarint

func DecodeUvarint(b []byte) ([]byte, uint64, error)

DecodeUvarint decodes value encoded by EncodeUvarint before. It returns the leftover un-decoded slice, decoded value if no error.

func DecodeVarint

func DecodeVarint(b []byte) ([]byte, int64, error)

DecodeVarint decodes value encoded by EncodeVarint before. It returns the leftover un-decoded slice, decoded value if no error.

func EdgeNonUniqueIndexKey

func EdgeNonUniqueIndexKey(graphID, indexID, srcVertexID, dstVertexID int64) []byte

EdgeNonUniqueIndexKey encodes the non-unique index key described as above.

func EncodeBytes

func EncodeBytes(b []byte, data []byte) []byte

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

func EncodeBytesDesc(b []byte, data []byte) []byte

EncodeBytesDesc first encodes bytes using EncodeBytes, then bitwise reverses encoded value to guarantee the encoded value is in descending order for comparison.

func EncodeBytesExt

func EncodeBytesExt(b []byte, data []byte, isRawKv bool) []byte

EncodeBytesExt is an extension of `EncodeBytes`, which will not encode for `isRawKv = true` but just append `data` to `b`.

func EncodeComparableUvarint

func EncodeComparableUvarint(b []byte, v uint64) []byte

EncodeComparableUvarint encodes uint64 into mem-comparable bytes.

func EncodeComparableVarint

func EncodeComparableVarint(b []byte, v int64) []byte

EncodeComparableVarint encodes an int64 to a mem-comparable bytes.

func EncodeFloat

func EncodeFloat(b []byte, v float64) []byte

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

func EncodeFloatDesc(b []byte, v float64) []byte

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

func EncodeInt(b []byte, v int64) []byte

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

func EncodeIntDesc(b []byte, v int64) []byte

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

func EncodeIntToCmpUint(v int64) uint64

EncodeIntToCmpUint make int v to comparable uint type

func EncodeUint

func EncodeUint(b []byte, v uint64) []byte

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

func EncodeUintDesc(b []byte, v uint64) []byte

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

func EncodeUvarint(b []byte, v uint64) []byte

EncodeUvarint appends the encoded value to slice b and returns the appended slice. Note that the encoded result is not memcomparable.

func EncodeVarint

func EncodeVarint(b []byte, v int64) []byte

EncodeVarint appends the encoded value to slice b and returns the appended slice. Note that the encoded result is not memcomparable.

func EncodedBytesLength

func EncodedBytesLength(dataLen int) int

EncodedBytesLength returns the length of data after encoded

func IncomingEdgeKey

func IncomingEdgeKey(graphID, srcVertexID, dstVertexID int64) []byte

IncomingEdgeKey encodes the incoming edge key.

The key format is: ${Prefix}${GraphID}${DstVertexID}${IncomingEdgeSep}${SrcVertexID}.

func LabelKey

func LabelKey(graphID, labelID, vertexID, dstVertexID int64) []byte

LabelKey returns the encoded key of specified graph/label.

func LabelValue

func LabelValue() []byte

LabelValue returns a zero which is represents the flag byte of normal value.

func OutgoingEdgeKey

func OutgoingEdgeKey(graphID, srcVertexID, dstVertexID int64) []byte

OutgoingEdgeKey encodes the outgoing edge key.

The key format is: ${Prefix}${GraphID}${SrcVertexID}${outgoingEdgeSep}${DstVertexID}.

func ParseEdgeNonUniqueIndexKey

func ParseEdgeNonUniqueIndexKey(key []byte) (graphID, indexID, srcVertexID, dstVertexID int64, err error)

ParseEdgeNonUniqueIndexKey parses the edge non-unique key.

func ParseIncomingEdgeKey

func ParseIncomingEdgeKey(key []byte) (graphID, srcVertexID, dstVertexID int64, err error)

ParseIncomingEdgeKey parse the incoming edge key.

func ParseOutgoingEdgeKey

func ParseOutgoingEdgeKey(key []byte) (graphID, srcVertexID, dstVertexID int64, err error)

ParseOutgoingEdgeKey parse the outgoing edge key.

func ParseUniqueIndexKey

func ParseUniqueIndexKey(key []byte) (graphID, indexID int64, typ byte, err error)

ParseUniqueIndexKey parse the unique key.

func ParseVertexKey

func ParseVertexKey(key []byte) (graphID, vertexID int64, err error)

ParseVertexKey parses the vertex key.

func ParseVertexNonUniqueIndexKey

func ParseVertexNonUniqueIndexKey(key []byte) (graphID, indexID, vertexID int64, err error)

ParseVertexNonUniqueIndexKey parses the vertex non-unique key.

func UniqueIndexKey

func UniqueIndexKey(graphID, indexID int64, typ byte) []byte

UniqueIndexKey encodes the unique index key described as above.

func VertexKey

func VertexKey(graphID, vertexID int64) []byte

VertexKey encodes the vertex key. The key format is: ${Prefix}${GraphID}${VertexID}.

func VertexNonUniqueIndexKey

func VertexNonUniqueIndexKey(graphID, indexID, vertexID int64) []byte

VertexNonUniqueIndexKey encodes the non-unique index key described as above.

Types

type PropertyDecoder

type PropertyDecoder struct {
	// contains filtered or unexported fields
}

PropertyDecoder is used to decode value bytes into datum

func NewPropertyDecoder

func NewPropertyDecoder(labels []*model.LabelInfo, properties []*model.PropertyInfo) *PropertyDecoder

func (*PropertyDecoder) Decode

func (d *PropertyDecoder) Decode(rowData []byte) (map[uint16]struct{}, map[uint16]datum.Datum, error)

type PropertyEncoder

type PropertyEncoder struct {
	// contains filtered or unexported fields
}

PropertyEncoder is used to encode datums into value bytes.

func (*PropertyEncoder) Encode

func (e *PropertyEncoder) Encode(buf []byte, labelIDs, propertyIDs []uint16, values []datum.Datum) ([]byte, error)

Encode encodes properties into a value bytes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL