forked from TrueCloudLab/frostfs-node
[#1523] blobstor: Rename compression.CConfig
to Config
Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
This commit is contained in:
parent
0042c1d4a6
commit
e8c6dce466
12 changed files with 34 additions and 34 deletions
|
@ -48,11 +48,11 @@ import (
|
|||
// B-s are intitialized and opened.
|
||||
//
|
||||
// Object is saved as follows:
|
||||
// 1. at each level, according to HRW, the next one is selected and
|
||||
// dives into it until we reach the deepest;
|
||||
// 2. at the B-s level object is saved to the active B. If active B
|
||||
// is full, next B is opened, initialized and cached. If there
|
||||
// is no more X candidates, goto 1 and process next level.
|
||||
// 1. at each level, according to HRW, the next one is selected and
|
||||
// dives into it until we reach the deepest;
|
||||
// 2. at the B-s level object is saved to the active B. If active B
|
||||
// is full, next B is opened, initialized and cached. If there
|
||||
// is no more X candidates, goto 1 and process next level.
|
||||
//
|
||||
// After the object is saved in B, path concatenation is returned
|
||||
// in system path format as B identifier (ex. "0/1/1" or "3/2/1").
|
||||
|
@ -228,6 +228,6 @@ func (b *Blobovniczas) Type() string {
|
|||
}
|
||||
|
||||
// SetCompressor implements common.Storage.
|
||||
func (b *Blobovniczas) SetCompressor(cc *compression.CConfig) {
|
||||
b.CConfig = cc
|
||||
func (b *Blobovniczas) SetCompressor(cc *compression.Config) {
|
||||
b.compression = cc
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ func (b *Blobovniczas) getObject(blz *blobovnicza.Blobovnicza, prm blobovnicza.G
|
|||
}
|
||||
|
||||
// decompress the data
|
||||
data, err := b.Decompress(res.Object())
|
||||
data, err := b.compression.Decompress(res.Object())
|
||||
if err != nil {
|
||||
return common.GetRes{}, fmt.Errorf("could not decompress object data: %w", err)
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ func (b *Blobovniczas) getObjectRange(blz *blobovnicza.Blobovnicza, prm common.G
|
|||
}
|
||||
|
||||
// decompress the data
|
||||
data, err := b.Decompress(res.Object())
|
||||
data, err := b.compression.Decompress(res.Object())
|
||||
if err != nil {
|
||||
return common.GetRangeRes{}, fmt.Errorf("could not decompress object data: %w", err)
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
func (b *Blobovniczas) Iterate(prm common.IteratePrm) (common.IterateRes, error) {
|
||||
return common.IterateRes{}, b.iterateBlobovniczas(prm.IgnoreErrors, func(p string, blz *blobovnicza.Blobovnicza) error {
|
||||
return blobovnicza.IterateObjects(blz, func(addr oid.Address, data []byte) error {
|
||||
data, err := b.Decompress(data)
|
||||
data, err := b.compression.Decompress(data)
|
||||
if err != nil {
|
||||
if prm.IgnoreErrors {
|
||||
if prm.ErrorHandler != nil {
|
||||
|
|
|
@ -16,8 +16,8 @@ type cfg struct {
|
|||
openedCacheSize int
|
||||
blzShallowDepth uint64
|
||||
blzShallowWidth uint64
|
||||
*compression.CConfig
|
||||
blzOpts []blobovnicza.Option
|
||||
compression *compression.Config
|
||||
blzOpts []blobovnicza.Option
|
||||
}
|
||||
|
||||
type Option func(*cfg)
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
// returns error if could not save object in any blobovnicza.
|
||||
func (b *Blobovniczas) Put(prm common.PutPrm) (common.PutRes, error) {
|
||||
if !prm.DontCompress {
|
||||
prm.RawData = b.CConfig.Compress(prm.RawData)
|
||||
prm.RawData = b.compression.Compress(prm.RawData)
|
||||
}
|
||||
|
||||
var putPrm blobovnicza.PutPrm
|
||||
|
|
|
@ -32,9 +32,9 @@ type Info = fstree.Info
|
|||
type Option func(*cfg)
|
||||
|
||||
type cfg struct {
|
||||
compression.CConfig
|
||||
log *logger.Logger
|
||||
storage []SubStorage
|
||||
compression compression.Config
|
||||
log *logger.Logger
|
||||
storage []SubStorage
|
||||
}
|
||||
|
||||
func initConfig(c *cfg) {
|
||||
|
@ -51,7 +51,7 @@ func New(opts ...Option) *BlobStor {
|
|||
}
|
||||
|
||||
for i := range bs.storage {
|
||||
bs.storage[i].Storage.SetCompressor(&bs.CConfig)
|
||||
bs.storage[i].Storage.SetCompressor(&bs.compression)
|
||||
}
|
||||
|
||||
return bs
|
||||
|
@ -86,7 +86,7 @@ func WithLogger(l *logger.Logger) Option {
|
|||
// is recorded in the provided log.
|
||||
func WithCompressObjects(comp bool) Option {
|
||||
return func(c *cfg) {
|
||||
c.Enabled = comp
|
||||
c.compression.Enabled = comp
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,6 +94,6 @@ func WithCompressObjects(comp bool) Option {
|
|||
// for specific content types as seen by object.AttributeContentType attribute.
|
||||
func WithUncompressableContentTypes(values []string) Option {
|
||||
return func(c *cfg) {
|
||||
c.UncompressableContentTypes = values
|
||||
c.compression.UncompressableContentTypes = values
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ type Storage interface {
|
|||
Close() error
|
||||
|
||||
Type() string
|
||||
SetCompressor(cc *compression.CConfig)
|
||||
SetCompressor(cc *compression.Config)
|
||||
|
||||
Get(GetPrm) (GetRes, error)
|
||||
GetRange(GetRangePrm) (GetRangeRes, error)
|
||||
|
|
|
@ -8,8 +8,8 @@ import (
|
|||
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
|
||||
)
|
||||
|
||||
// CConfig represents common compression-related configuration.
|
||||
type CConfig struct {
|
||||
// Config represents common compression-related configuration.
|
||||
type Config struct {
|
||||
Enabled bool
|
||||
UncompressableContentTypes []string
|
||||
|
||||
|
@ -22,7 +22,7 @@ type CConfig struct {
|
|||
var zstdFrameMagic = []byte{0x28, 0xb5, 0x2f, 0xfd}
|
||||
|
||||
// Init initializes compression routines.
|
||||
func (c *CConfig) Init() error {
|
||||
func (c *Config) Init() error {
|
||||
var err error
|
||||
|
||||
if c.Enabled {
|
||||
|
@ -44,7 +44,7 @@ func (c *CConfig) Init() error {
|
|||
// For an object to be compressed 2 conditions must hold:
|
||||
// 1. Compression is enabled in settings.
|
||||
// 2. Object MIME Content-Type is allowed for compression.
|
||||
func (c *CConfig) NeedsCompression(obj *objectSDK.Object) bool {
|
||||
func (c *Config) NeedsCompression(obj *objectSDK.Object) bool {
|
||||
if !c.Enabled || len(c.UncompressableContentTypes) == 0 {
|
||||
return c.Enabled
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ func (c *CConfig) NeedsCompression(obj *objectSDK.Object) bool {
|
|||
|
||||
// Decompress decompresses data if it starts with the magic
|
||||
// and returns data untouched otherwise.
|
||||
func (c *CConfig) Decompress(data []byte) ([]byte, error) {
|
||||
func (c *Config) Decompress(data []byte) ([]byte, error) {
|
||||
if len(data) < 4 || !bytes.Equal(data[:4], zstdFrameMagic) {
|
||||
return data, nil
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ func (c *CConfig) Decompress(data []byte) ([]byte, error) {
|
|||
|
||||
// Compress compresses data if compression is enabled
|
||||
// and returns data untouched otherwise.
|
||||
func (c *CConfig) Compress(data []byte) []byte {
|
||||
func (c *Config) Compress(data []byte) []byte {
|
||||
if c == nil || !c.Enabled {
|
||||
return data
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ func (c *CConfig) Compress(data []byte) []byte {
|
|||
}
|
||||
|
||||
// Close closes encoder and decoder, returns any error occured.
|
||||
func (c *CConfig) Close() error {
|
||||
func (c *Config) Close() error {
|
||||
var err error
|
||||
if c.encoder != nil {
|
||||
err = c.encoder.Close()
|
||||
|
|
|
@ -31,7 +31,7 @@ var ErrInitBlobovniczas = errors.New("failure on blobovnicza initialization stag
|
|||
func (b *BlobStor) Init() error {
|
||||
b.log.Debug("initializing...")
|
||||
|
||||
if err := b.CConfig.Init(); err != nil {
|
||||
if err := b.compression.Init(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ func (b *BlobStor) Close() error {
|
|||
}
|
||||
}
|
||||
|
||||
err := b.CConfig.Close()
|
||||
err := b.compression.Close()
|
||||
if firstErr == nil {
|
||||
firstErr = err
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import (
|
|||
type FSTree struct {
|
||||
Info
|
||||
|
||||
*compression.CConfig
|
||||
*compression.Config
|
||||
Depth int
|
||||
DirNameLen int
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ func New(opts ...Option) *FSTree {
|
|||
Permissions: 0700,
|
||||
RootPath: "./",
|
||||
},
|
||||
CConfig: nil,
|
||||
Config: nil,
|
||||
Depth: 4,
|
||||
DirNameLen: DirNameLen,
|
||||
}
|
||||
|
@ -318,6 +318,6 @@ func (*FSTree) Type() string {
|
|||
}
|
||||
|
||||
// SetCompressor implements common.Storage.
|
||||
func (t *FSTree) SetCompressor(cc *compression.CConfig) {
|
||||
t.CConfig = cc
|
||||
func (t *FSTree) SetCompressor(cc *compression.Config) {
|
||||
t.Config = cc
|
||||
}
|
||||
|
|
|
@ -54,5 +54,5 @@ func (b *BlobStor) Put(prm common.PutPrm) (common.PutRes, error) {
|
|||
// 1. Compression is enabled in settings.
|
||||
// 2. Object MIME Content-Type is allowed for compression.
|
||||
func (b *BlobStor) NeedsCompression(obj *objectSDK.Object) bool {
|
||||
return b.cfg.CConfig.NeedsCompression(obj)
|
||||
return b.cfg.compression.NeedsCompression(obj)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue