Documentation ¶
Overview ¶
Package simple8b implements the 64bit integer encoding algoritm as published by Ann and Moffat in "Index compression using 64-bit words", Softw. Pract. Exper. 2010; 40:131–147
It is capable of encoding multiple integers with values betweeen 0 and to 1^60 -1, in a single word.
Imported from github.com/jwilder/encoding
Index ¶
- Constants
- Variables
- func Count(v uint64) (int, error)
- func CountBytes(b []byte) (int, error)
- func CountBytesBetween(b []byte, min, max uint64) (int, error)
- func Decode(dst *[240]uint64, v uint64) (n int, err error)
- func DecodeAll(dst, src []uint64) (value int, err error)
- func DecodeBytesBigEndian(dst []uint64, src []byte) (value int, err error)
- func Encode(src []uint64) (value uint64, n int, err error)
- func EncodeAll(src []uint64) ([]uint64, error)
- func ForEach(b []byte, fn func(v uint64) bool) error
- type Decoder
- type Encoder
Constants ¶
const MaxValue = (1 << 60) - 1
const (
S8B_BIT_SIZE = 60
)
Variables ¶
var (
ErrValueOutOfBounds = errors.New("value out of bounds")
)
Functions ¶
func CountBytes ¶
Count returns the number of integers encoded in the byte slice
func DecodeAll ¶
Decode writes the uncompressed values from src to dst. It returns the number of values written or an error.
func DecodeBytesBigEndian ¶
DecodeBytesBigEndian writes the compressed, big-endian values from src to dst. It returns the number of values written or an error.
func Encode ¶
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.
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 (*Decoder) Next ¶
Next returns true if there are remaining values to be read. Successive calls to Next advance the current element pointer.
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