use of annis.sqlgen.model.CommonAncestor in project ANNIS by korpling.
the class JoinListener method enterCommonancestor.
@Override
public void enterCommonancestor(AqlParser.CommonancestorContext ctx) {
QueryNode left = relationChain.get(relationIdx);
QueryNode right = relationChain.get(relationIdx + 1);
String label = ctx.label == null ? null : ctx.label.getText();
left.addOutgoingJoin(addParsedLocation(ctx, new CommonAncestor(right, label)));
}
use of annis.sqlgen.model.CommonAncestor in project ANNIS by korpling.
the class TestDefaultWhereClauseGenerator method shouldSkipToplevelCorpusPredicateForCommonAncestorIfCorpusListIsEmpty.
/**
* The common ancestor operator should skip the predicate on toplevel_corpus
* in the EXISTS subquery if the corpus list is empty.
*/
@Theory
public void shouldSkipToplevelCorpusPredicateForCommonAncestorIfCorpusListIsEmpty(String componentPredicate) {
// given
generator.setUseToplevelCorpusPredicateInCommonAncestorSubquery(true);
given(queryData.getCorpusList()).willReturn(new ArrayList<Long>());
node23.addOutgoingJoin(new CommonAncestor(node42));
// then
checkEdgeConditions(componentPredicate, "d", null, true, "EXISTS (SELECT 1 FROM (SELECT * FROM facts LIMIT 0) AS ancestor WHERE" + "\n\t" + "ancestor.pre < _rank23.pre AND _rank23.pre < ancestor.post AND" + "\n\t" + "ancestor.pre < _rank42.pre AND _rank42.pre < ancestor.post" + "\n\tLIMIT 1)", join("<>", "_node23.id", "_node42.id"));
}
use of annis.sqlgen.model.CommonAncestor in project ANNIS by korpling.
the class TestDefaultWhereClauseGenerator method shouldUseComponentRefPredicateForCommonAncestor.
/**
* The common ancestor operator may optionally use a predicate on toplevel_corpus
* in the EXISTS subquery.
*/
@Theory
public void shouldUseComponentRefPredicateForCommonAncestor(String componentPredicate) {
// given
generator.setUseComponentRefPredicateInCommonAncestorSubquery(true);
long corpusId = uniqueLong();
given(queryData.getCorpusList()).willReturn(asList(corpusId));
node23.addOutgoingJoin(new CommonAncestor(node42));
// then
checkEdgeConditions(componentPredicate, "d", null, true, join("=", "_rank23.component_ref", "_rank42.component_ref"), "EXISTS (SELECT 1 FROM facts_" + corpusId + " AS ancestor WHERE" + "\n\t" + "ancestor.component_ref = _rank23.component_ref AND" + "\n\t" + "ancestor.component_ref = _rank42.component_ref AND" + "\n\t" + "ancestor.pre < _rank23.pre AND _rank23.pre < ancestor.post AND" + "\n\t" + "ancestor.pre < _rank42.pre AND _rank42.pre < ancestor.post\n\t" + "LIMIT 1)", join("<>", "_node23.id", "_node42.id"));
}
use of annis.sqlgen.model.CommonAncestor in project ANNIS by korpling.
the class TestDefaultWhereClauseGenerator method shouldAllowIdenticalNodeForCommonAncestorTarget.
/**
* The common ancestor operator may optionally bind the same node to both operands.
*/
@Theory
public void shouldAllowIdenticalNodeForCommonAncestorTarget(String componentPredicate) {
// given
generator.setAllowIdenticalSibling(true);
node23.addOutgoingJoin(new CommonAncestor(node42));
// then
checkEdgeConditions(componentPredicate, "d", null, true, "EXISTS (SELECT 1 FROM (SELECT * FROM facts LIMIT 0) AS ancestor WHERE" + "\n\t" + "ancestor.pre < _rank23.pre AND _rank23.pre < ancestor.post AND" + "\n\t" + "ancestor.pre < _rank42.pre AND _rank42.pre < ancestor.post" + "\n\tLIMIT 1)");
}
use of annis.sqlgen.model.CommonAncestor in project ANNIS by korpling.
the class TestDefaultWhereClauseGenerator method shouldGenerateWhereConditionsForCommonAncestor.
/**
* WHERE conditions for common ancestor ($*).
*/
@Theory
public void shouldGenerateWhereConditionsForCommonAncestor(String componentPredicate) {
// given
node23.addOutgoingJoin(new CommonAncestor(node42));
// then
checkEdgeConditions(componentPredicate, "d", null, true, "EXISTS (SELECT 1 FROM (SELECT * FROM facts LIMIT 0) AS ancestor WHERE" + "\n\t" + "ancestor.pre < _rank23.pre AND _rank23.pre < ancestor.post AND" + "\n\t" + "ancestor.pre < _rank42.pre AND _rank42.pre < ancestor.post" + "\n\tLIMIT 1)", join("<>", "_node23.id", "_node42.id"));
}
Aggregations