mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-10-22 03:57:23 +08:00
refactoring to typed Size
Go is amazing with refactoring!
This commit is contained in:
@@ -18,14 +18,14 @@ type mapMetric struct {
|
||||
MaximumFileKey uint64 `json:"MaxFileKey"`
|
||||
}
|
||||
|
||||
func (mm *mapMetric) logDelete(deletedByteCount uint32) {
|
||||
func (mm *mapMetric) logDelete(deletedByteCount Size) {
|
||||
if mm == nil {
|
||||
return
|
||||
}
|
||||
mm.LogDeletionCounter(deletedByteCount)
|
||||
}
|
||||
|
||||
func (mm *mapMetric) logPut(key NeedleId, oldSize uint32, newSize uint32) {
|
||||
func (mm *mapMetric) logPut(key NeedleId, oldSize Size, newSize Size) {
|
||||
if mm == nil {
|
||||
return
|
||||
}
|
||||
@@ -35,14 +35,14 @@ func (mm *mapMetric) logPut(key NeedleId, oldSize uint32, newSize uint32) {
|
||||
mm.LogDeletionCounter(oldSize)
|
||||
}
|
||||
}
|
||||
func (mm *mapMetric) LogFileCounter(newSize uint32) {
|
||||
func (mm *mapMetric) LogFileCounter(newSize Size) {
|
||||
if mm == nil {
|
||||
return
|
||||
}
|
||||
atomic.AddUint32(&mm.FileCounter, 1)
|
||||
atomic.AddUint64(&mm.FileByteCounter, uint64(newSize))
|
||||
}
|
||||
func (mm *mapMetric) LogDeletionCounter(oldSize uint32) {
|
||||
func (mm *mapMetric) LogDeletionCounter(oldSize Size) {
|
||||
if mm == nil {
|
||||
return
|
||||
}
|
||||
@@ -97,7 +97,7 @@ func newNeedleMapMetricFromIndexFile(r *os.File) (mm *mapMetric, err error) {
|
||||
buf := make([]byte, NeedleIdSize)
|
||||
err = reverseWalkIndexFile(r, func(entryCount int64) {
|
||||
bf = bloom.NewWithEstimates(uint(entryCount), 0.001)
|
||||
}, func(key NeedleId, offset Offset, size uint32) error {
|
||||
}, func(key NeedleId, offset Offset, size Size) error {
|
||||
|
||||
mm.MaybeSetMaxFileKey(key)
|
||||
NeedleIdToBytes(buf, key)
|
||||
@@ -121,7 +121,7 @@ func newNeedleMapMetricFromIndexFile(r *os.File) (mm *mapMetric, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func reverseWalkIndexFile(r *os.File, initFn func(entryCount int64), fn func(key NeedleId, offset Offset, size uint32) error) error {
|
||||
func reverseWalkIndexFile(r *os.File, initFn func(entryCount int64), fn func(key NeedleId, offset Offset, size Size) error) error {
|
||||
fi, err := r.Stat()
|
||||
if err != nil {
|
||||
return fmt.Errorf("file %s stat error: %v", r.Name(), err)
|
||||
|
Reference in New Issue
Block a user