Versions in this module Expand all Collapse all v0 v0.3.0 Feb 7, 2026 Changes in this version + const DefaultTrainBootstrapBytes + const DefaultTrainBootstrapDictBytes + const DefaultTrainBootstrapMinRecords type Trainer + func (t *Trainer) SetOnAccept(fn func(*ActiveProfile)) v0.2.0 Jan 24, 2026 Changes in this version + const DefaultMetricsWindowBytes + const DefaultMinBytes + const DefaultMinSavings + const DefaultTrainBytes + const DefaultTrainDedupWindow + const DefaultTrainDictBytes + const DefaultTrainMaxRecordBytes + const DefaultTrainMinRecords + const DefaultTrainQueue + const HeaderSize + const MinProfileBytes + const MinProfileBytesDegraded + const MinProfileInterval + const MinProfileIntervalDegraded + const MinProfileRecords + const MinProfileRecordsDegraded + const ProfileDriftThreshold + const ProfileImproveThresh + var ErrCorrupt = errors.New("compression: invalid compressed value") + type ActiveProfile struct + AvgSampleBytes int + DecodeNsEstimate int64 + Dict []byte + DictBytes int + DictHash uint64 + EncodeNsEstimate int64 + HistoryBytes int + K int + PayloadRatio float64 + Samples int + Timestamp time.Time + TotalRatio float64 + func ChooseKForDict(dict []byte, samples [][]byte) (profile *ActiveProfile) + func ChooseKForDictOptions(dict []byte, samples [][]byte, opts ChooseKOptions) (profile *ActiveProfile) + type ChooseKOptions struct + CandidateK []int + DecodeNsPerRawByte float64 + EncodeNsPerRawByte float64 + IoNsPerStoredByte float64 + type Config struct + BufferPool *sync.Pool + Kind Kind + Level zstd.EncoderLevel + MinBytes int + MinSavings int + ZstdDecs *sync.Pool + ZstdEncs *sync.Pool + func NormalizeOptions(opts Options) (Config, error) + func (c *Config) CompressRecord(key, value []byte) ([]byte, bool, error) + func (c *Config) CompressValue(value []byte) ([]byte, bool, error) + func (c *Config) CompressValuePooled(value []byte) ([]byte, bool, func(), error) + func (c *Config) DecompressRecord(encoded []byte) ([]byte, []byte, error) + func (c *Config) DecompressValue(encoded []byte) ([]byte, error) + type DictUseFlag uint8 + const DictUseGlobal + const DictUseLocal + const DictUseRef + type Kind uint8 + const KindNone + const KindZSTD + type Metrics struct + Enabled bool + LogWindows bool + MinRecords uint64 + PauseBytes uint64 + PauseThreshold float64 + SlabID uint32 + TotalCompressed uint64 + TotalDegraded uint64 + TotalFull uint64 + TotalRaw uint64 + TotalRecords uint64 + TotalStored uint64 + WindowBytes uint64 + WindowCompressed uint64 + WindowFull uint64 + WindowRaw uint64 + WindowRecords uint64 + WindowStored uint64 + func NewMetrics(opts MetricsOptions) Metrics + func (m *Metrics) Add(slabID uint32, rawBytes, storedBytes, records, compressedCount, fullCount int) uint64 + func (m *Metrics) Finish(reason string) + func (m *Metrics) LogWindow() uint64 + func (m *Metrics) Reset(nextSlabID uint32) + func (m *Metrics) SetSlab(id uint32) + type MetricsOptions struct + AdaptiveRatio float64 + MetricsEnabled bool + MinRecords int + PauseBytes int + WindowBytes int + type Options struct + Kind Kind + Level int + MinBytes int + MinSavingsBytes int + type TrainConfig struct + DecodeNsPerRawByte float64 + DedupWindow int + DictBytes int + EncodeNsPerRawByte float64 + Level int + MaxRecordBytes int + MinRecords int + SampleStride int + TrainBytes int + type Trainer struct + func NewTrainer(opts TrainConfig, cfg Config, readOnly bool, metricsEnabled bool) *Trainer + func (t *Trainer) AcceptProfile(profile *ActiveProfile) + func (t *Trainer) ActiveProfile() (*ActiveProfile, bool) + func (t *Trainer) Close() + func (t *Trainer) Collect(value []byte) + func (t *Trainer) Config() TrainConfig + func (t *Trainer) ForceCollecting() + func (t *Trainer) SetAutotuneCandidates(candidateK, candidateHistoryBytes []int) + func (t *Trainer) SetAutotuneIOCost(ioNsPerStoredByte float64) + func (t *Trainer) ShouldCollect() bool + func (t *Trainer) SignalDegraded(slabID uint32) + func (t *Trainer) Stats() TrainerStats + type TrainerStats struct + CollectCount uint64 + CollectMaxNanos uint64 + CollectNanos uint64 + Collecting bool + DictDedupBytes uint64 + DictDedupBytesCache uint64 + DictDedupBytesGlobal uint64 + DictDedupBytesRef uint64 + DictDedupCache uint64 + DictDedupGlobal uint64 + DictDedupHits uint64 + DictDedupLookups uint64 + DictDedupRef uint64 + Dropped uint64 + Enabled bool + Enqueued uint64 + LastAcceptBytes uint64 + LastAcceptRecords uint64 + LastAcceptTimestamp time.Time + LastTrainDedupFlag string + LastTrainDedupMode string + LastTrainDedupRef uint64 + LastTrainDict uint64 + LastTrainDictHash uint64 + LastTrainRatio float64 + LastTrainSamples uint64 + MaxQueueLen uint64 + ProfileAccepts uint64 + ProfileAttempts uint64 + ProfileK int + ProfilePayloadRatio float64 + ProfileRejectReason string + ProfileRejects uint64 + ProfileTimestamp time.Time + ProfileTotalRatio float64 + QueueCap int + QueueLen int + RollingRatioBaseline float64 + RollingRatioCurrent float64 + TrainCount uint64 + Training bool