Skip to main content

load_graph_index

Function load_graph_index 

Source
pub fn load_graph_index<'g>(graph: &'g Graph, root: &Path) -> GraphIndex<'g>
Expand description

Build the query index, phase two of the two-phase build (see module header). graph is what the caller got back from graph::read_graph(root); root is used here only for the manifest join.

Examples found in repository?
examples/extension_impact.rs (line 98)
92fn run(directory: &Path) -> Result<(), Box<dyn std::error::Error>> {
93    let baseline: graph::Graph =
94        serde_json::from_slice(&fs::read(directory.join("baseline.json"))?)?;
95    let oracle: graph::Graph = serde_json::from_slice(&fs::read(directory.join("oracle.json"))?)?;
96    let spec: Spec = serde_json::from_slice(&fs::read(directory.join("spec.json"))?)?;
97    let root = directory.join("unmapped");
98    let baseline_index = query::load_graph_index(&baseline, &root);
99    let mut candidate_index = query::load_graph_index(&baseline, &root);
100    let oracle_index = query::load_graph_index(&oracle, &root);
101    admit(&mut candidate_index, &spec.candidates)?;
102    let stdout = io::stdout();
103    let mut out = io::BufWriter::new(stdout.lock());
104    for seed in spec.seeds {
105        let record = json!({
106            "seed": seed,
107            "baseline": answer(&baseline_index, &seed, query::DEFAULT_CAP)?,
108            "candidate": answer(&candidate_index, &seed, query::DEFAULT_CAP)?,
109            "oracle": truth(&oracle_index, &seed)?,
110        });
111        serde_json::to_writer(&mut out, &record)?;
112        writeln!(out)?;
113    }
114    Ok(())
115}