Skip to content

Commit 7966e8d

Browse files
committed
Use more accurate root_node statistic
1 parent 2f353b5 commit 7966e8d

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

graphannis/src/annis/db/aql/operators/edge_op.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,22 @@ impl BaseEdgeOp {
4949
.components
5050
.iter()
5151
.all(|c| c.get_type() == AnnotationComponentType::PartOf);
52-
let max_nodes_estimate = if all_part_of_components {
52+
53+
let max_nodes_estimate = if all_part_of_components && gs.len() == 1 {
5354
// PartOf components have a very skewed distribution of root nodes
5455
// vs. the actual possible targets, thus do not use all nodes as
55-
// population but only the non-roots. We can guess the non-root
56-
// nodes by estimating the number of nodes in the corpus grah.
57-
let result = db.get_node_annos().guess_max_count(
58-
Some(&NODE_TYPE_KEY.ns),
59-
&NODE_TYPE_KEY.name,
60-
"corpus",
61-
"datasource",
62-
)?;
63-
result
56+
// population but only the non-roots.
57+
if let Some(stats) = gs[0].get_statistics() {
58+
stats.nodes - stats.root_nodes
59+
} else {
60+
// Fallback to guessing by using the node type
61+
db.get_node_annos().guess_max_count(
62+
Some(&NODE_TYPE_KEY.ns),
63+
&NODE_TYPE_KEY.name,
64+
"corpus",
65+
"datasource",
66+
)?
67+
}
6468
} else {
6569
db.get_node_annos().guess_max_count(
6670
Some(&NODE_TYPE_KEY.ns),

0 commit comments

Comments
 (0)