Commit bf999b40 authored by Ajit Jagtap's avatar Ajit Jagtap
Browse files

Merge branch 'sp_zstd_changes_21_05_2020' into 'devbranch'

zstd library changes

See merge request !198
parents b4dbb342 fff637aa
Branches
Tags
2 merge requests!199Mep release 21052020,!198zstd library changes
Showing with 13 additions and 6 deletions
......@@ -11,9 +11,14 @@ import (
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/errormdl"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/loggermdl"
"github.com/DataDog/zstd"
// "github.com/DataDog/zstd"
"github.com/klauspost/compress/zstd"
)
var encoder, _ = zstd.NewWriter(nil)
var decoder, _ = zstd.NewReader(nil)
//Zip - Zip
func Zip(source, target string) error {
source = filepath.Clean(source)
......@@ -297,10 +302,11 @@ func Unzip(archive, target string) error {
return nil
}
//zip byte array
//ZipBytes - zip byte array
func ZipBytes(inputData []byte) ([]byte, error) {
compressedData, err := zstd.CompressLevel(nil, inputData, 9)
return compressedData, err
// compressedData, err := zstd.CompressLevel(nil, inputData, 9)
compressedData := encoder.EncodeAll(inputData, make([]byte, 0, len(inputData)))
return compressedData, nil
}
// ZipSingleFile - Zip single file
......@@ -320,9 +326,10 @@ func ZipSingleFile(sourceFilePath, destFilePath string) error {
return nil
}
//unzip bytes - Decompress
//UnZipBytes bytes - Decompress
func UnZipBytes(compressedData []byte) ([]byte, error) {
decompressedData, err := zstd.Decompress(nil, compressedData)
// decompressedData, err := zstd.Decompress(nil, compressedData)
decompressedData, err := decoder.DecodeAll(compressedData, nil)
return decompressedData, errormdl.CheckErr(err)
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment