mononoke: walker: filter the repo path by node type

Summary:
Not all node types can have a path associated

Reset the tracked path to None if the route is taking us through a node type that can't have a repo path.

Reviewed By: krallin

Differential Revision: D21228372

fbshipit-source-id: 2b1e291f09232500adce79c630d428f09cd2d2cc
This commit is contained in:
Alex Hornby 2020-05-11 11:58:27 -07:00 committed by Facebook GitHub Bot
parent d64505bfff
commit 1c044613f8
2 changed files with 32 additions and 6 deletions

View File

@ -62,23 +62,23 @@ Three separate cycles allowing all edges, total bytes should be the same as full
* Run */s,*/s,579,579,0%,*s; * (glob)
Walked/s,* (glob)
Reduced edge three separate cycles moving offset each time, total in each cycle should be the same as above. Its not.
Reduced edge three separate cycles moving offset each time, total in each cycle should be the same as above.
$ for i in {0..2}; do mononoke_walker --storage-id=blobstore --readonly-storage compression-benefit -q --bookmark master_bookmark -I deep -x BonsaiFsnodeMapping -x Fsnode -X BonsaiChangesetToBonsaiParent -X HgFileEnvelopeToFileContent -X HgChangesetToHgParent --sample-rate=3 --sample-offset=$i 2>&1; done | strip_glog
Walking roots * (glob)
Walking edge types * (glob)
Walking node types * (glob)
Final count: * (glob)
* Run */s,*/s,1045,1016,2%,*s; * (glob)
* Run */s,*/s,1146,1117,2%,*s; * (glob)
Walked/s,* (glob)
Walking roots * (glob)
Walking edge types * (glob)
Walking node types * (glob)
Final count: * (glob)
* Run */s,*/s,522,522,0%,*s;* (glob)
* Run */s,*/s,443,443,0%,*s;* (glob)
Walked/s,* (glob)
Walking roots * (glob)
Walking edge types * (glob)
Walking node types * (glob)
Final count: * (glob)
* Run */s,*/s,601,601,0%,*s; * (glob)
* Run */s,*/s,579,579,0%,*s; * (glob)
Walked/s,* (glob)

View File

@ -47,6 +47,32 @@ pub struct PathTrackingRoute {
pub path: Option<WrappedPath>,
}
// Only certain node types can have repo paths associated
fn filter_repo_path(node_type: NodeType, path: Option<&'_ WrappedPath>) -> Option<&'_ WrappedPath> {
match node_type {
NodeType::Root => None,
// Bonsai
NodeType::Bookmark => None,
NodeType::BonsaiChangeset => None,
NodeType::BonsaiHgMapping => None,
NodeType::BonsaiPhaseMapping => None,
NodeType::PublishedBookmarks => None,
NodeType::BonsaiFsnodeMapping => None,
// Hg
NodeType::HgBonsaiMapping => None,
NodeType::HgChangeset => None,
NodeType::HgManifest => path,
NodeType::HgFileEnvelope => path,
NodeType::HgFileNode => path,
// Content
NodeType::FileContent => path,
NodeType::FileContentMetadata => path,
NodeType::AliasContentMapping => path,
// Derived Data
NodeType::Fsnode => path,
}
}
impl PathTrackingRoute {
fn evolve_path<'a>(
from_route: Option<&'a WrappedPath>,
@ -59,8 +85,8 @@ impl PathTrackingRoute {
None => match target.stats_path() {
// Path is part of node identity
Some(from_node) => Some(from_node),
// No per-node path, so use the path from route
None => from_route,
// No per-node path, so use the route, filtering out nodes that can't have repo paths
None => filter_repo_path(target.get_type(), from_route),
},
}
}