forked from TrueCloudLab/frostfs-node
[#1715] config: Add compression
config section
To group all `compression_*` parameters together. Change-Id: I11ad9600f731903753fef1adfbc0328ef75bbf87 Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
8c746a914a
commit
0ee7467da5
12 changed files with 105 additions and 155 deletions
|
@ -32,8 +32,8 @@ type Config struct {
|
|||
UncompressableContentTypes []string
|
||||
Level Level
|
||||
|
||||
UseCompressEstimation bool
|
||||
CompressEstimationThreshold float64
|
||||
EstimateCompressibility bool
|
||||
EstimateCompressibilityThreshold float64
|
||||
}
|
||||
|
||||
// zstdFrameMagic contains first 4 bytes of any compressed object
|
||||
|
@ -101,9 +101,9 @@ func (c *Compressor) Compress(data []byte) []byte {
|
|||
if c == nil || !c.Enabled {
|
||||
return data
|
||||
}
|
||||
if c.UseCompressEstimation {
|
||||
if c.EstimateCompressibility {
|
||||
estimated := compress.Estimate(data)
|
||||
if estimated >= c.CompressEstimationThreshold {
|
||||
if estimated >= c.EstimateCompressibilityThreshold {
|
||||
return c.compress(data)
|
||||
}
|
||||
return data
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue