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
check deleted chunks faster
Chris Lu1babec00e70f
diff --git a/weed/filer2/filer_deletion.go b/weed/filer2/filer_deletion.goindex 574be85557..f8b09adf66 100644--- a/weed/filer2/filer_deletion.go+++ b/weed/filer2/filer_deletion.go@@ -74,16 +74,13 @@ func (f *Filer) deleteChunksIfNotNew(oldEntry, newEntry *Entry) {}var toDelete []*filer_pb.FileChunk+ newChunkIds := make(map[string]bool)+ for _, newChunk := range newEntry.Chunks {+ newChunkIds[newChunk.GetFileIdString()] = true+ }for _, oldChunk := range oldEntry.Chunks {- found := false- for _, newChunk := range newEntry.Chunks {- if filer_pb.ChunkEquals(oldChunk, newChunk) {- found = true- break- }- }- if !found {+ if _, found := newChunkIds[oldChunk.GetFileIdString()]; !found {toDelete = append(toDelete, oldChunk)}}diff --git a/weed/pb/filer_pb/filer_pb_helper.go b/weed/pb/filer_pb/filer_pb_helper.goindex ef216610b8..5c40332e6b 100644--- a/weed/pb/filer_pb/filer_pb_helper.go+++ b/weed/pb/filer_pb/filer_pb_helper.go@@ -21,16 +21,6 @@ func (fid *FileId) toFileIdString() string {return needle.NewFileId(needle.VolumeId(fid.VolumeId), fid.FileKey, fid.Cookie).String()}-func ChunkEquals(this, that *FileChunk) bool {- if this.Fid == nil{- this.Fid, _ = toFileIdObject(this.FileId)- }- if that.Fid == nil{- that.Fid, _ = toFileIdObject(that.FileId)- }- return this.Fid.FileKey == that.Fid.FileKey && this.Fid.VolumeId == that.Fid.VolumeId && this.Fid.Cookie == that.Fid.Cookie-}-func (c *FileChunk) GetFileIdString() string {if c.FileId != "" {return c.FileId