3322
3322
# Delta records that need their compression parent before they can be
3324
3324
self._pending_deltas = {}
3325
# Fulltext records that are waiting for their parents fulltexts before
3326
# they can be yielded for annotation
3327
self._pending_annotation = {}
3326
3329
self._all_build_details = {}
3409
3412
# can set 'copy_base_content = False' and remove base_content
3410
3413
# from the cache (to be inserted as the new content)
3411
3414
content, _ = self._vf._factory.parse_record(
3412
key, record, record_details, None, copy_base_content=True)
3415
key, record, record_details, base_content,
3416
copy_base_content=True)
3414
3418
# Fulltext record
3415
3419
content, _ = self._vf._factory.parse_record(
3435
3439
# self._content_objects[child_key] = child_content
3436
3440
# to_process.append((child_key, child_parent_keys, child_content))
3442
def _process_pending(self, key):
3443
"""The content for 'key' was just processed.
3445
Determine if there is any more pending work to be processed.
3447
if key not in self._pending_deltas:
3449
compression_parent = key
3450
children = self._pending_deltas.pop(key)
3452
for key, parent_keys, record, record_details in children:
3453
lines = self._expand_record(key, parent_keys, compression_parent,
3454
record, record_details)
3455
assert lines is not None
3456
if self._check_ready_for_annotations(key, parent_keys):
3457
to_return.append(key)
3459
def _check_ready_for_annotations(self, key, parent_keys):
3460
"""return true if this text is ready to be yielded.
3462
Otherwise, this will return False, and queue the text into
3463
self._pending_annotation
3465
for parent_key in parent_keys:
3466
if parent_key not in self._annotations_cache:
3467
# still waiting on at least one parent text, so queue it up
3468
# Note that if there are multiple parents, we need to wait
3470
self._pending_annotation.setdefault(parent_key,
3471
[]).append((key, parent_keys))
3438
3475
def _extract_texts(self, records):
3439
3476
"""Extract the various texts needed based on records"""
3440
3477
# We iterate in the order read, rather than a strict order requested
3465
3502
# that we know when we can re-use the content lines, and the annotation
3466
3503
# code can know when it can stop caching fulltexts, as well.
3468
# Children that we want to annotate as soon as we get the parent text
3469
# Map from parent_key => [child_key]
3470
pending_annotation = {}
3471
3505
# Children that are missing their compression parent
3472
3506
pending_deltas = {}
3473
3507
for (key, record, digest) in self._vf._read_records_iter(records):
3483
3517
# At this point, we may be able to yield this content, if all
3484
3518
# parents are also finished
3485
yield_this_text = True
3486
for parent_key in parent_keys:
3487
if parent_key not in self._annotations_cache:
3488
# still waiting on at least one parent text, so queue it up
3489
# Note that if there are multiple parents, we need to wait
3491
pending_annotation.setdefault(parent_key,
3492
[]).append((key, parent_keys, content))
3493
yield_this_text = False
3519
yield_this_text = self._check_ready_for_annotations(key,
3495
3521
if yield_this_text:
3496
3522
# All parents present
3497
3523
yield key, lines, len(lines)