compressor

package
v1.1.4-rc.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 16, 2023 License: MIT Imports: 6 Imported by: 6

Documentation

Index

Constants

View Source
const (
	TargetL1TxSizeBytesFlagName = "target-l1-tx-size-bytes"
	TargetNumFramesFlagName     = "target-num-frames"
	ApproxComprRatioFlagName    = "approx-compr-ratio"
	KindFlagName                = "compressor"
)
View Source
const RatioKind = "ratio"
View Source
const ShadowKind = "shadow"

Variables

View Source
var KindKeys []string

Functions

func CLIFlags

func CLIFlags(envPrefix string) []cli.Flag

func NewRatioCompressor

func NewRatioCompressor(config Config) (derive.Compressor, error)

NewRatioCompressor creates a new derive.Compressor implementation that uses the target size and a compression ratio parameter to determine how much data can be written to the compressor before it's considered full. The full calculation is as follows:

full = uncompressedLength * approxCompRatio >= targetFrameSize * targetNumFrames

func NewShadowCompressor

func NewShadowCompressor(config Config) (derive.Compressor, error)

NewShadowCompressor creates a new derive.Compressor implementation that contains two compression buffers: one used for size estimation, and one used for the final compressed output. The first is flushed on every write, the second isn't, which means the final compressed data is always slightly smaller than the target. There is one exception to this rule: the first write to the buffer is not checked against the target, which allows individual blocks larger than the target to be included (and will be split across multiple channel frames).

Types

type CLIConfig

type CLIConfig struct {
	// TargetL1TxSizeBytes to target when creating channel frames. Note that if the
	// realized compression ratio is worse than the approximate, more frames may
	// actually be created. This also depends on how close the target is to the
	// max frame size.
	TargetL1TxSizeBytes uint64
	// TargetNumFrames to create in this channel. If the realized compression ratio
	// is worse than approxComprRatio, additional leftover frame(s) might get created.
	TargetNumFrames int
	// ApproxComprRatio to assume. Should be slightly smaller than average from
	// experiments to avoid the chances of creating a small additional leftover frame.
	ApproxComprRatio float64
	// Type of compressor to use. Must be one of KindKeys.
	Kind string
}

func ReadCLIConfig

func ReadCLIConfig(ctx *cli.Context) CLIConfig

func (*CLIConfig) Config

func (c *CLIConfig) Config() Config

type Config

type Config struct {
	// TargetFrameSize to target when creating channel frames. Note that if the
	// realized compression ratio is worse than the approximate, more frames may
	// actually be created. This also depends on how close the target is to the
	// max frame size.
	TargetFrameSize uint64
	// TargetNumFrames to create in this channel. If the realized compression ratio
	// is worse than approxComprRatio, additional leftover frame(s) might get created.
	TargetNumFrames int
	// ApproxComprRatio to assume. Should be slightly smaller than average from
	// experiments to avoid the chances of creating a small additional leftover frame.
	ApproxComprRatio float64
	// Kind of compressor to use. Must be one of KindKeys. If unset, NewCompressor
	// will default to RatioKind.
	Kind string
}

func (Config) NewCompressor

func (c Config) NewCompressor() (derive.Compressor, error)

type FactoryFunc

type FactoryFunc func(Config) (derive.Compressor, error)

type RatioCompressor

type RatioCompressor struct {
	// contains filtered or unexported fields
}

func (*RatioCompressor) Close

func (t *RatioCompressor) Close() error

func (*RatioCompressor) Flush

func (t *RatioCompressor) Flush() error

func (*RatioCompressor) FullErr

func (t *RatioCompressor) FullErr() error

func (*RatioCompressor) InputThreshold

func (t *RatioCompressor) InputThreshold() uint64

InputThreshold calculates the input data threshold in bytes from the given parameters.

func (*RatioCompressor) Len

func (t *RatioCompressor) Len() int

func (*RatioCompressor) Read

func (t *RatioCompressor) Read(p []byte) (int, error)

func (*RatioCompressor) Reset

func (t *RatioCompressor) Reset()

func (*RatioCompressor) Write

func (t *RatioCompressor) Write(p []byte) (int, error)

type ShadowCompressor

type ShadowCompressor struct {
	// contains filtered or unexported fields
}

func (*ShadowCompressor) Close

func (t *ShadowCompressor) Close() error

func (*ShadowCompressor) Flush

func (t *ShadowCompressor) Flush() error

func (*ShadowCompressor) FullErr

func (t *ShadowCompressor) FullErr() error

func (*ShadowCompressor) Len

func (t *ShadowCompressor) Len() int

func (*ShadowCompressor) Read

func (t *ShadowCompressor) Read(p []byte) (int, error)

func (*ShadowCompressor) Reset

func (t *ShadowCompressor) Reset()

func (*ShadowCompressor) Write

func (t *ShadowCompressor) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL