mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-11-24 19:19:11 +08:00
refactoring
This commit is contained in:
parent
332caf0cd7
commit
ee11d98650
@ -88,7 +88,7 @@ func (cm *MemDb) SaveToIdx(idxName string) (ret error) {
|
||||
defer idxFile.Close()
|
||||
|
||||
return cm.AscendingVisit(func(value NeedleValue) error {
|
||||
if value.Offset.IsZero() || value.Size == TombstoneFileSize {
|
||||
if value.Offset.IsZero() || value.Size.IsDeleted() {
|
||||
return nil
|
||||
}
|
||||
_, err := idxFile.Write(value.ToBytes())
|
||||
@ -105,7 +105,7 @@ func (cm *MemDb) LoadFromIdx(idxName string) (ret error) {
|
||||
defer idxFile.Close()
|
||||
|
||||
return idx.WalkIndexFile(idxFile, func(key NeedleId, offset Offset, size Size) error {
|
||||
if offset.IsZero() || size == TombstoneFileSize {
|
||||
if offset.IsZero() || size.IsDeleted() {
|
||||
return cm.Delete(key)
|
||||
}
|
||||
return cm.Set(key, offset, size)
|
||||
|
@ -80,7 +80,7 @@ func (m *SortedFileNeedleMap) Delete(key NeedleId, offset Offset) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if size == TombstoneFileSize {
|
||||
if size.IsDeleted() {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,10 @@ type Offset struct {
|
||||
|
||||
type Size uint32
|
||||
|
||||
func (s Size) IsDeleted() bool {
|
||||
return s == TombstoneFileSize
|
||||
}
|
||||
|
||||
type OffsetLower struct {
|
||||
b3 byte
|
||||
b2 byte
|
||||
|
@ -27,7 +27,7 @@ func CheckVolumeDataIntegrity(v *Volume, indexFile *os.File) (lastAppendAtNs uin
|
||||
if offset.IsZero() {
|
||||
return 0, nil
|
||||
}
|
||||
if size == TombstoneFileSize {
|
||||
if size.IsDeleted() {
|
||||
size = 0
|
||||
}
|
||||
if lastAppendAtNs, e = verifyNeedleIntegrity(v.DataBackend, v.Version(), offset.ToAcutalOffset(), key, size); e != nil {
|
||||
|
@ -260,7 +260,7 @@ func (v *Volume) readNeedle(n *needle.Needle) (int, error) {
|
||||
if !ok || nv.Offset.IsZero() {
|
||||
return -1, ErrorNotFound
|
||||
}
|
||||
if nv.Size == TombstoneFileSize {
|
||||
if nv.Size.IsDeleted() {
|
||||
return -1, errors.New("already deleted")
|
||||
}
|
||||
if nv.Size == 0 {
|
||||
|
@ -413,7 +413,7 @@ func copyDataBasedOnIndexFile(srcDatName, srcIdxName, dstDatName, datIdxName str
|
||||
|
||||
offset, size := value.Offset, value.Size
|
||||
|
||||
if offset.IsZero() || size == TombstoneFileSize {
|
||||
if offset.IsZero() || size.IsDeleted() {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user