refactoring
This commit is contained in:
@@ -25,7 +25,9 @@ func (v *Volume) garbageLevel() float64 {
|
|||||||
|
|
||||||
func (v *Volume) Compact(preallocate int64, compactionBytePerSecond int64) error {
|
func (v *Volume) Compact(preallocate int64, compactionBytePerSecond int64) error {
|
||||||
|
|
||||||
if v.MemoryMapMaxSizeMb == 0 { //it makes no sense to compact in memory
|
if v.MemoryMapMaxSizeMb != 0 { //it makes no sense to compact in memory
|
||||||
|
return nil
|
||||||
|
}
|
||||||
glog.V(3).Infof("Compacting volume %d ...", v.Id)
|
glog.V(3).Infof("Compacting volume %d ...", v.Id)
|
||||||
//no need to lock for copy on write
|
//no need to lock for copy on write
|
||||||
//v.accessLock.Lock()
|
//v.accessLock.Lock()
|
||||||
@@ -41,14 +43,13 @@ func (v *Volume) Compact(preallocate int64, compactionBytePerSecond int64) error
|
|||||||
v.lastCompactRevision = v.SuperBlock.CompactionRevision
|
v.lastCompactRevision = v.SuperBlock.CompactionRevision
|
||||||
glog.V(3).Infof("creating copies for volume %d ,last offset %d...", v.Id, v.lastCompactIndexOffset)
|
glog.V(3).Infof("creating copies for volume %d ,last offset %d...", v.Id, v.lastCompactIndexOffset)
|
||||||
return v.copyDataAndGenerateIndexFile(filePath+".cpd", filePath+".cpx", preallocate, compactionBytePerSecond)
|
return v.copyDataAndGenerateIndexFile(filePath+".cpd", filePath+".cpx", preallocate, compactionBytePerSecond)
|
||||||
} else {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Volume) Compact2() error {
|
func (v *Volume) Compact2() error {
|
||||||
|
|
||||||
if v.MemoryMapMaxSizeMb == 0 { //it makes no sense to compact in memory
|
if v.MemoryMapMaxSizeMb != 0 { //it makes no sense to compact in memory
|
||||||
|
return nil
|
||||||
|
}
|
||||||
glog.V(3).Infof("Compact2 volume %d ...", v.Id)
|
glog.V(3).Infof("Compact2 volume %d ...", v.Id)
|
||||||
|
|
||||||
v.isCompacting = true
|
v.isCompacting = true
|
||||||
@@ -59,13 +60,12 @@ func (v *Volume) Compact2() error {
|
|||||||
filePath := v.FileName()
|
filePath := v.FileName()
|
||||||
glog.V(3).Infof("creating copies for volume %d ...", v.Id)
|
glog.V(3).Infof("creating copies for volume %d ...", v.Id)
|
||||||
return v.copyDataBasedOnIndexFile(filePath+".cpd", filePath+".cpx")
|
return v.copyDataBasedOnIndexFile(filePath+".cpd", filePath+".cpx")
|
||||||
} else {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Volume) CommitCompact() error {
|
func (v *Volume) CommitCompact() error {
|
||||||
if v.MemoryMapMaxSizeMb == 0 { //it makes no sense to compact in memory
|
if v.MemoryMapMaxSizeMb != 0 { //it makes no sense to compact in memory
|
||||||
|
return nil
|
||||||
|
}
|
||||||
glog.V(0).Infof("Committing volume %d vacuuming...", v.Id)
|
glog.V(0).Infof("Committing volume %d vacuuming...", v.Id)
|
||||||
|
|
||||||
v.isCompacting = true
|
v.isCompacting = true
|
||||||
@@ -115,8 +115,6 @@ func (v *Volume) CommitCompact() error {
|
|||||||
if e = v.load(true, false, v.needleMapKind, 0); e != nil {
|
if e = v.load(true, false, v.needleMapKind, 0); e != nil {
|
||||||
return e
|
return e
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Volume) cleanupCompact() error {
|
func (v *Volume) cleanupCompact() error {
|
||||||
|
|||||||
Reference in New Issue
Block a user