diff --git a/CHANGELOG.md b/CHANGELOG.md index 2af566285..c2b6262cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- `AnnotationComponentType::apply_update_graph_index` makes sure all edges + from named dominance components are also contained in the default + dominance component `Dominance/annis`. + ## [4.2.0] - 2026-08-11 ### Added diff --git a/graphannis/src/annis/db/aql/model.rs b/graphannis/src/annis/db/aql/model.rs index 4ad880787..f8c54325c 100644 --- a/graphannis/src/annis/db/aql/model.rs +++ b/graphannis/src/annis/db/aql/model.rs @@ -13,7 +13,7 @@ use graphannis_core::{ util::disk_collections::{DEFAULT_BLOCK_CACHE_CAPACITY, DiskMap, EvictionStrategy}, }; use std::{ - collections::{BTreeMap, HashMap}, + collections::{BTreeMap, BTreeSet, HashMap}, fmt, }; use transient_btree_index::BtreeConfig; @@ -597,6 +597,37 @@ impl ComponentType for AnnotationComponentType { index.reindex_inherited_coverage(graph, gs_order)?; } + // make sure all edges in named dominance components are also in the default dominance component `Dominance/annis` + { + let default_dominance_component = AnnotationComponent::new( + AnnotationComponentType::Dominance, + ANNIS_NS.into(), + "".into(), + ); + let mut edge_collector = BTreeSet::default(); + let all_dominance_components = + graph.get_all_components(Some(AnnotationComponentType::Dominance), None); + for component in all_dominance_components { + if component == default_dominance_component { + continue; + } + if let Some(other_dominance_gs) = graph.get_graphstorage_as_ref(&component) { + for source_node in other_dominance_gs.source_nodes() { + let source = source_node?; + for target in other_dominance_gs.get_outgoing_edges(source) { + let target = target?; + edge_collector.insert(Edge { source, target }); + } + } + } + } + let default_dominance_gs = + graph.get_or_create_writable(&default_dominance_component)?; + edge_collector + .into_iter() + .try_for_each(|e| default_dominance_gs.add_edge(e))?; + } + Ok(()) } diff --git a/graphannis/src/annis/db/aql/model/snapshots/graphannis__annis__db__aql__model__tests__add_token_to_single_sentence.snap b/graphannis/src/annis/db/aql/model/snapshots/graphannis__annis__db__aql__model__tests__add_token_to_single_sentence.snap index 5951c5264..47bd3a76c 100644 --- a/graphannis/src/annis/db/aql/model/snapshots/graphannis__annis__db__aql__model__tests__add_token_to_single_sentence.snap +++ b/graphannis/src/annis/db/aql/model/snapshots/graphannis__annis__db__aql__model__tests__add_token_to_single_sentence.snap @@ -106,101 +106,125 @@ expression: "String::from_utf8_lossy(&output)" node - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + +