Source

Immutabase / test_binsearch.py

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

from immutabase import Immutabase, BinarySearchIndex, MultiFileStore

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

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

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

print list(db)