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
minor optimization
chrislu8c5759a06dbe
diff --git a/weed/storage/volume_read.go b/weed/storage/volume_read.goindex b38ec32d36..d4d795fee3 100644--- a/weed/storage/volume_read.go+++ b/weed/storage/volume_read.go@@ -107,7 +107,7 @@ func (v *Volume) readNeedleDataInto(n *needle.Needle, readOption *ReadOption, wrreadOption.IsOutOfRange = falseerr = n.ReadNeedleMeta(v.DataBackend, nv.Offset.ToActualOffset(), readSize, v.Version())}- buf := mem.Allocate(1024 * 1024)+ buf := mem.Allocate(min(1024*1024, int(size)))defer mem.Free(buf)actualOffset := nv.Offset.ToActualOffset()if readOption.IsOutOfRange {@@ -117,6 +117,13 @@ func (v *Volume) readNeedleDataInto(n *needle.Needle, readOption *ReadOption, wrreturn n.ReadNeedleDataInto(v.DataBackend, actualOffset, buf, writer, offset, size)}+func min(x, y int) int {+ if x < y {+ return x+ }+ return y+}+// read fills in Needle content by looking up n.Id from NeedleMapperfunc (v *Volume) ReadNeedleBlob(offset int64, size Size) ([]byte, error) {v.dataFileAccessLock.RLock()