policies_ex

package
v0.0.0-...-aaf6028 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Implementations for the interfaces provided by the 'policies' packages. Aka 'github.com/maxymania/fastnntp-polyglot/policies'. This package is meant to implement a more efficient and effective policies.DeflateFunction as well as more flexible and useful policies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateSimpleAdaptiveDeflate

func CreateSimpleAdaptiveDeflate(unCompressible, compressible, veryCompressible policies.DeflateFunction) policies.DeflateFunction

Adaptive Compression function constructor. This produces an policies.DeflateFunction, that first estimates the compressibility of the data, and then, chooses an underlying compression function, depending on whether the data is Non-Compressible, Compressible or Very compressible.

func FastDeflate

func FastDeflate(d policies.DEFLATE, data []byte) []byte

Fast policies.DeflateFunction

func HuffmanOnlyDeflate

func HuffmanOnlyDeflate(d policies.DEFLATE, data []byte) []byte

Very fast policies.DeflateFunction (llar).

func NewDeflateFunction

func NewDeflateFunction(level int) policies.DeflateFunction

Faster alternaticve to policies.NewDeflateFunction(level int)

func ZopfliDeflate

func ZopfliDeflate(d policies.DEFLATE, data []byte) []byte

High efficiency policies.DeflateFunction

Types

type AdaptiveDeflator

type AdaptiveDeflator struct {
	// If not zero, this variable declares, how small a BLOB may be at least and how big it may be at most,
	// in order to archieve proper compression.
	CompressibleSize format.Range

	// The Maximum DELATE-Ratio, that might be used to compress the data.
	// This option is meant to limit the performance impact of large BLOBs.
	MaxRatio int

	// If true, the function will use HuffmanOnly instead of NoCompression for
	// non-compressible BLOBs.
	UseHuffmanInCase bool

	// If the data is compressible, add BoostRatio but don't exceed BoostMaxRatio
	BoostRatio, BoostMaxRatio int

	// If ZopfliMinSize <= len(data) <= ZopfliMaxSize AND len(data)!=0, then
	// the Zopfli Compression algorithm will be used instead of the regular
	// Deflate routines, thus resulting in much higher compression ratio.
	ZopfliMinSize, ZopfliMaxSize int

	// If the estimated compressibility is < ZopfliMinCompressibility, then
	// the Zopfli algorithm will not kick in.
	ZopfliMinCompressibility float64
}

Advanced adaptive DEFLATE encoder

func (*AdaptiveDeflator) Deflate

func (ad *AdaptiveDeflator) Deflate(d policies.DEFLATE, data []byte) []byte

Use this method as policies.DeflateFunction closure.

type AdaptiveDeflatorConfig

type AdaptiveDeflatorConfig struct {
	CompressibleSize format.Range `inn:"size"`
	MaxRatio         int          `inn:"ratio"`
	UseHuffmanInCase bool         `inn:"nc-use-huffman"`
	BoostRatio       format.Range `inn:"boost"`
	Zopfli           struct {
		Size               format.Range `inn:"size"`
		MinCompressibility float64      `inn:"compressible"`
	} `inn:"zopfli!"`
}

func (*AdaptiveDeflatorConfig) Build

func (cfg *AdaptiveDeflatorConfig) Build(ad *AdaptiveDeflator)

type Layer

type Layer struct {
	Inner      policies.PostingPolicy
	Element    []LayerElement
	PerformAll bool
}

func (*Layer) Decide

func (l *Layer) Decide(groups [][]byte, lines, length int64) policies.PostingDecision

type LayerElement

type LayerElement struct {
	Xover, Head, Body policies.DeflateFunction

	ExpireDays int

	Criteria *Matcher
}

type Matcher

type Matcher struct {
	Newsgroups, Except, Exclude *regexp.Regexp

	SizeMin, SizeMax, LinesMin, LinesMax int64
}

func (*Matcher) Match

func (m *Matcher) Match(groups [][]byte, lines, length int64) bool

type MatcherConfig

type MatcherConfig struct {
	Newsgroups string         `inn:"newsgroups"`
	Except     string         `inn:"except"`
	Exclude    string         `inn:"exclude"`
	Size       format.Range64 `inn:"size"`
	Lines      format.Range64 `inn:"lines"`
}

func (*MatcherConfig) Build

func (c *MatcherConfig) Build(m *Matcher)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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