sile / scalable_cuckoo_filter

A variant of Cuckoo Filter whose size automatically scales as necessary
MIT License
18 stars 7 forks source link

Bug: `Bits::set_uint` not working as expected #6

Closed michael-yxchen closed 1 year ago

michael-yxchen commented 1 year ago

The variable high is off. It should be shifted by (size + offset) instead.

Test to reproduce the error

#[test]
    fn test_high_bits() {
        let mut bits = Bits::new(320);
        assert_eq!(bits.len(), 320);

        assert_eq!(bits.get_uint(290, 5), 0);
        bits.set_uint(290, 5, 31);
        assert_eq!(bits.get_uint(290, 5), 31);
        bits.set_uint(290, 5, 21);
        assert_eq!(bits.get_uint(290, 5), 21); // line 84
    }

Test error

---- bits::test::test_high_bits stdout ----
thread 'bits::test::test_high_bits' panicked at src/bits.rs:84:9:
assertion `left == right` failed
  left: 29
 right: 21

I'm planning to fix the issue myself. Any help reviewing is greatly appreciated!