494
494
return self._manager._wire_bytes()
497
self._manager = None # safe?
498
497
if storage_kind in ('fulltext', 'chunked'):
499
498
if self._bytes is None:
500
# Grab the raw bytes for this entry, and break the ref-cycle
499
# Grab and cache the raw bytes for this entry
500
# and break the ref-cycle with _manager since we don't need it
501
502
self._manager._prepare_for_extract()
502
503
block = self._manager._block
503
504
self._bytes = block.extract(self.key, self._start, self._end)
1302
1303
for key in keys:
1303
1304
if key in self._unadded_refs:
1304
1305
if manager is not None:
1305
# Yield everything buffered so far
1306
1306
for factory in manager.get_record_stream():
1308
# Disable this record, breaks the refcycle, and
1309
# saves memory. But this means clients really
1310
# *cannot* hang on to objects.
1311
factory._bytes = None
1312
factory._manager = None
1308
last_read_memo = manager = None
1314
1309
bytes, sha1 = self._compressor.extract(key)
1315
1310
parents = self._unadded_refs[key]
1316
1311
yield FulltextContentFactory(key, parents, sha1, bytes)
1318
1313
index_memo, _, parents, (method, _) = locations[key]
1319
1314
read_memo = index_memo[0:3]
1320
if last_memo == read_memo:
1315
if last_read_memo != read_memo:
1316
# We are starting a new block. If we have a
1317
# manager, we have found everything that fits for
1318
# now, so yield records
1319
if manager is not None:
1320
for factory in manager.get_record_stream():
1322
# Now start a new manager
1323
1323
block = self._get_block(index_memo)
1325
last_memo = read_memo
1324
manager = _LazyGroupContentManager(block)
1325
last_read_memo = read_memo
1326
1326
start, end = index_memo[3:5]
1328
manager = _LazyGroupContentManager(block)
1329
elif manager._block is not block:
1330
# Flush and create a new manager
1331
for factory in manager.get_record_stream():
1333
manager = _LazyGroupContentManager(block)
1334
1327
manager.add_factory(key, parents, start, end)
1336
1329
if manager is not None:
1337
# Yield everything buffered so far
1338
1330
for factory in manager.get_record_stream():
1332
last_read_memo = manager = None
1341
1333
for record in source.get_record_stream(keys, ordering,
1342
1334
include_delta_closure):
1344
1336
if manager is not None:
1345
# Yield everything buffered so far
1346
1337
for factory in manager.get_record_stream():
1350
1340
def get_sha1s(self, keys):
1351
1341
"""See VersionedFiles.get_sha1s()."""