use of org.sirix.axis.ChildAxis 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.ChildAxis 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.ChildAxis in project sirix by sirixdb.
the class ConcurrentAxisTest method testSeriellNew.
/**
* Test seriell.
*/
// @Bench
@Test
public void testSeriellNew() throws Exception {
/* query: //regions/africa//location */
final int resultNumber = 55;
final Axis axis = new NestedAxis(new NestedAxis(new FilterAxis(new DescendantAxis(holder.getReader(), IncludeSelf.YES), new NameFilter(holder.getReader(), "regions")), new FilterAxis(new ChildAxis(holder.getReader()), new NameFilter(holder.getReader(), "africa"))), 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(false, axis.hasNext());
}
use of org.sirix.axis.ChildAxis in project sirix by sirixdb.
the class ConcurrentAxisTest method testPartConcurrentDescAxis1.
/**
* Test concurrent.
*
* @throws SirixXPathException
*/
// @Bench
@Test
public void testPartConcurrentDescAxis1() throws Exception {
/* query: //regions/africa//location */
final int resultNumber = 55;
final XdmNodeReadTrx firstConcurrRtx = holder.getResourceManager().beginNodeReadTrx();
final Axis axis = new NestedAxis(new NestedAxis(new ConcurrentAxis(firstConcurrRtx, new FilterAxis(new DescendantAxis(holder.getReader(), IncludeSelf.YES), new NameFilter(holder.getReader(), "regions"))), new FilterAxis(new ChildAxis(firstConcurrRtx), new NameFilter(firstConcurrRtx, "africa"))), new FilterAxis(new DescendantAxis(firstConcurrRtx, IncludeSelf.YES), new NameFilter(firstConcurrRtx, "location")));
for (int i = 0; i < resultNumber; i++) {
assertEquals(true, axis.hasNext());
axis.next();
}
assertEquals(false, axis.hasNext());
}
use of org.sirix.axis.ChildAxis in project sirix by sirixdb.
the class PathSummaryWriter method getPathNodeKey.
/**
* Insert a new path node or increment the counter of an existing node and return the path node
* key.
*
* @param name the name of the path node to search for
* @param pathKind the kind of the path node to search for
* @return a path node key of the found node, or the path node key of a new inserted node
* @throws SirixException if anything went wrong
*/
public long getPathNodeKey(final QNm name, final Kind pathKind) throws SirixException {
final Kind kind = mNodeRtx.getNode().getKind();
int level = 0;
if (kind == Kind.DOCUMENT) {
mPathSummaryReader.moveTo(Fixed.DOCUMENT_NODE_KEY.getStandardProperty());
} else {
movePathSummary();
level = mPathSummaryReader.getLevel();
}
final long nodeKey = mPathSummaryReader.getNodeKey();
final Axis axis = new FilterAxis(new ChildAxis(mPathSummaryReader), new NameFilter(mPathSummaryReader, pathKind == Kind.NAMESPACE ? name.getPrefix() : Utils.buildName(name)), new PathKindFilter(mPathSummaryReader, pathKind));
long retVal = nodeKey;
if (axis.hasNext()) {
axis.next();
retVal = mPathSummaryReader.getNodeKey();
final PathNode pathNode = (PathNode) mPageWriteTrx.prepareEntryForModification(retVal, PageKind.PATHSUMMARYPAGE, 0, Optional.<UnorderedKeyValuePage>empty());
pathNode.incrementReferenceCount();
} else {
assert nodeKey == mPathSummaryReader.getNodeKey();
insertPathAsFirstChild(name, pathKind, level + 1);
retVal = mPathSummaryReader.getNodeKey();
}
return retVal;
}
Aggregations