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

    Constants

    This section is empty.

    Variables

    This section is empty.

    Functions

    func EncodeAndWriteVarInt32

    func EncodeAndWriteVarInt32(wtr io.Writer, n int32) error

      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

      func EncodeAndWriteVarInt64(wtr io.Writer, n int64) error

        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

        func IsFinalVarIntByte(b byte) bool

          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

          func ReadBytes(buf io.Reader) ([]byte, error)

            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

            func ReadString(buf io.Reader) (string, error)

              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

              func ReadVarIntAndDecode32(r io.Reader) (int32, error)

                ReadVarIntAndDecode32 reads a varint from buf to a uint32 and then zigzag decodes it to an int32 value.

                func ReadVarIntAndDecode64

                func ReadVarIntAndDecode64(r io.Reader) (int64, error)

                  ReadVarIntAndDecode64 reads a varint from r to a uint64 and then zigzag decodes it to an int64 value.

                  func ReadVarIntToUint

                  func ReadVarIntToUint(r io.Reader) (uint64, error)

                    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 VarintEncode

                    func VarintEncode(w io.Writer, v uint64) error

                      REMOVE ME?

                      func WriteBytes

                      func WriteBytes(wtr io.Writer, bs []byte) (err error)

                        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

                        func WriteString(wtr io.Writer, s string) error

                          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 ZigzagDecodeInt32(n uint32) int32

                          func ZigzagDecodeInt64

                          func ZigzagDecodeInt64(n uint64) int64

                          func ZigzagEncodeUInt32

                          func ZigzagEncodeUInt32(n int32) uint32

                          func ZigzagEncodeUInt64

                          func ZigzagEncodeUInt64(n int64) uint64

                          Types

                          This section is empty.