web search done right
Use less memory to build centrality store
Mikkel Denkercebbc2c6a0b7
diff --git a/core/benches/online-harmonic.rs b/core/benches/online-harmonic.rsindex 62ff95a2..d9e9c4ac 100644--- a/core/benches/online-harmonic.rs+++ b/core/benches/online-harmonic.rs@@ -1,7 +1,10 @@use criterion::{criterion_group, criterion_main, Criterion};-use cuely::webgraph::{- centrality::{harmonic::HarmonicCentrality, online_harmonic::OnlineHarmonicCentrality},- WebgraphBuilder,+use cuely::{+ ranking::centrality_store::HarmonicCentralityStore,+ webgraph::{+ centrality::{harmonic::HarmonicCentrality, online_harmonic::OnlineHarmonicCentrality},+ WebgraphBuilder,+ },};const WEBGRAPH_PATH: &str = "data/webgraph";@@ -9,10 +12,17 @@ const WEBGRAPH_PATH: &str = "data/webgraph";pub fn criterion_benchmark(c: &mut Criterion) {let webgraph = WebgraphBuilder::new(WEBGRAPH_PATH).open();let centrality = HarmonicCentrality::calculate(&webgraph);++ let harmonic_centrality_store = HarmonicCentralityStore::open(cuely::gen_temp_path());+ for (node, centrality) in centrality.host {+ harmonic_centrality_store.host.insert(node.name, centrality);+ }+ harmonic_centrality_store.host.flush();+c.bench_function("Online harmonic centrality calculation", |b| {b.iter(|| {for _ in 0..10 {- OnlineHarmonicCentrality::new(&webgraph, ¢rality);+ OnlineHarmonicCentrality::new(&webgraph, &harmonic_centrality_store);}})});diff --git a/core/examples/print_approx_harmonic_centrality.rs b/core/examples/print_approx_harmonic_centrality.rsindex 28119ebc..57ab0cd7 100644--- a/core/examples/print_approx_harmonic_centrality.rs+++ b/core/examples/print_approx_harmonic_centrality.rs@@ -91,7 +91,12 @@ fn print_top_nodes() {let liked_nodes: Vec<_> = liked_sites.iter()- .map(|host| Node::from_url(&Url::from(host.to_string())))+ .filter_map(|host| {+ store+ .node2id+ .get(&Node::from_url(&Url::from(host.to_string())))+ .copied()+ }).collect();let scorer = store.online_harmonic.scorer(&liked_nodes, &[]);diff --git a/core/src/lib.rs b/core/src/lib.rsindex 513f02b9..aa196245 100644--- a/core/src/lib.rs+++ b/core/src/lib.rs@@ -255,7 +255,7 @@ pub enum Error {pub(crate) type Result<T> = std::result::Result<T, Error>;// taken from https://docs.rs/sled/0.34.7/src/sled/config.rs.html#445-fn gen_temp_path() -> PathBuf {+pub fn gen_temp_path() -> PathBuf {use std::sync::atomic::{AtomicUsize, Ordering};use std::time::SystemTime;diff --git a/core/src/query/optic.rs b/core/src/query/optic.rsindex 40851663..7de4db7a 100644--- a/core/src/query/optic.rs+++ b/core/src/query/optic.rs@@ -621,13 +621,7 @@ mod tests {primary_image: None,host_topic: None,dmoz_description: None,- node_id: Some(- *centrality_store- .online_harmonic- .node2id- .get(&Node::from("www.a.com").into_host())- .unwrap(),- ),+ node_id: Some(graph.node2id(&Node::from("www.a.com").into_host()).unwrap()),}).expect("failed to insert webpage");index@@ -657,13 +651,7 @@ mod tests {fetch_time_ms: 500,dmoz_description: None,host_topic: None,- node_id: Some(- *centrality_store- .online_harmonic- .node2id- .get(&Node::from("www.b.com").into_host())- .unwrap(),- ),+ node_id: Some(graph.node2id(&Node::from("www.b.com").into_host()).unwrap()),}).expect("failed to insert webpage");index@@ -693,13 +681,7 @@ mod tests {fetch_time_ms: 500,host_topic: None,dmoz_description: None,- node_id: Some(- *centrality_store- .online_harmonic- .node2id- .get(&Node::from("www.c.com").into_host())- .unwrap(),- ),+ node_id: Some(graph.node2id(&Node::from("www.c.com").into_host()).unwrap()),}).expect("failed to insert webpage");diff --git a/core/src/query/parser.rs b/core/src/query/parser.rsindex 7a539645..ce6beddf 100644--- a/core/src/query/parser.rs+++ b/core/src/query/parser.rs@@ -42,7 +42,7 @@ impl ToString for Term {fn to_string(&self) -> String {match self {Term::Simple(term) => term.clone(),- Term::Phrase(phrase) => "\"".to_string() + &phrase + "\"",+ Term::Phrase(phrase) => "\"".to_string() + phrase + "\"",Term::Not(term) => "-".to_string() + term.to_string().as_str(),Term::Site(site) => "site:".to_string() + site.as_str(),Term::Title(title) => "intitle:".to_string() + title.as_str(),@@ -347,10 +347,9 @@ fn parse_term(term: &str) -> Box<Term> {pub fn parse(query: &str) -> Vec<Box<Term>> {let mut res = Vec::new();- let mut chars = query.char_indices();let mut cur_term_begin = 0;- while let Some((offset, c)) = chars.next() {+ for (offset, c) in query.char_indices() {if cur_term_begin > offset {continue;}diff --git a/core/src/ranking/centrality_store.rs b/core/src/ranking/centrality_store.rsindex a0f254fb..93364a7b 100644--- a/core/src/ranking/centrality_store.rs+++ b/core/src/ranking/centrality_store.rs@@ -136,7 +136,7 @@ impl CentralityStore {fn store_host<P: AsRef<Path>>(output_path: P,store: &mut CentralityStore,- harmonic_centrality: &HarmonicCentrality,+ harmonic_centrality: HarmonicCentrality,) {let csv_file = File::options().write(true)@@ -145,7 +145,7 @@ impl CentralityStore {.open(output_path.as_ref().join("harmonic_host.csv")).unwrap();- let mut host: Vec<_> = harmonic_centrality.host.clone().into_iter().collect();+ let mut host: Vec<_> = harmonic_centrality.host.into_iter().collect();host.sort_by(|a, b| b.1.partial_cmp(&a.1).unwrap_or(std::cmp::Ordering::Equal));let mut wtr = csv::Writer::from_writer(csv_file);for (node, centrality) in host {@@ -154,6 +154,7 @@ impl CentralityStore {.unwrap();}wtr.flush().unwrap();+ store.harmonic.host.flush();}pub fn build<P: AsRef<Path>>(graph: &Webgraph, output_path: P) -> Self {@@ -161,9 +162,10 @@ impl CentralityStore {let harmonic_centrality = HarmonicCentrality::calculate(graph);- Self::store_host(&output_path, &mut store, &harmonic_centrality);- store.online_harmonic = OnlineHarmonicCentrality::new(graph, &harmonic_centrality);- store.inbound_similarity = InboundSimilarity::build(graph, &harmonic_centrality);+ Self::store_host(&output_path, &mut store, harmonic_centrality);++ store.online_harmonic = OnlineHarmonicCentrality::new(graph, &store.harmonic);+ store.inbound_similarity = InboundSimilarity::build(graph, &store.harmonic);store.node2id = graph.node_ids().collect();diff --git a/core/src/ranking/inbound_similarity.rs b/core/src/ranking/inbound_similarity.rsindex 7234ac78..4500758d 100644--- a/core/src/ranking/inbound_similarity.rs+++ b/core/src/ranking/inbound_similarity.rs@@ -25,11 +25,11 @@ use serde::{Deserialize, Serialize};use crate::{intmap::IntMap,- webgraph::{centrality::harmonic::HarmonicCentrality, NodeID, Webgraph},+ webgraph::{NodeID, Webgraph},Result,};-use super::bitvec_similarity;+use super::{bitvec_similarity, centrality_store::HarmonicCentralityStore};const DEFAULT_HARMONIC_CENTRALITY_THRESHOLD_FOR_INBOUND: f64 = 0.038;const DEFAULT_HARMONIC_CENTRALITY_THRESHOLD_FOR_NODES: f64 = 0.03;const SCORE_SCALE: f64 = 5.0;@@ -62,7 +62,7 @@ pub struct InboundSimilarity {}impl InboundSimilarity {- pub fn build(graph: &Webgraph, harmonic: &HarmonicCentrality) -> Self {+ pub fn build(graph: &Webgraph, harmonic: &HarmonicCentralityStore) -> Self {Self::build_with_threshold(graph,harmonic,@@ -72,7 +72,7 @@ impl InboundSimilarity {}fn build_with_threshold(graph: &Webgraph,- harmonic: &HarmonicCentrality,+ harmonic: &HarmonicCentralityStore,harmonic_centrality_threshold_nodes: f64,harmonic_centrality_threshold_inbound: f64,) -> Self {@@ -82,9 +82,9 @@ impl InboundSimilarity {if let Some(max_node) = nodes.iter().max().copied() {for node_id in nodes.into_iter()- .filter(|node_id| match graph.id2node(&node_id) {+ .filter(|node_id| match graph.id2node(node_id) {Some(node) => {- let score = *harmonic.host.get(&node.into_host()).unwrap_or(&0.0);+ let score = harmonic.host.get(&node.into_host().name).unwrap_or(0.0);score >= harmonic_centrality_threshold_nodes}None => false,@@ -97,7 +97,7 @@ impl InboundSimilarity {.into_iter().filter(|edge| match graph.id2node(&edge.from) {Some(node) => {- let score = *harmonic.host.get(&node.into_host()).unwrap_or(&0.0);+ let score = harmonic.host.get(&node.into_host().name).unwrap_or(0.0);score >= harmonic_centrality_threshold_inbound}None => false,@@ -168,7 +168,7 @@ mod tests {rand_words,ranking::centrality_store::CentralityStore,searcher::{LocalSearcher, SearchQuery},- webgraph::{Node, WebgraphBuilder},+ webgraph::{centrality::harmonic::HarmonicCentrality, Node, WebgraphBuilder},webpage::{Html, Webpage},};@@ -185,7 +185,15 @@ mod tests {graph.commit();let harmonic = HarmonicCentrality::calculate(&graph);- let inbound = InboundSimilarity::build_with_threshold(&graph, &harmonic, -1.0, -1.0);++ let harmonic_centrality_store = HarmonicCentralityStore::open(crate::gen_temp_path());+ for (node, centrality) in harmonic.host {+ harmonic_centrality_store.host.insert(node.name, centrality);+ }+ harmonic_centrality_store.host.flush();++ let inbound =+ InboundSimilarity::build_with_threshold(&graph, &harmonic_centrality_store, -1.0, -1.0);let scorer = inbound.scorer(&[graph.node2id(&Node::from("b.com")).unwrap()], &[]);let e = graph.node2id(&Node::from("e.com")).unwrap();@@ -205,7 +213,15 @@ mod tests {graph.commit();let harmonic = HarmonicCentrality::calculate(&graph);- let inbound = InboundSimilarity::build_with_threshold(&graph, &harmonic, -1.0, -1.0);++ let harmonic_centrality_store = HarmonicCentralityStore::open(crate::gen_temp_path());+ for (node, centrality) in harmonic.host {+ harmonic_centrality_store.host.insert(node.name, centrality);+ }+ harmonic_centrality_store.host.flush();++ let inbound =+ InboundSimilarity::build_with_threshold(&graph, &harmonic_centrality_store, -1.0, -1.0);let mut centrality_store = CentralityStore::build(&graph, gen_temp_path());centrality_store.inbound_similarity = inbound;diff --git a/core/src/ranking/mod.rs b/core/src/ranking/mod.rsindex 21daf289..8a8bbecb 100644--- a/core/src/ranking/mod.rs+++ b/core/src/ranking/mod.rs@@ -24,7 +24,7 @@ pub mod optics;pub mod pipeline;pub mod signal;-use std::sync::Arc;+use std::{collections::BTreeMap, sync::Arc};use ::optics::SiteRankings;use initial::InitialScoreTweaker;@@ -40,7 +40,7 @@ use crate::{online_harmonic::{self, OnlineHarmonicCentrality, Scorer},topic,},- Node,+ Node, NodeID,},webpage::{region::{Region, RegionCount},@@ -153,19 +153,24 @@ impl Ranker {pub fn online_centrality_scorer(site_rankings: &SiteRankings,harmonic: &OnlineHarmonicCentrality,+ node2id: &BTreeMap<Node, NodeID>,) -> Scorer {- let mut liked_nodes = Vec::new();- let mut disliked_nodes = Vec::new();+ let mut liked = Vec::new();+ let mut disliked = Vec::new();for site in &site_rankings.liked {- liked_nodes.push(Node::from_url(&Url::from(site.clone())).into_host());+ if let Some(nodeid) = node2id.get(&Node::from_url(&Url::from(site.clone())).into_host()) {+ liked.push(*nodeid);+ }}for site in &site_rankings.disliked {- disliked_nodes.push(Node::from_url(&Url::from(site.clone())).into_host());+ if let Some(nodeid) = node2id.get(&Node::from_url(&Url::from(site.clone())).into_host()) {+ disliked.push(*nodeid);+ }}- harmonic.scorer(&liked_nodes, &disliked_nodes)+ harmonic.scorer(&liked, &disliked)}#[cfg(test)]@@ -175,6 +180,7 @@ mod tests {use crate::{human_website_annotations::{self, Info, Topic},index::Index,+ ranking::centrality_store::HarmonicCentralityStore,searcher::{LocalSearcher, SearchQuery},webgraph::{centrality::{@@ -1240,8 +1246,15 @@ mod tests {webgraph.commit();- let centrality = HarmonicCentrality::calculate(&webgraph);- let harmonic = OnlineHarmonicCentrality::new(&webgraph, ¢rality);+ let harmonic = HarmonicCentrality::calculate(&webgraph);++ let harmonic_centrality_store = HarmonicCentralityStore::open(crate::gen_temp_path());+ for (node, centrality) in harmonic.host {+ harmonic_centrality_store.host.insert(node.name, centrality);+ }+ harmonic_centrality_store.host.flush();++ let harmonic = OnlineHarmonicCentrality::new(&webgraph, &harmonic_centrality_store);let topic_centrality = TopicCentrality::build(&index, topics, webgraph, harmonic);diff --git a/core/src/searcher/local.rs b/core/src/searcher/local.rsindex 8552e6c4..0c1a5e2f 100644--- a/core/src/searcher/local.rs+++ b/core/src/searcher/local.rs@@ -163,7 +163,7 @@ impl LocalSearcher {if !top_host_nodes.is_empty() {let harmonic = centrality_store.online_harmonic- .scorer_from_ids(&top_host_nodes, &[]);+ .scorer(&top_host_nodes, &[]);ranker.set_query_centrality(harmonic);}}@@ -190,6 +190,7 @@ impl LocalSearcher {aggregator.set_personal_harmonic(online_centrality_scorer(&optic.site_rankings,&store.online_harmonic,+ &store.node2id,));let liked_sites: Vec<_> = opticdiff --git a/core/src/webgraph/centrality/online_harmonic.rs b/core/src/webgraph/centrality/online_harmonic.rsindex 0b33c64a..0b997e65 100644--- a/core/src/webgraph/centrality/online_harmonic.rs+++ b/core/src/webgraph/centrality/online_harmonic.rs@@ -30,16 +30,14 @@ use std::io::{BufReader, BufWriter, Read};use std::path::Path;use std::sync::{Arc, Mutex};-use itertools::Itertools;use serde::{Deserialize, Serialize};use crate::intmap::IntMap;+use crate::ranking::centrality_store::HarmonicCentralityStore;use crate::webgraph::{Edge, Node};use crate::webgraph::{NodeID, Webgraph};use crate::Result;-use super::harmonic::HarmonicCentrality;-const NUM_PROXY_NODES: usize = 500;const BEST_PROXY_NODES_PER_USER_NODE: usize = 3;const USER_NODES_LIMIT: usize = 100; // if the user specifies more than this number of nodes, the remaining nodes will be merged into existing@@ -335,21 +333,20 @@ fn reversed_distances(graph: &Webgraph, source: Node) -> BTreeMap<NodeID, u8> {#[derive(Serialize, Deserialize, Default)]pub struct OnlineHarmonicCentrality {- pub node2id: HashMap<Node, NodeID>,pub proxy_nodes: Vec<Arc<ProxyNode>>,}impl OnlineHarmonicCentrality {- pub fn new(graph: &Webgraph, centrality: &HarmonicCentrality) -> Self {+ pub fn new(graph: &Webgraph, centrality: &HarmonicCentralityStore) -> Self {Self::new_with_num_proxy(graph, centrality, NUM_PROXY_NODES)}fn new_with_num_proxy(graph: &Webgraph,- centrality: &HarmonicCentrality,+ centrality: &HarmonicCentralityStore,num_proxy_nodes: usize,) -> Self {- let mut node2id: HashMap<Node, NodeID> = HashMap::new();+ let mut node2id: BTreeMap<Node, NodeID> = BTreeMap::new();// we should probably choose the proxy nodes based on their// betweenness centrality, but I don't know how we can approximate betweenness@@ -361,7 +358,7 @@ impl OnlineHarmonicCentrality {for (node, id) in graph.node_ids() {node2id.insert(node.clone(), id);- let score = *centrality.host.get(&node).unwrap_or(&0.0);+ let score = centrality.host.get(&node.name).unwrap_or(0.0);let candidate = ProxyNodeCandidate { node, score };if nodes.len() >= num_proxy_nodes {@@ -399,29 +396,10 @@ impl OnlineHarmonicCentrality {}).collect();- Self {- proxy_nodes,- node2id,- }- }-- pub fn scorer(&self, liked_nodes: &[Node], disliked_nodes: &[Node]) -> Scorer {- let liked_nodes = liked_nodes- .iter()- .map(|node| node.clone().into_host())- .filter_map(|node| self.node2id.get(&node).cloned())- .collect_vec();-- let disliked_nodes = disliked_nodes- .iter()- .map(|node| node.clone().into_host())- .filter_map(|node| self.node2id.get(&node).cloned())- .collect_vec();-- self.scorer_from_ids(&liked_nodes, &disliked_nodes)+ Self { proxy_nodes }}- pub fn scorer_from_ids(&self, liked_nodes: &[NodeID], disliked_nodes: &[NodeID]) -> Scorer {+ pub fn scorer(&self, liked_nodes: &[NodeID], disliked_nodes: &[NodeID]) -> Scorer {Scorer::new(&self.proxy_nodes,liked_nodes,@@ -458,7 +436,7 @@ impl OnlineHarmonicCentrality {#[cfg(test)]mod tests {use super::*;- use crate::webgraph::WebgraphBuilder;+ use crate::webgraph::{centrality::harmonic::HarmonicCentrality, WebgraphBuilder};fn test_graph() -> Webgraph {/*@@ -493,51 +471,35 @@ mod tests {fn ordering() {let graph = test_graph();let harmonic = HarmonicCentrality::calculate(&graph);- let centrality = OnlineHarmonicCentrality::new_with_num_proxy(&graph, &harmonic, 5);- let liked_nodes = vec![Node::from("B".to_string()), Node::from("E".to_string())];+ let harmonic_centrality_store = HarmonicCentralityStore::open(crate::gen_temp_path());+ for (node, centrality) in harmonic.host {+ harmonic_centrality_store.host.insert(node.name, centrality);+ }+ harmonic_centrality_store.host.flush();++ let centrality =+ OnlineHarmonicCentrality::new_with_num_proxy(&graph, &harmonic_centrality_store, 5);++ let liked_nodes: Vec<_> = vec![Node::from("B".to_string()), Node::from("E".to_string())]+ .into_iter()+ .filter_map(|node| graph.node2id(&node))+ .collect();let scorer = centrality.scorer(&liked_nodes, &[]);assert!(- scorer.score(- *centrality- .node2id- .get(&Node::from("E".to_string()))- .unwrap()- ) > scorer.score(- *centrality- .node2id- .get(&Node::from("H".to_string()))- .unwrap()- )+ scorer.score(graph.node2id(&Node::from("E".to_string())).unwrap())+ > scorer.score(graph.node2id(&Node::from("H".to_string())).unwrap()));assert!(- scorer.score(- *centrality- .node2id- .get(&Node::from("H".to_string()))- .unwrap()- ) > scorer.score(- *centrality- .node2id- .get(&Node::from("C".to_string()))- .unwrap()- )+ scorer.score(graph.node2id(&Node::from("H".to_string())).unwrap())+ > scorer.score(graph.node2id(&Node::from("C".to_string())).unwrap()));assert!(- scorer.score(- *centrality- .node2id- .get(&Node::from("C".to_string()))- .unwrap()- ) > scorer.score(- *centrality- .node2id- .get(&Node::from("A".to_string()))- .unwrap()- )+ scorer.score(graph.node2id(&Node::from("C".to_string())).unwrap())+ > scorer.score(graph.node2id(&Node::from("A".to_string())).unwrap()));}@@ -545,14 +507,25 @@ mod tests {fn disliked_nodes_centrality() {let graph = test_graph();let harmonic = HarmonicCentrality::calculate(&graph);- let centrality = OnlineHarmonicCentrality::new_with_num_proxy(&graph, &harmonic, 5);- let disliked_nodes = vec![Node::from("D".to_string()), Node::from("E".to_string())];+ let harmonic_centrality_store = HarmonicCentralityStore::open(crate::gen_temp_path());+ for (node, centrality) in harmonic.host {+ harmonic_centrality_store.host.insert(node.name, centrality);+ }+ harmonic_centrality_store.host.flush();++ let centrality =+ OnlineHarmonicCentrality::new_with_num_proxy(&graph, &harmonic_centrality_store, 5);++ let disliked_nodes: Vec<_> = vec![Node::from("D".to_string()), Node::from("E".to_string())]+ .into_iter()+ .filter_map(|node| graph.node2id(&node))+ .collect();let scorer = centrality.scorer(&[], &disliked_nodes);for node in &disliked_nodes {- assert_eq!(scorer.score(*centrality.node2id.get(node).unwrap()), 0.0);+ assert_eq!(scorer.score(*node), 0.0);}}@@ -560,53 +533,41 @@ mod tests {fn ordering_with_dislikes() {let graph = test_graph();let harmonic = HarmonicCentrality::calculate(&graph);- let centrality = OnlineHarmonicCentrality::new_with_num_proxy(&graph, &harmonic, 5);- let liked_nodes = vec![Node::from("B".to_string()), Node::from("E".to_string())];- let disliked_nodes = vec![Node::from("F".to_string())];+ let harmonic_centrality_store = HarmonicCentralityStore::open(crate::gen_temp_path());+ for (node, centrality) in harmonic.host {+ harmonic_centrality_store.host.insert(node.name, centrality);+ }+ harmonic_centrality_store.host.flush();++ let centrality =+ OnlineHarmonicCentrality::new_with_num_proxy(&graph, &harmonic_centrality_store, 5);++ let liked_nodes: Vec<_> = vec![Node::from("B".to_string()), Node::from("E".to_string())]+ .into_iter()+ .filter_map(|node| graph.node2id(&node))+ .collect();++ let disliked_nodes: Vec<_> = vec![Node::from("F".to_string())]+ .into_iter()+ .filter_map(|node| graph.node2id(&node))+ .collect();let scorer = centrality.scorer(&liked_nodes, &disliked_nodes);assert!(- scorer.score(- *centrality- .node2id- .get(&Node::from("E".to_string()))- .unwrap()- ) > scorer.score(- *centrality- .node2id- .get(&Node::from("H".to_string()))- .unwrap()- )+ scorer.score(graph.node2id(&Node::from("E".to_string())).unwrap())+ > scorer.score(graph.node2id(&Node::from("H".to_string())).unwrap()));assert!(- scorer.score(- *centrality- .node2id- .get(&Node::from("H".to_string()))- .unwrap()- ) > scorer.score(- *centrality- .node2id- .get(&Node::from("C".to_string()))- .unwrap()- )+ scorer.score(graph.node2id(&Node::from("H".to_string())).unwrap())+ > scorer.score(graph.node2id(&Node::from("C".to_string())).unwrap()));assert!(- scorer.score(- *centrality- .node2id- .get(&Node::from("C".to_string()))- .unwrap()- ) > scorer.score(- *centrality- .node2id- .get(&Node::from("A".to_string()))- .unwrap()- )+ scorer.score(graph.node2id(&Node::from("C".to_string())).unwrap())+ > scorer.score(graph.node2id(&Node::from("A".to_string())).unwrap()));}}diff --git a/core/src/webgraph/centrality/topic.rs b/core/src/webgraph/centrality/topic.rsindex 5ca803e6..ee3836c7 100644--- a/core/src/webgraph/centrality/topic.rs+++ b/core/src/webgraph/centrality/topic.rs@@ -174,7 +174,10 @@ impl TopicCentrality {}).collect();- let top_sites: Vec<_> = top_sites.into_iter().collect();+ let top_sites: Vec<_> = top_sites+ .into_iter()+ .filter_map(|node| webgraph.node2id(&node))+ .collect();assert!(!top_sites.is_empty());diff --git a/core/src/widgets/calculator.rs b/core/src/widgets/calculator.rsindex 3a3a90a7..1f8d99e1 100644--- a/core/src/widgets/calculator.rs+++ b/core/src/widgets/calculator.rs@@ -59,8 +59,8 @@ impl Debug for Expr {fn fmt(&self, fmt: &mut Formatter) -> std::result::Result<(), std::fmt::Error> {use self::Expr::*;match *self {- Number(n) => write!(fmt, "{:?}", n),- Op(ref l, op, ref r) => write!(fmt, "({:?} {:?} {:?})", l, op, r),+ Number(n) => write!(fmt, "{n:?}"),+ Op(ref l, op, ref r) => write!(fmt, "({l:?} {op:?} {r:?})"),}}}@@ -69,8 +69,8 @@ impl Display for Expr {fn fmt(&self, fmt: &mut Formatter<'_>) -> std::fmt::Result {use self::Expr::*;match *self {- Number(n) => write!(fmt, "{}", n),- Op(ref l, op, ref r) => write!(fmt, "{} {} {}", l, op, r),+ Number(n) => write!(fmt, "{n}"),+ Op(ref l, op, ref r) => write!(fmt, "{l} {op} {r}"),}}}