Documentation
¶
Overview ¶
Package compress is the compressor of the writer: for one chunk of one column, it tries the encodings of internal/encode that fit its type on a sample of the rows, keeps the one that makes the smallest array, and applies it to the whole chunk. The children of an encoding (the codes of a dictionary, the integers of ALP, the lengths of FSST) are compressed the same way, down to a depth of 3, as the reference does (vortex-compressor and vortex-btrblocks).
A candidate is measured by encoding the sample with it, its children included, and counting the bytes of the tree plus an overhead per array and per buffer, so that an encoding that saves less than what it costs to describe is not taken. The plain array is always a candidate, and the result is checked against it on the whole chunk: a chunk is never made larger. The sample is runs of 64 consecutive rows, at least 16 of them and about 1% of the chunk, at offsets drawn from a fixed seed: the same rows always give the same tree. The bytes of a candidate that do not grow with the rows (the symbol table of FSST, the dictionary of OnPair) are charged at the share of the rows its sample holds, and OnPair trains on half of the bytes of a sample rather than 15%, as the reference does since 0.94.0. As there too, a dictionary of strings is measured last, on all the rows, when a probe of whole runs of rows says it may beat the best ratio of the sample (dicttrial.go).
The candidates of a trial (the sample, and the children of its candidates) are the ones the reference does not rule out from the statistics of its rows: integers are not tried as a dictionary when more than half of their valid values are distinct, nor as a sparse array when their most frequent value is under nine tenths of them (and they are not mostly null), and floats are not tried as a dictionary when more than half are distinct. A scheme is never twice in a chain of parents, and some leave out more under some of their children, as the exclusion rules of the reference do (exclZigZag and the others). The values of a frame of reference are bit-packed, as the reference does, with no other candidate. The probe of the dictionary layout keeps the scheme it chose, for the chunk of the same rows that follows it.
A Compressor is not safe for concurrent use: the writer has one per column. Once it has seen chunks of the largest size, it allocates nothing.
Index ¶
- type Compressor
- func (c *Compressor) Bools(v, nulls []bool) *encode.Node
- func (c *Compressor) Configure(mode Mode, limit Limits)
- func (c *Compressor) Decimals(raw []byte, width int, nulls []bool) *encode.Node
- func (c *Compressor) Numbers(p PType, raw []byte, nulls []bool) *encode.Node
- func (c *Compressor) PicksDict(p PType, raw []byte, nulls []bool) bool
- func (c *Compressor) PicksDictStrings(v [][]byte, nulls []bool, utf8 bool) bool
- func (c *Compressor) Reset()
- func (c *Compressor) Strings(v [][]byte, nulls []bool, utf8 bool) *encode.Node
- func (c *Compressor) Timestamps(v []int64, nulls []bool, ticks int64) *encode.Node
- type Limits
- type Mode
- type PType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Compressor ¶
type Compressor struct {
// contains filtered or unexported fields
}
Compressor holds the memory of the compression of the chunks of a column.
func NewLimited ¶
func NewLimited(mode Mode, limit Limits) *Compressor
NewLimited returns a Compressor that does without the encodings of limit.
func (*Compressor) Bools ¶
func (c *Compressor) Bools(v, nulls []bool) *encode.Node
Bools is the compressed array of booleans, or nil for the plain array: a constant, or nothing.
func (*Compressor) Configure ¶
func (c *Compressor) Configure(mode Mode, limit Limits)
Configure makes c a Compressor of this mode and of these limits, with the memory it has: the arrays of its earlier calls must not be used any more.
func (*Compressor) Decimals ¶
Decimals is the compressed array of decimals of width bytes, or nil for the plain array: their byte parts, the integers compressed, when the values fit an i64.
func (*Compressor) Numbers ¶
Numbers is the compressed array of the numbers raw of type p, or nil for the plain array.
func (*Compressor) PicksDict ¶
func (c *Compressor) PicksDict(p PType, raw []byte, nulls []bool) bool
PicksDict says whether the compressor would write the numbers raw of type p as a dictionary: the probe of the dictionary layout of the writer.
func (*Compressor) PicksDictStrings ¶
func (c *Compressor) PicksDictStrings(v [][]byte, nulls []bool, utf8 bool) bool
PicksDictStrings is PicksDict for strings.
func (*Compressor) Reset ¶
func (c *Compressor) Reset()
Reset frees the arrays of the earlier calls, which must not be used any more.
func (*Compressor) Strings ¶
Strings is the compressed array of the strings v (utf8, else binary), or nil for the plain array.
func (*Compressor) Timestamps ¶
Timestamps is the compressed array of timestamps in ticks of a second (one of the encode.Ticks constants), or nil for the plain array: their datetime parts, the parts compressed as integers, or the integers themselves when that is smaller.
type Limits ¶
type Limits struct {
NoRLE bool // fastlanes.rle
NoMasked bool // vortex.masked
NoSequence bool // vortex.sequence
NoZstd bool // vortex.zstd
NoOnPair bool // vortex.onpair
NoPco bool // vortex.pco
}
Limits lists the encodings that a compressor leaves out, because the edition a file targets does not have them. The zero value leaves out none.