diff options
| author | hilimd <68371223+hilimd@users.noreply.github.com> | 2020-11-22 20:29:17 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-22 20:29:17 +0800 |
| commit | 9aa990f80f8af70628c72eaf0c20d445c15b9e9d (patch) | |
| tree | 2dd4ed5551515b207074bf27908432b0293cd321 /weed/util/compression.go | |
| parent | e8296104fc715f0f7c41a82059f366603b3e94f0 (diff) | |
| parent | 92f906b6fcce2ef72661bb825075e2826b8f3aa1 (diff) | |
| download | seaweedfs-9aa990f80f8af70628c72eaf0c20d445c15b9e9d.tar.xz seaweedfs-9aa990f80f8af70628c72eaf0c20d445c15b9e9d.zip | |
Merge pull request #39 from chrislusf/master
sync
Diffstat (limited to 'weed/util/compression.go')
| -rw-r--r-- | weed/util/compression.go | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/weed/util/compression.go b/weed/util/compression.go index cf3ac7c57..33506834b 100644 --- a/weed/util/compression.go +++ b/weed/util/compression.go @@ -9,7 +9,7 @@ import ( "strings" "github.com/chrislusf/seaweedfs/weed/glog" - "github.com/klauspost/compress/zstd" + // "github.com/klauspost/compress/zstd" ) var ( @@ -55,19 +55,16 @@ func GzipData(input []byte) ([]byte, error) { return buf.Bytes(), nil } -var zstdEncoder, _ = zstd.NewWriter(nil) - -func ZstdData(input []byte) ([]byte, error) { - return zstdEncoder.EncodeAll(input, nil), nil -} func DecompressData(input []byte) ([]byte, error) { if IsGzippedContent(input) { return ungzipData(input) } + /* if IsZstdContent(input) { return unzstdData(input) } + */ return input, UnsupportedCompression } @@ -82,12 +79,6 @@ func ungzipData(input []byte) ([]byte, error) { return output, err } -var decoder, _ = zstd.NewReader(nil) - -func unzstdData(input []byte) ([]byte, error) { - return decoder.DecodeAll(input, nil) -} - func IsGzippedContent(data []byte) bool { if len(data) < 2 { return false @@ -95,12 +86,26 @@ func IsGzippedContent(data []byte) bool { return data[0] == 31 && data[1] == 139 } +/* +var zstdEncoder, _ = zstd.NewWriter(nil) + +func ZstdData(input []byte) ([]byte, error) { + return zstdEncoder.EncodeAll(input, nil), nil +} + +var decoder, _ = zstd.NewReader(nil) + +func unzstdData(input []byte) ([]byte, error) { + return decoder.DecodeAll(input, nil) +} + func IsZstdContent(data []byte) bool { if len(data) < 4 { return false } return data[3] == 0xFD && data[2] == 0x2F && data[1] == 0xB5 && data[0] == 0x28 } +*/ /* * Default not to compressed since compression can be done on client side. |
