mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-11-28 05:15:00 +08:00
adjust compression to optimize for speed
This commit is contained in:
parent
c731d9be6d
commit
a32abda1a3
@ -72,7 +72,7 @@ func IsGzippableFileType(ext, mtype string) (shouldBeZipped, iAmSure bool) {
|
|||||||
|
|
||||||
func GzipData(input []byte) ([]byte, error) {
|
func GzipData(input []byte) ([]byte, error) {
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
w, _ := gzip.NewWriterLevel(buf, flate.BestCompression)
|
w, _ := gzip.NewWriterLevel(buf, flate.BestSpeed)
|
||||||
if _, err := w.Write(input); err != nil {
|
if _, err := w.Write(input); err != nil {
|
||||||
glog.V(2).Infoln("error compressing data:", err)
|
glog.V(2).Infoln("error compressing data:", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -2,6 +2,7 @@ package operation
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"compress/flate"
|
||||||
"compress/gzip"
|
"compress/gzip"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
@ -50,7 +51,7 @@ func Upload(uploadUrl string, filename string, reader io.Reader, isGzipped bool,
|
|||||||
}
|
}
|
||||||
return upload_content(uploadUrl, func(w io.Writer) (err error) {
|
return upload_content(uploadUrl, func(w io.Writer) (err error) {
|
||||||
if shouldGzipNow {
|
if shouldGzipNow {
|
||||||
gzWriter := gzip.NewWriter(w)
|
gzWriter, _ := gzip.NewWriterLevel(w, flate.BestSpeed)
|
||||||
_, err = io.Copy(gzWriter, reader)
|
_, err = io.Copy(gzWriter, reader)
|
||||||
gzWriter.Close()
|
gzWriter.Close()
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user