Documentation ¶
Overview ¶
Package varint is used for the OrientDB schemaless serialization where variable size integers are used with zigzag encoding to convert negative integers to a positive unsigned int format so that smaller integers (whether negative or positive) can be transmitted in less than 4 bytes on the wire. The variable length zigzag encoding used by OrientDB is the same as that used for Google's Protocol Buffers and is documented here: https://developers.google.com/protocol-buffers/docs/encoding?csw=1
Index ¶
- func EncodeAndWriteVarInt32(wtr io.Writer, n int32) error
- func EncodeAndWriteVarInt64(wtr io.Writer, n int64) error
- func IsFinalVarIntByte(b byte) bool
- func ReadBytes(buf io.Reader) ([]byte, error)
- func ReadString(buf io.Reader) (string, error)
- func ReadVarIntAndDecode32(r io.Reader) (int32, error)
- func ReadVarIntAndDecode64(r io.Reader) (int64, error)
- func ReadVarIntToUint(r io.Reader) (uint64, error)
- func VarintEncode(w io.Writer, v uint64) error
- func WriteBytes(wtr io.Writer, bs []byte) (err error)
- func WriteString(wtr io.Writer, s string) error
- func ZigzagDecodeInt32(n uint32) int32
- func ZigzagDecodeInt64(n uint64) int64
- func ZigzagEncodeUInt32(n int32) uint32
- func ZigzagEncodeUInt64(n int64) uint64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncodeAndWriteVarInt32 ¶
EncodeAndWriteVarInt32 zigzag encodes the int32 passed in and then translates that number to a protobuf/OrientDB varint, writing the bytes of that varint to the io.Writer.
func EncodeAndWriteVarInt64 ¶
EncodeAndWriteVarInt64 zigzag encodes the int64 passed in and then translates that number to a protobuf/OrientDB varint, writing the bytes of that varint to the io.Writer.
func IsFinalVarIntByte ¶
IsFinalVarIntByte checks the high bit of byte `b` to determine whether it is the last byte in an OrientDB varint encoding. If the high bit is zero, true is returned.
func ReadBytes ¶
varint.ReadBytes, like rw.ReadBytes, first reads a length from the input buffer and then that number of bytes into a []byte from the input buffer. The difference is that the integer indicating the length of the byte array to follow is a zigzag encoded varint.
func ReadString ¶
varint.ReadString, like rw.ReadString, first reads a length from the input buffer and then that number of bytes (of ASCII chars) into a string from the input buffer. The difference is that the integer indicating the length of the byte array to follow is a zigzag encoded varint.
func ReadVarIntAndDecode32 ¶
ReadVarIntAndDecode32 reads a varint from buf to a uint32 and then zigzag decodes it to an int32 value.
func ReadVarIntAndDecode64 ¶
ReadVarIntAndDecode64 reads a varint from r to a uint64 and then zigzag decodes it to an int64 value.
func ReadVarIntToUint ¶
ReadVarIntToUint reads a variable length integer from the input buffer. The inflated integer is written is returned as a uint64 value. This method only "inflates" the varint into a uint64; it does NOT zigzag decode it.
func WriteBytes ¶
varint.WriteBytes, like rw.WriteBytes, first reads a length from the input buffer and then that number of bytes into a []byte from the input buffer. The difference is that the integer indicating the length of the byte array to follow is a zigzag encoded varint.
func WriteString ¶
varint.WriteString, like rw.WriteString, first reads a length from the input buffer and then that number of bytes (of ASCII chars) into a string from the input buffer. The difference is that the integer indicating the length of the byte array to follow is a zigzag encoded varint.
func ZigzagDecodeInt32 ¶
func ZigzagDecodeInt64 ¶
func ZigzagEncodeUInt32 ¶
func ZigzagEncodeUInt64 ¶
Types ¶
This section is empty.