MCPcopy Create free account
hub / github.com/emwalker/digraph / update_synonyms

Method update_synonyms

backend/src/git/index.rs:842–887  ·  view source on GitHub ↗
(
        &mut self,
        client: &Client,
        repo_id: RepoId,
        before: &Option<RepoTopic>,
        after: &RepoTopic,
    )

Source from the content-addressed store, hash-verified

840 }
841
842 pub fn update_synonyms(
843 &mut self,
844 client: &Client,
845 repo_id: RepoId,
846 before: &Option<RepoTopic>,
847 after: &RepoTopic,
848 ) -> Result<()> {
849 let topic_id = after.topic_id();
850
851 let before = match before {
852 Some(before) => before
853 .prefixed_synonyms()
854 .iter()
855 .cloned()
856 .collect::<HashSet<Synonym>>(),
857 None => HashSet::new(),
858 };
859
860 let after = after
861 .prefixed_synonyms()
862 .iter()
863 .cloned()
864 .collect::<HashSet<Synonym>>();
865
866 self.synonym_indexes(
867 client,
868 repo_id,
869 after.difference(&before),
870 |index, token, name| {
871 index.add(topic_id, token.to_owned(), name)?;
872 Ok(())
873 },
874 )?;
875
876 self.synonym_indexes(
877 client,
878 repo_id,
879 before.difference(&after),
880 |index, token, name| {
881 index.remove(topic_id, token.to_owned(), name)?;
882 Ok(())
883 },
884 )?;
885
886 Ok(())
887 }
888}
889
890impl std::fmt::Debug for Indexer {

Callers 1

save_topicMethod · 0.80

Calls 6

prefixed_synonymsMethod · 0.80
synonym_indexesMethod · 0.80
topic_idMethod · 0.45
iterMethod · 0.45
addMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected