Skip to content

Really high false negative rate in ScalableCuckooFilter #50

@duongcongtoai

Description

@duongcongtoai

The feature of having a scalable cuckooFilter is really convenient but for my usecase the application cannot tolerate false negative.
To reproduce

func Test_ScalableCuckooFilter_FalseNegative(t *testing.T) {
	filter := NewScalableCuckooFilter()

	// filter := NewFilter(100000)
	exist := []string{}
	removed := []string{}
	for i := 0; i < 15000; i++ {
		id := fmt.Sprintf("%d-", i) + uuid.NewString()
		exist = append(exist, id)
		removed = append(removed, id+"to-removed")
	}
	for i := 0; i < len(exist); i++ {
		filter.Insert([]byte(exist[i]))
	}
	for i := 0; i < len(exist); i++ {
		filter.Insert([]byte(removed[i]))
	}

	for i := 0; i < len(exist); i++ {
		filter.Delete([]byte(removed[i]))
	}
	for i := 0; i < len(exist); i++ {
		filter.Insert([]byte(removed[i]))
	}
	falseNegatives := []int{}
	for i := 0; i < len(exist); i++ {
		exist := filter.Lookup([]byte(exist[i]))
		if !exist {
			falseNegatives = append(falseNegatives, i)
		}
	}
	assert.Equal(t, 0, len(falseNegatives))
}

And the result

    scalable_cuckoofilter_test.go:43: 
        	Error Trace:	scalable_cuckoofilter_test.go:43
        	Error:      	Not equal: 
        	            	expected: 0
        	            	actual  : 160
        	Test:       	Test_ScalableCuckooFilter_FalseNegative
--- FAIL: Test_ScalableCuckooFilter_FalseNegative (0.02s)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions