s8b

package
v0.2.9 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2024 License: Apache-2.0, MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const MaxValue = (1 << 60) - 1
View Source
const (
	S8B_BIT_SIZE = 60
)

Variables

View Source
var BufOvUint16 = [16]int{0, 0, 4, 2, 0, 1, 4, 6, 0, 1, 2, 0, 0, 1, 0, 0}
View Source
var BufOvUint32 = [16]int{0, 0, 0, 2, 0, 1, 0, 0, 0, 1, 2, 3, 0, 1, 0, 0}
View Source
var BufOvUint8 = [16]int{0, 0, 0, 2, 0, 1, 4, 6, 0, 1, 0, 0, 0, 0, 0, 0}
View Source
var (
	ErrValueOutOfBounds = errors.New("value out of bounds")
)

Functions

func Count

func Count(v uint64) (int, error)

Count returns the number of integers encoded within an uint64

func CountBytesBetween

func CountBytesBetween(b []byte, min, max uint64) (int, error)

func CountValues

func CountValues(b []byte) (int, error)

Count returns the number of integers encoded in the byte slice

func CountValuesBigEndian

func CountValuesBigEndian(b []byte) (int, error)

Count returns the number of integers encoded in the byte slice

func Decode

func Decode(dst *[240]uint64, v uint64) (n int, err error)

func DecodeAll

func DecodeAll(dst, src []uint64) (value int, err error)

Decode writes the uncompressed values from src to dst. It returns the number of values written or an error. nocheckptr while the underlying struct layout doesn't change

func DecodeAllUint16

func DecodeAllUint16(dst []uint16, src []byte) (value int, err error)

Decode writes the uncompressed values from src to dst. It returns the number of values written or an error.

func DecodeAllUint32

func DecodeAllUint32(dst []uint32, src []byte) (value int, err error)

Decode writes the uncompressed values from src to dst. It returns the number of values written or an error.

func DecodeAllUint64

func DecodeAllUint64(dst []uint64, src []byte) (value int, err error)

Decode writes the uncompressed values from src to dst. It returns the number of values written or an error.

func DecodeAllUint8

func DecodeAllUint8(dst []uint8, src []byte) (value int, err error)

Decode writes the uncompressed values from src to dst. It returns the number of values written or an error.

func DecodeBytesBigEndian

func DecodeBytesBigEndian(dst []uint64, src []byte) (value int, err error)

DecodeBytesBigEndian writes the compressed, big-endian values from src to dst. It returns the number of values written or an error.

func Encode

func Encode(src []uint64) (value uint64, n int, err error)

Encode packs as many values into a single uint64. It returns the packed uint64, how many values from src were packed, or an error if the values exceed the maximum value range.

func EncodeAll

func EncodeAll(src []uint64) ([]uint64, error)

Encode returns a packed slice of the values from src. If a value is over 1 << 60, an error is returned. The input src is modified to avoid extra allocations. If you need to re-use, use a copy.

func ForEach

func ForEach(b []byte, fn func(v uint64) bool) error

Types

type Decoder

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

Decoder converts a compressed byte slice to a stream of unsigned 64bit integers.

func NewDecoder

func NewDecoder(b []byte) *Decoder

NewDecoder returns a Decoder from a byte slice

func (*Decoder) Next

func (d *Decoder) Next() bool

Next returns true if there are remaining values to be read. Successive calls to Next advance the current element pointer.

func (*Decoder) Read

func (d *Decoder) Read() uint64

Read returns the current value. Successive calls to Read return the same value.

func (*Decoder) SetBytes

func (d *Decoder) SetBytes(b []byte)

type Encoder

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

Encoder converts a stream of unsigned 64bit integers to a compressed byte slice.

func NewEncoder

func NewEncoder() *Encoder

NewEncoder returns an Encoder able to convert uint64s to compressed byte slices

func (*Encoder) Bytes

func (e *Encoder) Bytes() ([]byte, error)

func (*Encoder) Reset

func (e *Encoder) Reset()

func (*Encoder) SetValues

func (e *Encoder) SetValues(v []uint64)

func (*Encoder) Write

func (e *Encoder) Write(v uint64) error

Jump to

Keyboard shortcuts

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