Changeset View
Changeset View
Standalone View
Standalone View
swh/provenance/graph.py
Show First 20 Lines • Show All 170 Lines • ▼ Show 20 Lines | |||||
@statsd.timed(metric=GRAPH_DURATION_METRIC, tags={"method": "build_isochrone_graph"}) | @statsd.timed(metric=GRAPH_DURATION_METRIC, tags={"method": "build_isochrone_graph"}) | ||||
def build_isochrone_graph( | def build_isochrone_graph( | ||||
archive: ArchiveInterface, | archive: ArchiveInterface, | ||||
provenance: ProvenanceInterface, | provenance: ProvenanceInterface, | ||||
revision: RevisionEntry, | revision: RevisionEntry, | ||||
directory: DirectoryEntry, | directory: DirectoryEntry, | ||||
minsize: int = 0, | |||||
) -> IsochroneNode: | ) -> IsochroneNode: | ||||
assert revision.date is not None | assert revision.date is not None | ||||
assert revision.root == directory.id | assert revision.root == directory.id | ||||
# this function process a revision in 2 steps: | # this function process a revision in 2 steps: | ||||
# | # | ||||
# 1. build the tree structure of IsochroneNode objects (one INode per | # 1. build the tree structure of IsochroneNode objects (one INode per | ||||
# directory under the root directory of the revision but not following | # directory under the root directory of the revision but not following | ||||
Show All 16 Lines | while stack: | ||||
# is greater or equal to the current revision's one, it should be ignored as | # is greater or equal to the current revision's one, it should be ignored as | ||||
# the revision is being processed out of order. | # the revision is being processed out of order. | ||||
if current.dbdate is not None and current.dbdate > revision.date: | if current.dbdate is not None and current.dbdate > revision.date: | ||||
current.invalidate() | current.invalidate() | ||||
# Pre-query all known dates for directories in the current directory | # Pre-query all known dates for directories in the current directory | ||||
# for the provenance object to have them cached and (potentially) improve | # for the provenance object to have them cached and (potentially) improve | ||||
# performance. | # performance. | ||||
current.entry.retrieve_children(archive) | current.entry.retrieve_children(archive, minsize=minsize) | ||||
ddates = provenance.directory_get_dates_in_isochrone_frontier( | ddates = provenance.directory_get_dates_in_isochrone_frontier( | ||||
current.entry.dirs | current.entry.dirs | ||||
) | ) | ||||
for dir in current.entry.dirs: | for dir in current.entry.dirs: | ||||
# Recursively analyse subdirectory nodes | # Recursively analyse subdirectory nodes | ||||
node = current.add_directory(dir, date=ddates.get(dir.id, None)) | node = current.add_directory(dir, date=ddates.get(dir.id, None)) | ||||
stack.append(node) | stack.append(node) | ||||
▲ Show 20 Lines • Show All 55 Lines • Show Last 20 Lines |