Chris Lu
5 years ago
8 changed files with 63 additions and 15 deletions
-
2weed/command/backup.go
-
5weed/command/compact.go
-
2weed/storage/needle_map_memory.go
-
31weed/storage/needle_map_metric_test.go
-
2weed/storage/store_vacuum.go
-
2weed/storage/volume_loading.go
-
32weed/storage/volume_vacuum.go
-
2weed/storage/volume_vacuum_test.go
@ -0,0 +1,31 @@ |
|||
package storage |
|||
|
|||
import ( |
|||
"io/ioutil" |
|||
"math/rand" |
|||
"testing" |
|||
|
|||
"github.com/chrislusf/seaweedfs/weed/glog" |
|||
. "github.com/chrislusf/seaweedfs/weed/storage/types" |
|||
) |
|||
|
|||
func TestFastLoadingNeedleMapMetrics(t *testing.T) { |
|||
|
|||
idxFile, _ := ioutil.TempFile("", "tmp.idx") |
|||
nm := NewCompactNeedleMap(idxFile) |
|||
|
|||
for i := 0; i < 10000; i++ { |
|||
nm.Put(Uint64ToNeedleId(uint64(i+1)), Uint32ToOffset(uint32(0)), uint32(1)) |
|||
if rand.Float32() < 0.2 { |
|||
nm.Delete(Uint64ToNeedleId(uint64(rand.Int63n(int64(i))+1)), Uint32ToOffset(uint32(0))) |
|||
} |
|||
} |
|||
|
|||
mm, _ := newNeedleMapMetricFromIndexFile(idxFile) |
|||
|
|||
glog.V(0).Infof("FileCount expected %d actual %d", nm.FileCount(), mm.FileCount()) |
|||
glog.V(0).Infof("DeletedSize expected %d actual %d", nm.DeletedSize(), mm.DeletedSize()) |
|||
glog.V(0).Infof("ContentSize expected %d actual %d", nm.ContentSize(), mm.ContentSize()) |
|||
glog.V(0).Infof("DeletedCount expected %d actual %d", nm.DeletedCount(), mm.DeletedCount()) |
|||
glog.V(0).Infof("MaxFileKey expected %d actual %d", nm.MaxFileKey(), mm.MaxFileKey()) |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue