LmdbBackend¶
- class mmeval.fileio.LmdbBackend(db_path, readonly=True, lock=False, readahead=False, **kwargs)[source]¶
Lmdb storage backend.
- Parameters
db_path (str) – Lmdb database path.
readonly (bool) – Lmdb environment parameter. If True, disallow any write operations. Defaults to True.
lock (bool) – Lmdb environment parameter. If False, when concurrent access occurs, do not lock the database. Defaults to False.
readahead (bool) – Lmdb environment parameter. If False, disable the OS filesystem readahead mechanism, which may improve random read performance when a database is larger than RAM. Defaults to False.
**kwargs – Keyword arguments passed to lmdb.open.
- db_path¶
Lmdb database path.
- Type
str
- get(filepath: Union[str, pathlib.Path]) → bytes[source]¶
Get values according to the filepath.
- Parameters
filepath (str or Path) – Here, filepath is the lmdb key.
- Returns
Expected bytes object.
- Return type
bytes
Examples
>>> backend = LmdbBackend('path/to/lmdb') >>> backend.get('key') b'hello world'