Search in sources :

Example 1 with DupFilterAxis

use of org.sirix.service.xml.xpath.filter.DupFilterAxis in project sirix by sirixdb.

the class ExpressionSingle method add.

/**
 * Adds a new Axis to the expression chain. The first axis that is added has to be stored till a
 * second axis is added. When the second axis is added, it is nested with the first one and builds
 * the execution chain.
 *
 * @param pAx the axis to add
 */
public void add(final Axis pAx) {
    Axis axis = pAx;
    if (isDupOrd(axis)) {
        axis = new DupFilterAxis(axis.getTrx(), axis);
        DupState.nodup = true;
    }
    switch(mNumber) {
        case 0:
            mFirstAxis = axis;
            mNumber++;
            break;
        case 1:
            mExpr = new NestedAxis(mFirstAxis, axis);
            mNumber++;
            break;
        default:
            final Axis cache = mExpr;
            mExpr = new NestedAxis(cache, axis);
    }
}
Also used : DupFilterAxis(org.sirix.service.xml.xpath.filter.DupFilterAxis) NestedAxis(org.sirix.axis.NestedAxis) AncestorAxis(org.sirix.axis.AncestorAxis) PrecedingAxis(org.sirix.axis.PrecedingAxis) Axis(org.sirix.api.Axis) NestedAxis(org.sirix.axis.NestedAxis) ChildAxis(org.sirix.axis.ChildAxis) FollowingSiblingAxis(org.sirix.axis.FollowingSiblingAxis) UnionAxis(org.sirix.service.xml.xpath.expr.UnionAxis) FollowingAxis(org.sirix.axis.FollowingAxis) FilterAxis(org.sirix.axis.filter.FilterAxis) DescendantAxis(org.sirix.axis.DescendantAxis) ParentAxis(org.sirix.axis.ParentAxis) DupFilterAxis(org.sirix.service.xml.xpath.filter.DupFilterAxis) PrecedingSiblingAxis(org.sirix.axis.PrecedingSiblingAxis)

Example 2 with DupFilterAxis

use of org.sirix.service.xml.xpath.filter.DupFilterAxis in project sirix by sirixdb.

the class ExpressionSingleTest method testDup.

@Test
public void testDup() throws SirixException {
    ExpressionSingle builder = new ExpressionSingle();
    builder.add(new ChildAxis(holder.getReader()));
    builder.add(new DescendantAxis(holder.getReader()));
    assertTrue(builder.getExpr() instanceof NestedAxis);
    builder = new ExpressionSingle();
    builder.add(new ChildAxis(holder.getReader()));
    builder.add(new DescendantAxis(holder.getReader()));
    assertEquals(true, builder.isOrdered());
    assertTrue(builder.getExpr() instanceof NestedAxis);
    builder = new ExpressionSingle();
    builder.add(new ChildAxis(holder.getReader()));
    builder.add(new DescendantAxis(holder.getReader()));
    builder.add(new ChildAxis(holder.getReader()));
    assertEquals(false, builder.isOrdered());
    builder = new ExpressionSingle();
    builder = new ExpressionSingle();
    builder.add(new ChildAxis(holder.getReader()));
    builder.add(new DescendantAxis(holder.getReader()));
    builder.add(new ChildAxis(holder.getReader()));
    builder.add(new ParentAxis(holder.getReader()));
    assertEquals(true, builder.isOrdered());
    builder = new ExpressionSingle();
    builder.add(new ChildAxis(holder.getReader()));
    builder.add(new DescendantAxis(holder.getReader()));
    builder.add(new FollowingSiblingAxis(holder.getReader()));
    assertEquals(false, builder.isOrdered());
    builder = new ExpressionSingle();
    builder.add(new UnionAxis(holder.getReader(), new DescendantAxis(holder.getReader()), new ParentAxis(holder.getReader())));
    assertEquals(false, builder.isOrdered());
    assertTrue(builder.getExpr() instanceof DupFilterAxis);
}
Also used : ChildAxis(org.sirix.axis.ChildAxis) FollowingSiblingAxis(org.sirix.axis.FollowingSiblingAxis) ParentAxis(org.sirix.axis.ParentAxis) NestedAxis(org.sirix.axis.NestedAxis) DupFilterAxis(org.sirix.service.xml.xpath.filter.DupFilterAxis) DescendantAxis(org.sirix.axis.DescendantAxis) UnionAxis(org.sirix.service.xml.xpath.expr.UnionAxis) Test(org.junit.Test)

Example 3 with DupFilterAxis

use of org.sirix.service.xml.xpath.filter.DupFilterAxis in project sirix by sirixdb.

the class PipelineBuilder method addUnionExpression.

/**
 * Adds a union expression to the pipeline.
 *
 * @param mTransaction Transaction to operate with.
 */
public void addUnionExpression(final XdmNodeReadTrx mTransaction) {
    assert getPipeStack().size() >= 2;
    final Axis mOperand2 = getPipeStack().pop().getExpr();
    final Axis mOperand1 = getPipeStack().pop().getExpr();
    if (getPipeStack().empty() || getExpression().getSize() != 0) {
        addExpressionSingle();
    }
    getExpression().add(new DupFilterAxis(mTransaction, new UnionAxis(mTransaction, mOperand1, mOperand2)));
}
Also used : DupFilterAxis(org.sirix.service.xml.xpath.filter.DupFilterAxis) ModOpAxis(org.sirix.service.xml.xpath.operators.ModOpAxis) RangeAxis(org.sirix.service.xml.xpath.expr.RangeAxis) AddOpAxis(org.sirix.service.xml.xpath.operators.AddOpAxis) ExceptAxis(org.sirix.service.xml.xpath.expr.ExceptAxis) Axis(org.sirix.api.Axis) MulOpAxis(org.sirix.service.xml.xpath.operators.MulOpAxis) UnionAxis(org.sirix.service.xml.xpath.expr.UnionAxis) IfAxis(org.sirix.service.xml.xpath.expr.IfAxis) IntersectAxis(org.sirix.service.xml.xpath.expr.IntersectAxis) IDivOpAxis(org.sirix.service.xml.xpath.operators.IDivOpAxis) DupFilterAxis(org.sirix.service.xml.xpath.filter.DupFilterAxis) PredicateFilterAxis(org.sirix.axis.filter.PredicateFilterAxis) VariableAxis(org.sirix.service.xml.xpath.expr.VariableAxis) ForAxis(org.sirix.axis.ForAxis) SequenceAxis(org.sirix.service.xml.xpath.expr.SequenceAxis) FilterAxis(org.sirix.axis.filter.FilterAxis) SubOpAxis(org.sirix.service.xml.xpath.operators.SubOpAxis) DivOpAxis(org.sirix.service.xml.xpath.operators.DivOpAxis) UnionAxis(org.sirix.service.xml.xpath.expr.UnionAxis)

Aggregations

UnionAxis (org.sirix.service.xml.xpath.expr.UnionAxis)3 DupFilterAxis (org.sirix.service.xml.xpath.filter.DupFilterAxis)3 Axis (org.sirix.api.Axis)2 ChildAxis (org.sirix.axis.ChildAxis)2 DescendantAxis (org.sirix.axis.DescendantAxis)2 FollowingSiblingAxis (org.sirix.axis.FollowingSiblingAxis)2 NestedAxis (org.sirix.axis.NestedAxis)2 ParentAxis (org.sirix.axis.ParentAxis)2 FilterAxis (org.sirix.axis.filter.FilterAxis)2 Test (org.junit.Test)1 AncestorAxis (org.sirix.axis.AncestorAxis)1 FollowingAxis (org.sirix.axis.FollowingAxis)1 ForAxis (org.sirix.axis.ForAxis)1 PrecedingAxis (org.sirix.axis.PrecedingAxis)1 PrecedingSiblingAxis (org.sirix.axis.PrecedingSiblingAxis)1 PredicateFilterAxis (org.sirix.axis.filter.PredicateFilterAxis)1 ExceptAxis (org.sirix.service.xml.xpath.expr.ExceptAxis)1 IfAxis (org.sirix.service.xml.xpath.expr.IfAxis)1 IntersectAxis (org.sirix.service.xml.xpath.expr.IntersectAxis)1 RangeAxis (org.sirix.service.xml.xpath.expr.RangeAxis)1