Skip to main content

filter_known

Function filter_known 

Source
pub async fn filter_known<'a>(
    set: Set,
    filter_known_func: &(dyn Fn(&[Vertex]) -> BoxFuture<'a, Result<Vec<Vertex>>> + Send + Sync + 'a),
) -> Result<Set>
Expand description

Given a set (sub-graph) and a filter function that selects “known” subset of its input, apply filter to set.

The filter funtion must have following properties:

  • filter(xs) + filter(ys) = filter(xs + ys)
  • If its input contains both X and Y and X is an ancestor of Y in the sub-graph, and its output contains Y, then its output must also contain Y’s ancestor X. In other words, if vertex X is considered known, then ancestors of X are also known.

This function has a similar signature with filter, but it utilizes the above properties to test (much) less vertexes for a large input set.

The idea of the algorithm comes from Mercurial’s setdiscovery.py, introduced by 1. setdiscovery.py is used to figure out what commits are needed to be pushed or pulled.