kelindar / bitmap

Simple dense bitmap index in Go with binary operators
MIT License
306 stars 23 forks source link

AVX2. And operation produce wrong result when bitmaps have different sizes. V2 #14

Closed marniks7 closed 3 years ago

marniks7 commented 3 years ago

Hi, one more failing test: bigger, smaller, bigger

func TestAnd_ConsecutiveAnd_DifferentBitmapSizes(t *testing.T) {
    a, b, c := Bitmap{}, Bitmap{}, Bitmap{}
    for i := uint32(0); i < 200; i += 2 {
        a.Set(i)
    }

    for i := uint32(0); i < 100; i += 2 {
        b.Set(i)
    }

    for i := uint32(0); i < 200; i += 2 {
        c.Set(i)
    }

    a.And(b)
    a.And(c)

    for i := uint32(0); i < 200; i++ {
        assert.Equal(t, a.Contains(i), b.Contains(i), "for "+strconv.Itoa(int(i)))
    }
    assert.Equal(t, 50, a.Count())
}
  bitmap_test.go:380: 
            Error Trace:    bitmap_test.go:380
            Error:          Not equal: 
                            expected: true
                            actual  : false
            Test:           TestAnd_DifferentBitmapSizes
            Messages:       for 128
    bitmap_test.go:380: 
            Error Trace:    bitmap_test.go:380
            Error:          Not equal: 
                            expected: true
                            actual  : false
            Test:           TestAnd_DifferentBitmapSizes
            Messages:       for 130
kelindar commented 3 years ago

Amazing, thanks for the nice tests

kelindar commented 3 years ago

15 should fix it