MCPcopy Create free account
hub / github.com/tensorflow/datasets / read_values

Method read_values

tensorflow_datasets/core/shuffle.py:189–207  ·  view source on GitHub ↗

Yields (hkey, data) tuples stored in bucket.

(self)

Source from the content-addressed store, hash-verified

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):

Callers 1

_iter_bucketsMethod · 0.80

Calls 4

flushMethod · 0.95
_read_hkeyFunction · 0.85
existsMethod · 0.80
readMethod · 0.45

Tested by

no test coverage detected