forked from TrueCloudLab/frostfs-node
[#176] localstore: Implement primary BlobStor
Implement primary local BLOB storage based on filesystem tree. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
09750484f9
commit
b127607ac6
9 changed files with 467 additions and 0 deletions
35
pkg/local_object_storage/blobstor/compress.go
Normal file
35
pkg/local_object_storage/blobstor/compress.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
package blobstor
|
||||
|
||||
import (
|
||||
"github.com/klauspost/compress/zstd"
|
||||
)
|
||||
|
||||
func noOpCompressor(data []byte) []byte {
|
||||
return data
|
||||
}
|
||||
|
||||
func noOpDecompressor(data []byte) ([]byte, error) {
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func zstdCompressor() func([]byte) []byte {
|
||||
enc, err := zstd.NewWriter(nil)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return func(data []byte) []byte {
|
||||
return enc.EncodeAll(data, make([]byte, 0, len(data)))
|
||||
}
|
||||
}
|
||||
|
||||
func zstdDecompressor() func([]byte) ([]byte, error) {
|
||||
dec, err := zstd.NewReader(nil)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return func(data []byte) ([]byte, error) {
|
||||
return dec.DecodeAll(data, nil)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue