An in memory index that allows rapid random access into a file.
The class can be used to turn a file into a read-only
database.
Methods
|
|
__getitem__
__init__
|
|
__getitem__
|
__getitem__ ( self, key )
Return an item from the indexed file.
|
|
__init__
|
__init__ (
self,
filename,
iterator_gen,
key_gen,
)
Arguments:
- filename
- The file to index
- iterator_gen
- A function that eats a file handle, and returns
a file iterator. The iterator has a method next()
that returns the next item to be indexed from the file.
- key_gen
- A function that generates an index key from the items
created by the iterator.
|
|