SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
sampling whether the data can be gzipped
Chris Lu2286eda57586
diff --git a/weed/operation/upload_content.go b/weed/operation/upload_content.goindex 75775d7d08..b74663c369 100644--- a/weed/operation/upload_content.go+++ b/weed/operation/upload_content.go@@ -78,9 +78,13 @@ func doUploadData(uploadUrl string, filename string, cipher bool, data []byte, icontentIsGzipped := isInputGzippedshouldGzipNow := falseif !isInputGzipped {- if shouldBeZipped, iAmSure := util.IsGzippableFileType(filepath.Base(filename), mtype); mtype == "" || iAmSure && shouldBeZipped {+ if shouldBeZipped, iAmSure := util.IsGzippableFileType(filepath.Base(filename), mtype); iAmSure && shouldBeZipped {shouldGzipNow = truecontentIsGzipped = true+ } else if len(data) > 128 {+ var compressed []byte+ compressed, err = util.GzipData(data[0:128])+ shouldGzipNow = len(compressed)*10 < 128*9 // can not compress to less than 90%}}@@ -90,7 +94,12 @@ func doUploadData(uploadUrl string, filename string, cipher bool, data []byte, i// this could be double copyingclearDataLen = len(data)if shouldGzipNow {- data, err = util.GzipData(data)+ compressed, compressErr := util.GzipData(data)+ // fmt.Printf("data is compressed from %d ==> %d\n", len(data), len(compressed))+ if compressErr == nil {+ data = compressed+ contentIsGzipped = true+ }} else if isInputGzipped {// just to get the clear data lengthclearData, err := util.UnGzipData(data)