Search in sources :

Example 1 with CommonAncestor

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)));
}
Also used : CommonAncestor(annis.sqlgen.model.CommonAncestor) QueryNode(annis.model.QueryNode)

Example 2 with CommonAncestor

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"));
}
Also used : CommonAncestor(annis.sqlgen.model.CommonAncestor) TestUtils.uniqueLong(annis.test.TestUtils.uniqueLong) Theory(org.junit.experimental.theories.Theory)

Example 3 with CommonAncestor

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"));
}
Also used : CommonAncestor(annis.sqlgen.model.CommonAncestor) Theory(org.junit.experimental.theories.Theory)

Example 4 with CommonAncestor

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)");
}
Also used : CommonAncestor(annis.sqlgen.model.CommonAncestor) Theory(org.junit.experimental.theories.Theory)

Example 5 with CommonAncestor

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"));
}
Also used : CommonAncestor(annis.sqlgen.model.CommonAncestor) Theory(org.junit.experimental.theories.Theory)

Aggregations

CommonAncestor (annis.sqlgen.model.CommonAncestor)8 Theory (org.junit.experimental.theories.Theory)6 QueryNode (annis.model.QueryNode)2 Join (annis.model.Join)1 QueryAnnotation (annis.model.QueryAnnotation)1 Dominance (annis.sqlgen.model.Dominance)1 EqualValue (annis.sqlgen.model.EqualValue)1 Identical (annis.sqlgen.model.Identical)1 Inclusion (annis.sqlgen.model.Inclusion)1 LeftAlignment (annis.sqlgen.model.LeftAlignment)1 LeftDominance (annis.sqlgen.model.LeftDominance)1 LeftOverlap (annis.sqlgen.model.LeftOverlap)1 Near (annis.sqlgen.model.Near)1 NotEqualValue (annis.sqlgen.model.NotEqualValue)1 Overlap (annis.sqlgen.model.Overlap)1 PointingRelation (annis.sqlgen.model.PointingRelation)1 Precedence (annis.sqlgen.model.Precedence)1 RightAlignment (annis.sqlgen.model.RightAlignment)1 RightDominance (annis.sqlgen.model.RightDominance)1 RightOverlap (annis.sqlgen.model.RightOverlap)1