Yields (hkey, data) tuples stored in bucket.
(self)
| 187 | self._fobj.close() |
| 188 | |
| 189 | def read_values(self): |
| 190 | """Yields (hkey, data) tuples stored in bucket.""" |
| 191 | self.flush() |
| 192 | path = self._path |
| 193 | if not tf.io.gfile.exists(path): |
| 194 | # In case bucket was created but nothing was ever added. |
| 195 | # This is likely to happen if the number of buckets is large compared to |
| 196 | # the number of generated examples. |
| 197 | return |
| 198 | with tf.io.gfile.GFile(path, 'rb') as fobj: |
| 199 | while True: |
| 200 | buff = fobj.read(HKEY_SIZE_BYTES) |
| 201 | if not buff: |
| 202 | break |
| 203 | hkey = _read_hkey(buff) |
| 204 | size_bytes = fobj.read(8) |
| 205 | size = struct.unpack('=Q', size_bytes)[0] |
| 206 | data = fobj.read(size) |
| 207 | yield hkey, data |
| 208 | |
| 209 | def del_file(self): |
| 210 | if tf.io.gfile.exists(self._path): |
no test coverage detected