orientgo.v1: gopkg.in/istreamdata/orientgo.v1/obinary/binserde/varint Index | Files

package varint

import "gopkg.in/istreamdata/orientgo.v1/obinary/binserde/varint"

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

Package Files

read_varint.go readtypes.go write_varint.go writetypes.go zigzag.go

func EncodeAndWriteVarInt32 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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

REMOVE ME?

func WriteBytes Uses

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 Uses

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 Uses

func ZigzagDecodeInt32(n uint32) int32

func ZigzagDecodeInt64 Uses

func ZigzagDecodeInt64(n uint64) int64

func ZigzagEncodeUInt32 Uses

func ZigzagEncodeUInt32(n int32) uint32

func ZigzagEncodeUInt64 Uses

func ZigzagEncodeUInt64(n int64) uint64

Package varint imports 6 packages (graph) and is imported by 1 packages. Updated 2016-07-22. Refresh now. Tools for package owners.