Documentation ¶
Index ¶
- Constants
- Variables
- func DecodeFloat64LE(b *[]byte) (float64, error)
- func DecodeUvarint64(b *[]byte) (uint64, error)
- func DecodeVarfloat64(b *[]byte) (float64, error)
- func DecodeVarint32(b *[]byte) (int32, error)
- func DecodeVarint64(b *[]byte) (int64, error)
- func EncodeFlag(b *[]byte, f Flag)
- func EncodeFloat64LE(b *[]byte, v float64)
- func EncodeUvarint64(b *[]byte, v uint64)
- func EncodeVarfloat64(b *[]byte, v float64)
- func EncodeVarint64(b *[]byte, v int64)
- func Uvarint64Size(v uint64) int
- func Varfloat64Size(v float64) int
- func Varint64Size(v int64) int
- type Flag
- type FlagType
- type SubFlag
Constants ¶
const (
MaxVarLen64 = 9
)
Variables ¶
var ( FlagTypeIndexMapping = FlagType{0b10} FlagTypePositiveStore = FlagType{0b01} FlagTypeNegativeStore = FlagType{0b11} // Encodes the count of the zero bin. // Encoding format: // - [byte] flag // - [varfloat64] count of the zero bin FlagZeroCountVarFloat = NewFlag(flagTypeSketchFeatures, newSubFlag(1)) // Encode the total count. // Encoding format: // - [byte] flag // - [varfloat64] total count FlagCount = NewFlag(flagTypeSketchFeatures, newSubFlag(0x28)) // Encode the summary statistics. // Encoding format: // - [byte] flag // - [float64LE] summary stat FlagSum = NewFlag(flagTypeSketchFeatures, newSubFlag(0x21)) FlagMin = NewFlag(flagTypeSketchFeatures, newSubFlag(0x22)) FlagMax = NewFlag(flagTypeSketchFeatures, newSubFlag(0x23)) // Encodes log-like index mappings, specifying the base (gamma) and the index offset // The subflag specifies the interpolation method. // Encoding format: // - [byte] flag // - [float64LE] gamma // - [float64LE] index offset FlagIndexMappingBaseLogarithmic = NewFlag(FlagTypeIndexMapping, newSubFlag(0)) FlagIndexMappingBaseLinear = NewFlag(FlagTypeIndexMapping, newSubFlag(1)) FlagIndexMappingBaseQuadratic = NewFlag(FlagTypeIndexMapping, newSubFlag(2)) FlagIndexMappingBaseCubic = NewFlag(FlagTypeIndexMapping, newSubFlag(3)) FlagIndexMappingBaseQuartic = NewFlag(FlagTypeIndexMapping, newSubFlag(4)) // Encodes N bins, each one with its index and its count. // Indexes are delta-encoded. // Encoding format: // - [byte] flag // - [uvarint64] number of bins N // - [varint64] index of first bin // - [varfloat64] count of first bin // - [varint64] difference between the index of the second bin and the index // of the first bin // - [varfloat64] count of second bin // - ... // - [varint64] difference between the index of the N-th bin and the index // of the (N-1)-th bin // - [varfloat64] count of N-th bin BinEncodingIndexDeltasAndCounts = newSubFlag(1) // Encodes N bins whose counts are each equal to 1. // Indexes are delta-encoded. // Encoding format: // - [byte] flag // - [uvarint64] number of bins N // - [varint64] index of first bin // - [varint64] difference between the index of the second bin and the index // of the first bin // - ... // - [varint64] difference between the index of the N-th bin and the index // of the (N-1)-th bin BinEncodingIndexDeltas = newSubFlag(2) // Encodes N contiguous bins, specifiying the count of each one // Encoding format: // - [byte] flag // - [uvarint64] number of bins N // - [varint64] index of first bin // - [varint64] difference between two successive indexes // - [varfloat64] count of first bin // - [varfloat64] count of second bin // - ... // - [varfloat64] count of N-th bin BinEncodingContiguousCounts = newSubFlag(3) )
Functions ¶
func DecodeFloat64LE ¶
DecodeFloat64LE deserializes 64-bit floating-point values that have been encoded with EncodeFloat64LE.
func DecodeUvarint64 ¶
DecodeUvarint64 deserializes 64-bit unsigned integers that have been encoded using EncodeUvarint64.
func DecodeVarfloat64 ¶
DecodeVarfloat64 deserializes 64-bit floating-point values that have been encoded with EncodeVarfloat64.
func DecodeVarint32 ¶
DecodeVarint32 deserializes 32-bit signed integers that have been encoded using EncodeVarint64.
func DecodeVarint64 ¶
DecodeVarint64 deserializes 64-bit signed integers that have been encoded using EncodeVarint32.
func EncodeFlag ¶
EncodeFlag encodes a flag and appends its content to the provided []byte.
func EncodeFloat64LE ¶
EncodeFloat64LE serializes 64-bit floating-point values, starting with the least significant bytes.
func EncodeUvarint64 ¶
EncodeUvarint64 serializes 64-bit unsigned integers 7 bits at a time, starting with the least significant bits. The most significant bit in each output byte is the continuation bit and indicates whether there are additional non-zero bits encoded in following bytes. There are at most 9 output bytes and the last one does not have a continuation bit, allowing for it to encode 8 bits (8*7+8 = 64).
func EncodeVarfloat64 ¶
EncodeVarfloat64 serializes 64-bit floating-point values using a method that is similar to the varuint encoding and that is space-efficient for non-negative integer values. The output takes at most 9 bytes. Input values are first shifted as floating-point values (+1), then transmuted to integer values, then shifted again as integer values (-Float64bits(1)). That is in order to minimize the number of non-zero bits when dealing with non-negative integer values. After that transformation, any input integer value no greater than 2^53 (the largest integer value that can be encoded exactly as a 64-bit floating-point value) will have at least 6 leading zero bits. By rotating bits to the left, those bits end up at the right of the binary representation. The resulting bits are then encoded similarly to the varuint method, but starting with the most significant bits.
func EncodeVarint64 ¶
EncodeVarint64 serializes 64-bit signed integers using zig-zag encoding, which ensures small-scale integers are turned into unsigned integers that have leading zeros, whether they are positive or negative, hence allows for space-efficient varuint encoding of those values.
func Uvarint64Size ¶ added in v1.2.1
Uvarint64Size returns the number of bytes that EncodeUvarint64 encodes a 64-bit unsigned integer into.
func Varfloat64Size ¶ added in v1.2.1
Varfloat64Size returns the number of bytes that EncodeVarfloat64 encodes a 64-bit floating-point value into.
func Varint64Size ¶ added in v1.2.1
Varint64Size returns the number of bytes that EncodeVarint64 encodes a 64-bit signed integer into.
Types ¶
type Flag ¶
type Flag struct {
// contains filtered or unexported fields
}
func DecodeFlag ¶
DecodeFlag decodes a flag and updates the provided []byte so that it starts immediately after the encoded flag.