mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
check deleted chunks faster
This commit is contained in:
parent
cd45ab072a
commit
1babec00e7
|
@ -74,16 +74,13 @@ func (f *Filer) deleteChunksIfNotNew(oldEntry, newEntry *Entry) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var toDelete []*filer_pb.FileChunk
|
var toDelete []*filer_pb.FileChunk
|
||||||
|
newChunkIds := make(map[string]bool)
|
||||||
|
for _, newChunk := range newEntry.Chunks {
|
||||||
|
newChunkIds[newChunk.GetFileIdString()] = true
|
||||||
|
}
|
||||||
|
|
||||||
for _, oldChunk := range oldEntry.Chunks {
|
for _, oldChunk := range oldEntry.Chunks {
|
||||||
found := false
|
if _, found := newChunkIds[oldChunk.GetFileIdString()]; !found {
|
||||||
for _, newChunk := range newEntry.Chunks {
|
|
||||||
if filer_pb.ChunkEquals(oldChunk, newChunk) {
|
|
||||||
found = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !found {
|
|
||||||
toDelete = append(toDelete, oldChunk)
|
toDelete = append(toDelete, oldChunk)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,16 +21,6 @@ func (fid *FileId) toFileIdString() string {
|
||||||
return needle.NewFileId(needle.VolumeId(fid.VolumeId), fid.FileKey, fid.Cookie).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 {
|
func (c *FileChunk) GetFileIdString() string {
|
||||||
if c.FileId != "" {
|
if c.FileId != "" {
|
||||||
return c.FileId
|
return c.FileId
|
||||||
|
|
Loading…
Reference in a new issue