File tree Expand file tree Collapse file tree
graphannis/src/annis/db/aql Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ pub mod operators;
66
77use boolean_expression:: Expr ;
88use graphannis_core:: annostorage:: MatchGroup ;
9+ use itertools:: Itertools ;
910lalrpop_mod ! (
1011 #[ allow( clippy:: all) ]
1112 #[ allow( clippy:: panic) ]
@@ -77,7 +78,28 @@ pub fn execute_query_on_graph<'a>(
7778 let timeout = TimeoutCheck :: new ( timeout) ;
7879
7980 let config = Config { use_parallel_joins } ;
80- let it = ExecutionPlan :: from_disjunction ( query, graph, & config, timeout) ?;
81+ let it = ExecutionPlan :: from_disjunction ( query, graph, & config, timeout) ?
82+ . map_ok ( |mg| {
83+ // Rewrite match group to only include nodes that are included in the query
84+ // check if query node actually should be included
85+ let mut new_match_group = MatchGroup :: with_capacity ( mg. len ( ) ) ;
86+ for ( node_nr, m) in mg. into_iter ( ) . enumerate ( ) {
87+ let include_in_output = query
88+ . get_variable_by_node_nr ( node_nr)
89+ . is_some_and ( |var| query. is_included_in_output ( & var) ) ;
90+ if include_in_output {
91+ new_match_group. push ( m) ;
92+ }
93+ }
94+ new_match_group
95+ } )
96+ . unique_by ( move |mg| {
97+ // Map an error to an empty match group
98+ match mg {
99+ Ok ( mg) => mg. clone ( ) ,
100+ Err ( _) => MatchGroup :: new ( ) ,
101+ }
102+ } ) ;
81103
82104 Ok ( Box :: from ( it) )
83105}
You can’t perform that action at this time.
0 commit comments