Yield (key, value, timestamp, pos). No locking is performed.
(data, used=0)
| 25 | |
| 26 | |
| 27 | def _read_all_values(data, used=0): |
| 28 | """Yield (key, value, timestamp, pos). No locking is performed.""" |
| 29 | |
| 30 | if used <= 0: |
| 31 | # If not valid `used` value is passed in, read it from the file. |
| 32 | used = _unpack_integer(data, 0)[0] |
| 33 | |
| 34 | pos = 8 |
| 35 | |
| 36 | while pos < used: |
| 37 | encoded_len = _unpack_integer(data, pos)[0] |
| 38 | # check we are not reading beyond bounds |
| 39 | if encoded_len + pos > used: |
| 40 | raise RuntimeError('Read beyond file size detected, file is corrupted.') |
| 41 | pos += 4 |
| 42 | encoded_key = data[pos:pos + encoded_len] |
| 43 | padded_len = encoded_len + (8 - (encoded_len + 4) % 8) |
| 44 | pos += padded_len |
| 45 | value, timestamp = _unpack_two_doubles(data, pos) |
| 46 | yield encoded_key.decode('utf-8'), value, timestamp, pos |
| 47 | pos += 16 |
| 48 | |
| 49 | |
| 50 | class MmapedDict: |
no outgoing calls
no test coverage detected