mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 00:45:18 +03:00
mononoke: introduce WrappedPathLike to walker
Summary: This new trait abstracts across WrappedPath and WrapperPathHash. Later in the stack I make path tracking use this to track either full paths (for corpus sampling) or path hashes (for logging from scrub). Differential Revision: D28031870 fbshipit-source-id: d1c57230f68fffff179929a3cb92c82d92e0588c
This commit is contained in:
parent
71994ae65d
commit
901fe40f5f
@ -515,6 +515,11 @@ impl NodeType {
|
||||
|
||||
const ROOT_FINGERPRINT: u64 = 0;
|
||||
|
||||
// Can represent Path and PathHash
|
||||
pub trait WrappedPathLike {
|
||||
fn sampling_fingerprint(&self) -> u64;
|
||||
}
|
||||
|
||||
/// Represent root or non root path hash.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
pub enum WrappedPathHash {
|
||||
@ -522,8 +527,8 @@ pub enum WrappedPathHash {
|
||||
NonRoot(MPathHash),
|
||||
}
|
||||
|
||||
impl WrappedPathHash {
|
||||
pub fn sampling_fingerprint(&self) -> u64 {
|
||||
impl WrappedPathLike for WrappedPathHash {
|
||||
fn sampling_fingerprint(&self) -> u64 {
|
||||
match self {
|
||||
WrappedPathHash::Root => ROOT_FINGERPRINT,
|
||||
WrappedPathHash::NonRoot(path_hash) => path_hash.sampling_fingerprint(),
|
||||
@ -590,8 +595,10 @@ impl WrappedPath {
|
||||
WrappedPath::NonRoot(path) => path.get_path_hash_memo(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn sampling_fingerprint(&self) -> u64 {
|
||||
impl WrappedPathLike for WrappedPath {
|
||||
fn sampling_fingerprint(&self) -> u64 {
|
||||
self.get_path_hash().sampling_fingerprint()
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
* GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
use crate::graph::{EdgeType, Node, NodeData, NodeType, WrappedPath};
|
||||
use crate::graph::{EdgeType, Node, NodeData, NodeType, WrappedPath, WrappedPathLike};
|
||||
use crate::state::{InternedType, StepStats, WalkState};
|
||||
use crate::walk::{EmptyRoute, OutgoingEdge, StepRoute, TailingWalkVisitor, VisitOne, WalkVisitor};
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
* GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
use crate::graph::{FileContentData, Node, NodeData, NodeType};
|
||||
use crate::graph::{FileContentData, Node, NodeData, NodeType, WrappedPathLike};
|
||||
use crate::log;
|
||||
use crate::pack::{PackInfo, PackInfoLogOptions, PackInfoLogger};
|
||||
use crate::progress::{
|
||||
|
Loading…
Reference in New Issue
Block a user