255
255
# If we have nothing left to decomp, we ran out of decomp bytes
256
256
assert remaining_decomp
257
257
needed_bytes = num_bytes - len(self._content)
258
# We always set max_size to 32kB over the minimum needed, so that zlib
259
# will give us as much as we really want.
260
# TODO: If this isn't good enough, we could make a loop here, that
261
# keeps expanding the request until we get enough
258
# We always set max_size to 32kB over the minimum needed, so that
259
# zlib will give us as much as we really want.
260
# TODO: If this isn't good enough, we could make a loop here,
261
# that keeps expanding the request until we get enough
262
262
self._content += self._z_content_decompressor.decompress(
263
263
remaining_decomp, needed_bytes + _ZLIB_DECOMP_WINDOW)
264
264
assert len(self._content) >= num_bytes
965
969
source = key_to_source_map.get(key, self)
966
970
if source is not current_source:
967
971
source_keys.append((source, []))
972
current_source = source
968
973
source_keys[-1][1].append(key)
969
974
return source_keys
1039
1045
unadded_keys, source_result)
1040
1046
for key in missing:
1041
1047
yield AbsentContentFactory(key)
1049
lazy_buffered = None
1042
1050
for source, keys in source_keys:
1043
1051
if source is self:
1044
1052
for key in keys:
1045
1053
if key in self._unadded_refs:
1055
for factory in lazy_buffered:
1057
lazy_buffered = None
1046
1059
bytes, sha1 = self._compressor.extract(key)
1047
1060
parents = self._unadded_refs[key]
1061
yield FulltextContentFactory(key, parents, sha1, bytes)
1049
1063
index_memo, _, parents, (method, _) = locations[key]
1050
1064
block = self._get_block(index_memo)
1051
1065
start, end = index_memo[3:5]
1052
entry, bytes = block.extract(key, start, end)
1054
# TODO: If we don't have labels, then the sha1 here is
1055
# computed from the data, so we don't want to
1056
# re-sha the string.
1057
if not _FAST and sha_string(bytes) != sha1:
1058
raise AssertionError('sha1 sum did not match')
1059
yield FulltextContentFactory(key, parents, sha1, bytes)
1066
if block is last_block:
1070
factory = LazyGroupCompressFactory(key,
1071
parents, block, start, end, first)
1073
# The first entry in a new group
1075
for old in lazy_buffered:
1077
lazy_buffered = [factory]
1079
lazy_buffered.append(factory)
1082
# We need to flush everything we have buffered so far
1084
for factory in lazy_buffered:
1086
lazy_buffered = None
1061
1088
for record in source.get_record_stream(keys, ordering,
1062
1089
include_delta_closure):
1092
for factory in lazy_buffered:
1094
lazy_buffered = None
1065
1097
def get_sha1s(self, keys):
1066
1098
"""See VersionedFiles.get_sha1s()."""