use of org.sirix.axis.NestedAxis 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.axis.NestedAxis in project sirix by sirixdb.
the class ConcurrentAxisTest method testPartConcurrentDescAxis2.
/**
* Test concurrent.
*
* @throws SirixXPathException
*/
// @Bench
@Test
public void testPartConcurrentDescAxis2() throws Exception {
/* query: //regions/africa//location */
final int resultNumber = 55;
final XdmNodeReadTrx firstConcurrRtx = holder.getResourceManager().beginNodeReadTrx();
final Axis axis = new NestedAxis(new NestedAxis(new FilterAxis(new DescendantAxis(firstConcurrRtx, IncludeSelf.YES), new NameFilter(firstConcurrRtx, "regions")), new FilterAxis(new ChildAxis(firstConcurrRtx), new NameFilter(firstConcurrRtx, "africa"))), new ConcurrentAxis(firstConcurrRtx, new FilterAxis(new DescendantAxis(holder.getReader(), IncludeSelf.YES), new NameFilter(holder.getReader(), "location"))));
for (int i = 0; i < resultNumber; i++) {
assertEquals(true, axis.hasNext());
axis.next();
}
assertEquals(axis.hasNext(), false);
}
use of org.sirix.axis.NestedAxis in project sirix by sirixdb.
the class ConcurrentAxisTest method testConcurrent.
/**
* Test concurrent.
*
* @throws SirixException
*
* @throws SirixXPathException
*/
// @Bench
@Test
public void testConcurrent() throws Exception {
/* query: //regions/africa//location */
final int resultNumber = 55;
final XdmNodeReadTrx firstConcurrRtx = holder.getResourceManager().beginNodeReadTrx();
final XdmNodeReadTrx secondConcurrRtx = holder.getResourceManager().beginNodeReadTrx();
final XdmNodeReadTrx thirdConcurrRtx = holder.getResourceManager().beginNodeReadTrx();
final XdmNodeReadTrx firstRtx = holder.getResourceManager().beginNodeReadTrx();
final XdmNodeReadTrx secondRtx = holder.getResourceManager().beginNodeReadTrx();
final XdmNodeReadTrx thirdRtx = holder.getResourceManager().beginNodeReadTrx();
final Axis axis = new NestedAxis(new NestedAxis(new ConcurrentAxis(firstConcurrRtx, new FilterAxis(new DescendantAxis(firstRtx, IncludeSelf.YES), new NameFilter(firstRtx, "regions"))), new ConcurrentAxis(secondConcurrRtx, new FilterAxis(new ChildAxis(secondRtx), new NameFilter(secondRtx, "africa")))), new ConcurrentAxis(thirdConcurrRtx, new FilterAxis(new DescendantAxis(thirdRtx, IncludeSelf.YES), new NameFilter(thirdRtx, "location"))));
for (int i = 0; i < resultNumber; i++) {
assertEquals(true, axis.hasNext());
axis.next();
}
assertEquals(false, axis.hasNext());
}
use of org.sirix.axis.NestedAxis 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.axis.NestedAxis in project sirix by sirixdb.
the class ExpressionSingleTest method testAdd.
@Test
public void testAdd() throws SirixException {
// Verify.
final ExpressionSingle builder = new ExpressionSingle();
// test one axis
AbstractAxis self = new SelfAxis(holder.getReader());
builder.add(self);
assertEquals(builder.getExpr(), self);
// test 2 axis
AbstractAxis axis1 = new SelfAxis(holder.getReader());
AbstractAxis axis2 = new SelfAxis(holder.getReader());
builder.add(axis1);
builder.add(axis2);
assertTrue(builder.getExpr() instanceof NestedAxis);
}
Aggregations