Example #1
0
def test_persistent_hash_collisions2():
    HashTable = make_persistent_hash_type(hashfun=lambda x: r_uint(hash(x)) % 8)
    acc = HashTable.EMPTY

    for i in range(2048):
        validate_persistent_hash(acc)
        acc = acc.assoc(i % 128, i)

    assert len(acc) == 128
    assert len(list(acc.iteritems())) == 128
    for k, v in acc.iteritems():
        assert acc.val_at(k, None) is v
Example #2
0
def test_persistent_hash_collisions2():
    HashTable = make_persistent_hash_type(hashfun=lambda x: r_uint(hash(x)) % 8)
    acc = HashTable.EMPTY

    for i in range(2048):
        validate_persistent_hash(acc)
        acc = acc.assoc(i % 128, i)

    assert len(acc) == 128
    assert len(list(acc.iteritems())) == 128
    for k, v in acc.iteritems():
        assert acc.val_at(k, None) is v
Example #3
0
def test_persistent_hash_collisions():
    HashTable = make_persistent_hash_type(hashfun=lambda x: r_uint(42))
    acc = HashTable.EMPTY

    for i in range(1000):
        validate_persistent_hash(acc)
        acc = acc.assoc(i % 10, i)

    assert len(acc) == 10
    assert len(list(acc.iteritems())) == 10
    for k, v in acc.iteritems():
        assert k <= 10
        assert v >= 990
        assert v % 10 == k
        assert acc.val_at(k, None) is v
Example #4
0
def test_persistent_hash_collisions():
    HashTable = make_persistent_hash_type(hashfun=lambda x: r_uint(42))
    acc = HashTable.EMPTY

    for i in range(1000):
        validate_persistent_hash(acc)
        acc = acc.assoc(i % 10, i)

    assert len(acc) == 10
    assert len(list(acc.iteritems())) == 10
    for k, v in acc.iteritems():
        assert k <= 10
        assert v >= 990
        assert v % 10 == k
        assert acc.val_at(k, None) is v
Example #5
0
def test_persistent_hash2():
    HashTable = make_persistent_hash_type()
    acc = HashTable.EMPTY()

    for i in range(1000):
        validate_persistent_hash(acc)
        acc = acc.assoc(i % 10, i)

    for i in range(1000):
        validate_persistent_hash(acc)
        acc = acc.assoc(i % 10, i)

    assert len(acc) == 10
    assert len(list(acc.iteritems())) == 10
    for k, v in acc.iteritems():
        assert k <= 10
        assert v >= 990
        assert v % 10 == k
        assert acc.val_at(k, None) is v
Example #6
0
def test_persistent_hash2():
    HashTable = make_persistent_hash_type()
    acc = HashTable.EMPTY()

    for i in range(1000):
        validate_persistent_hash(acc)
        acc = acc.assoc(i % 10, i)

    for i in range(1000):
        validate_persistent_hash(acc)
        acc = acc.assoc(i % 10, i)

    assert len(acc) == 10
    assert len(list(acc.iteritems())) == 10
    for k, v in acc.iteritems():
        assert k <= 10
        assert v >= 990
        assert v % 10 == k
        assert acc.val_at(k, None) is v
Example #7
0
def test_persistent_hash__collisions_removal2():
    HashTable = make_persistent_hash_type(hashfun=lambda x: r_uint(hash(x) % 8))
    acc = HashTable.EMPTY()

    for i in range(1000):
        validate_persistent_hash(acc)
        acc = acc.assoc(i % 10, i).without(i % 10)

    assert len(acc) == 0
    assert list(acc.iteritems()) == []

    for i in range(1000):
        validate_persistent_hash(acc)
        acc = acc.assoc(i % 10, i).without(i % 10 + 1)

    assert len(acc) == 10
    assert len(list(acc.iteritems())) == 10
    for k, v in acc.iteritems():
        assert k <= 10
        assert v >= 990
        assert v % 10 == k
        assert acc.val_at(k, None) is v
Example #8
0
def test_persistent_hash__collisions_removal2():
    HashTable = make_persistent_hash_type(
        hashfun=lambda x: r_uint(hash(x) % 8))
    acc = HashTable.EMPTY()

    for i in range(1000):
        validate_persistent_hash(acc)
        acc = acc.assoc(i % 10, i).without(i % 10)

    assert len(acc) == 0
    assert list(acc.iteritems()) == []

    for i in range(1000):
        validate_persistent_hash(acc)
        acc = acc.assoc(i % 10, i).without(i % 10 + 1)

    assert len(acc) == 10
    assert len(list(acc.iteritems())) == 10
    for k, v in acc.iteritems():
        assert k <= 10
        assert v >= 990
        assert v % 10 == k
        assert acc.val_at(k, None) is v