This commit is contained in:
Chris Lu
2020-09-12 04:08:03 -07:00
parent ea26a98753
commit 446e476a11
8 changed files with 12 additions and 15 deletions

View File

@@ -65,7 +65,7 @@ func (nm *NeedleMap) Get(key NeedleId) (existingValue *needle_map.NeedleValue, o
}
func (nm *NeedleMap) Delete(key NeedleId) error {
existingValue, ok := nm.m.Get(NeedleId(key))
if !ok || existingValue.Size.IsDeleted(){
if !ok || existingValue.Size.IsDeleted() {
return nil
}
deletedBytes := nm.m.Delete(NeedleId(key))

View File

@@ -17,7 +17,7 @@ func TestFastLoadingNeedleMapMetrics(t *testing.T) {
for i := 0; i < 10000; i++ {
nm.Put(Uint64ToNeedleId(uint64(i+1)), Uint32ToOffset(uint32(0)), Size(1))
if rand.Float32() < 0.2 {
nm.Delete(Uint64ToNeedleId(uint64(rand.Int63n(int64(i))+1)))
nm.Delete(Uint64ToNeedleId(uint64(rand.Int63n(int64(i)) + 1)))
}
}