MCPcopy Index your code
hub / github.com/prometheus/client_python / _read_all_values

Function _read_all_values

prometheus_client/mmap_dict.py:27–47  ·  view source on GitHub ↗

Yield (key, value, timestamp, pos). No locking is performed.

(data, used=0)

Source from the content-addressed store, hash-verified

25
26
27def _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
50class MmapedDict:

Callers 2

_read_all_valuesMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected