package simple8b
import "github.com/influxdata/influxdb/pkg/encoding/simple8b"
Package simple8b implements the 64bit integer encoding algorithm 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
- func NewDecoder(b []byte) *Decoder
- func (d *Decoder) Next() bool
- func (d *Decoder) Read() uint64
- func (d *Decoder) SetBytes(b []byte)
- type Encoder
Constants ¶
const MaxValue = (1 << 60) - 1
const (
S8B_BIT_SIZE = 60
)
Variables ¶
Functions ¶
func Count ¶
Count returns the number of integers encoded within an uint64
func CountBytes ¶
Count returns the number of integers encoded in the byte slice
func CountBytesBetween ¶
func Decode ¶
func DecodeAll ¶
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 DecodeBytesBigEndian ¶
DecodeBytesBigEndian writes the compressed, big-endian 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 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.
func EncodeAll ¶
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 ¶
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 ¶
NewDecoder returns a Decoder from a byte slice
func (*Decoder) Next ¶
Next returns true if there are remaining values to be read. Successive calls to Next advance the current element pointer.
func (*Decoder) Read ¶
Read returns the current value. Successive calls to Read return the same value.
func (*Decoder) SetBytes ¶
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 (*Encoder) Reset ¶
func (e *Encoder) Reset()
func (*Encoder) SetValues ¶
func (*Encoder) Write ¶
Source Files ¶
- Version
- v1.12.0 (latest)
- Published
- Apr 8, 2025
- Platform
- linux/amd64
- Imports
- 4 packages
- Last checked
- 2 days ago –
Tools for package owners.