Source

Immutabase / test_diskhash.py

Full commit
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Author: eph

from immutabase import Immutabase, DiskHashIndex, MultiFileStore

db = Immutabase('diskhash.db', 'w', index=DiskHashIndex(), store=MultiFileStore())
for i in xrange(1000):
    db[str(i)] = i
db.close()

db = Immutabase('diskhash.db', 'a', index=DiskHashIndex(), store=MultiFileStore())
for i in xrange(1000, 2000):
    db[str(i)] = i
db.close()

db = Immutabase('diskhash.db', index=DiskHashIndex(), store=MultiFileStore())
for i in xrange(2000):
    if db[str(i)] != i:
        print 'Error:', db[str(i)], '!=', i

print list(db)