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);
}
}
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);
}
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)));
}
Aggregations