use of annis.sqlgen.model.Identical in project ANNIS by korpling.
the class ComponentSearchRelationNormalizer method replicateFromJoinSource.
private void replicateFromJoinSource(Join join, QueryNode sourceNode, List<QueryNode> nodes, AtomicLong maxID) {
Preconditions.checkState(sourceNode.removeOutgoingJoin(join), "The join was not attached to the source node.");
QueryNode newNode = new QueryNode(maxID.incrementAndGet(), sourceNode, false);
newNode.setVariable("x" + newNode.getId() + "(" + sourceNode.getVariable() + ")");
newNode.addOutgoingJoin(join);
newNode.setArtificial(true);
Identical identJoin = new Identical(newNode);
sourceNode.addOutgoingJoin(identJoin);
nodes.add(newNode);
}
use of annis.sqlgen.model.Identical in project ANNIS by korpling.
the class SubcorpusConstraintWhereClause method commonWhereConditions.
// VR: inline
@Deprecated
public List<String> commonWhereConditions(List<QueryNode> nodes, List<Long> corpusList, List<Long> documents) {
LinkedList<String> conditions = new LinkedList<>();
// annotations can always only be inside a subcorpus/document
QueryNode[] copyNodes = nodes.toArray(new QueryNode[nodes.size()]);
for (int left = 0; left < copyNodes.length; left++) {
for (int right = 0; right < copyNodes.length; right++) {
if (left != right) {
// only add constraint if the two nodes are not already connected by their component or node id
boolean needsCorpusRef = false;
for (Join j : copyNodes[left].getOutgoingJoins()) {
if (j.getTarget() != null && j.getTarget().getId() == copyNodes[right].getId()) {
if ((j instanceof RankTableJoin || j instanceof Identical)) {
// we definitly don't have to apply this join
needsCorpusRef = false;
break;
} else {
// there is at least one actual join between this nodes, assume we
// need a corpus_ref join for now
needsCorpusRef = true;
}
}
}
if (needsCorpusRef) {
conditions.add(join("=", tables(copyNodes[left]).aliasedColumn(NODE_TABLE, "corpus_ref"), tables(copyNodes[right]).aliasedColumn(NODE_TABLE, "corpus_ref")));
}
}
// end if left != right
}
// end right loop
}
return conditions;
}
use of annis.sqlgen.model.Identical in project ANNIS by korpling.
the class TestDefaultWhereClauseGenerator method whereClauseForIdentity.
@Test
public void whereClauseForIdentity() {
node23.addOutgoingJoin(new Identical(node42));
checkWhereConditions(join("=", "_node23.id", "_node42.id"));
}
use of annis.sqlgen.model.Identical in project ANNIS by korpling.
the class AbstractWhereClauseGenerator method whereConditions.
@Override
public Set<String> whereConditions(QueryData queryData, List<QueryNode> alternative, String indent) {
List<String> conditions = new ArrayList<>();
for (QueryNode node : alternative) {
// node constraints
if (node.getSpannedText() != null) {
addSpanConditions(conditions, queryData, node);
}
if (node.isToken()) {
addIsTokenConditions(conditions, queryData, node);
}
if (node.isRoot()) {
addIsRootConditions(conditions, queryData, node);
}
if (node.getArity() != null) {
addNodeArityConditions(conditions, queryData, node);
}
if (node.getTokenArity() != null) {
addTokenArityConditions(conditions, queryData, node);
}
// node joins
for (Join join : node.getOutgoingJoins()) {
QueryNode target = join.getTarget();
if (join instanceof SameSpan) {
addSameSpanConditions(conditions, node, target, (SameSpan) join, queryData);
} else if (join instanceof Identical) {
addIdenticalConditions(conditions, node, target, (Identical) join, queryData);
} else if (join instanceof LeftAlignment) {
addLeftAlignmentConditions(conditions, node, target, (LeftAlignment) join, queryData);
} else if (join instanceof RightAlignment) {
addRightAlignmentConditions(conditions, node, target, (RightAlignment) join, queryData);
} else if (join instanceof Inclusion) {
addInclusionConditions(conditions, node, target, (Inclusion) join, queryData);
} else if (join instanceof Overlap) {
addOverlapConditions(conditions, node, target, (Overlap) join, queryData);
} else if (join instanceof LeftOverlap) {
addLeftOverlapConditions(conditions, target, node, (LeftOverlap) join, queryData);
} else if (join instanceof RightOverlap) {
addRightOverlapConditions(conditions, target, node, (RightOverlap) join, queryData);
} else if (join instanceof Precedence) {
addPrecedenceConditions(conditions, node, target, (Precedence) join, queryData);
} else if (join instanceof Near) {
addNearConditions(conditions, node, target, (Near) join, queryData);
} else if (join instanceof Sibling) {
addSiblingConditions(conditions, node, target, (Sibling) join, queryData);
} else if (join instanceof CommonAncestor) {
addCommonAncestorConditions(conditions, node, target, (CommonAncestor) join, queryData);
} else if (join instanceof LeftDominance) {
addLeftDominanceConditions(conditions, node, target, (LeftDominance) join, queryData);
} else if (join instanceof RightDominance) {
addRightDominanceConditions(conditions, node, target, (RightDominance) join, queryData);
} else if (join instanceof Dominance) {
addDominanceConditions(conditions, node, target, (Dominance) join, queryData);
} else if (join instanceof PointingRelation) {
addPointingRelationConditions(conditions, node, target, (PointingRelation) join, queryData);
} else if (join instanceof EqualValue) {
addEqualValueConditions(conditions, node, target, (EqualValue) join, queryData);
} else if (join instanceof NotEqualValue) {
addNotEqualValueConditions(conditions, node, target, (NotEqualValue) join, queryData);
}
}
// node annotations
int i = 0;
for (QueryAnnotation annotation : node.getNodeAnnotations()) {
++i;
addAnnotationConditions(conditions, node, i, annotation, NODE_ANNOTATION_TABLE, queryData);
}
// relation annotations
int j = 0;
for (QueryAnnotation annotation : node.getEdgeAnnotations()) {
++j;
addAnnotationConditions(conditions, node, j, annotation, EDGE_ANNOTATION_TABLE, queryData);
}
}
return new HashSet<>(conditions);
}
use of annis.sqlgen.model.Identical in project ANNIS by korpling.
the class ComponentSearchRelationNormalizer method replicateFromJoinTarget.
private void replicateFromJoinTarget(Join join, QueryNode targetNode, List<QueryNode> nodes, AtomicLong maxID) {
QueryNode newTargetNode = new QueryNode(maxID.incrementAndGet(), targetNode, false);
newTargetNode.setArtificial(true);
newTargetNode.setVariable("x" + newTargetNode.getId() + "(" + targetNode.getVariable() + ")");
newTargetNode.setThisNodeAsTarget(join);
Identical identJoin = new Identical(newTargetNode);
targetNode.addOutgoingJoin(identJoin);
nodes.add(newTargetNode);
}
Aggregations