|
@ -5,6 +5,7 @@ import ( |
|
|
"io/ioutil" |
|
|
"io/ioutil" |
|
|
"math/rand" |
|
|
"math/rand" |
|
|
"github.com/chrislusf/seaweedfs/weed/glog" |
|
|
"github.com/chrislusf/seaweedfs/weed/glog" |
|
|
|
|
|
. "github.com/chrislusf/seaweedfs/weed/storage/types" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
func TestFastLoadingNeedleMapMetrics(t *testing.T) { |
|
|
func TestFastLoadingNeedleMapMetrics(t *testing.T) { |
|
@ -13,9 +14,9 @@ func TestFastLoadingNeedleMapMetrics(t *testing.T) { |
|
|
nm := NewBtreeNeedleMap(idxFile) |
|
|
nm := NewBtreeNeedleMap(idxFile) |
|
|
|
|
|
|
|
|
for i := 0; i < 10000; i++ { |
|
|
for i := 0; i < 10000; i++ { |
|
|
nm.Put(uint64(i+1), uint32(0), uint32(1)) |
|
|
|
|
|
|
|
|
nm.Put(Uint64ToNeedleId(uint64(i+1)), Uint32ToOffset(uint32(0)), uint32(1)) |
|
|
if rand.Float32() < 0.2 { |
|
|
if rand.Float32() < 0.2 { |
|
|
nm.Delete(uint64(rand.Int63n(int64(i))+1), uint32(0)) |
|
|
|
|
|
|
|
|
nm.Delete(Uint64ToNeedleId(uint64(rand.Int63n(int64(i))+1)), Uint32ToOffset(uint32(0))) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|