Method
__init__
(self, path, process_fn=None)
Source from the content-addressed store, hash-verified
| 17 | |
| 18 | class LMDBDataset(Dataset): |
| 19 | def __init__(self, path, process_fn=None): |
| 20 | import lmdb |
| 21 | |
| 22 | self.path = path |
| 23 | self.env = lmdb.open( |
| 24 | path, |
| 25 | max_readers=32, |
| 26 | readonly=True, |
| 27 | lock=False, |
| 28 | readahead=False, |
| 29 | meminit=False, |
| 30 | ) |
| 31 | self.process_fn = process_fn |
| 32 | if not self.env: |
| 33 | raise IOError("Cannot open lmdb dataset", path) |
| 34 | |
| 35 | with self.env.begin(write=False) as txn: |
| 36 | self.length = int(txn.get("length".encode("utf-8")).decode("utf-8")) |
| 37 | |
| 38 | def __len__(self): |
| 39 | return self.length |
Callers
nothing calls this directly
Tested by
no test coverage detected