(self, idx)
| 39 | return self.length |
| 40 | |
| 41 | def __getitem__(self, idx): |
| 42 | # print(f"Get {self.path}: {idx}") |
| 43 | with self.env.begin(write=False) as txn: |
| 44 | key = str(idx).encode("utf-8") |
| 45 | # row = pickle.loads(txn.get(key)) |
| 46 | try: |
| 47 | row = pickle.loads(txn.get(key)) |
| 48 | except TypeError: |
| 49 | raise IndexError("Index out of range") |
| 50 | if self.process_fn: |
| 51 | return self.process_fn(row) |
| 52 | else: |
| 53 | return row |
| 54 | |
| 55 | |
| 56 | class PadDataset(Dataset): |