Search in sources :

Example 6 with ChildAxis

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());
}
Also used : ChildAxis(org.sirix.axis.ChildAxis) NameFilter(org.sirix.axis.filter.NameFilter) XdmNodeReadTrx(org.sirix.api.XdmNodeReadTrx) NestedAxis(org.sirix.axis.NestedAxis) DescendantAxis(org.sirix.axis.DescendantAxis) Axis(org.sirix.api.Axis) NestedAxis(org.sirix.axis.NestedAxis) ChildAxis(org.sirix.axis.ChildAxis) FilterAxis(org.sirix.axis.filter.FilterAxis) DescendantAxis(org.sirix.axis.DescendantAxis) XPathAxis(org.sirix.service.xml.xpath.XPathAxis) FilterAxis(org.sirix.axis.filter.FilterAxis) Test(org.junit.Test)

Example 7 with ChildAxis

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);
}
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 8 with ChildAxis

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());
}
Also used : ChildAxis(org.sirix.axis.ChildAxis) NameFilter(org.sirix.axis.filter.NameFilter) NestedAxis(org.sirix.axis.NestedAxis) DescendantAxis(org.sirix.axis.DescendantAxis) Axis(org.sirix.api.Axis) NestedAxis(org.sirix.axis.NestedAxis) ChildAxis(org.sirix.axis.ChildAxis) FilterAxis(org.sirix.axis.filter.FilterAxis) DescendantAxis(org.sirix.axis.DescendantAxis) XPathAxis(org.sirix.service.xml.xpath.XPathAxis) FilterAxis(org.sirix.axis.filter.FilterAxis) Test(org.junit.Test)

Example 9 with ChildAxis

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());
}
Also used : ChildAxis(org.sirix.axis.ChildAxis) NameFilter(org.sirix.axis.filter.NameFilter) XdmNodeReadTrx(org.sirix.api.XdmNodeReadTrx) NestedAxis(org.sirix.axis.NestedAxis) DescendantAxis(org.sirix.axis.DescendantAxis) Axis(org.sirix.api.Axis) NestedAxis(org.sirix.axis.NestedAxis) ChildAxis(org.sirix.axis.ChildAxis) FilterAxis(org.sirix.axis.filter.FilterAxis) DescendantAxis(org.sirix.axis.DescendantAxis) XPathAxis(org.sirix.service.xml.xpath.XPathAxis) FilterAxis(org.sirix.axis.filter.FilterAxis) Test(org.junit.Test)

Example 10 with ChildAxis

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;
}
Also used : ChildAxis(org.sirix.axis.ChildAxis) NameFilter(org.sirix.axis.filter.NameFilter) PageKind(org.sirix.page.PageKind) Kind(org.sirix.node.Kind) UnorderedKeyValuePage(org.sirix.page.UnorderedKeyValuePage) Axis(org.sirix.api.Axis) ChildAxis(org.sirix.axis.ChildAxis) PostOrderAxis(org.sirix.axis.PostOrderAxis) FilterAxis(org.sirix.axis.filter.FilterAxis) DescendantAxis(org.sirix.axis.DescendantAxis) LevelOrderAxis(org.sirix.axis.LevelOrderAxis) FilterAxis(org.sirix.axis.filter.FilterAxis) PathKindFilter(org.sirix.axis.filter.PathKindFilter)

Aggregations

ChildAxis (org.sirix.axis.ChildAxis)11 DescendantAxis (org.sirix.axis.DescendantAxis)9 FilterAxis (org.sirix.axis.filter.FilterAxis)9 Axis (org.sirix.api.Axis)8 NameFilter (org.sirix.axis.filter.NameFilter)7 NestedAxis (org.sirix.axis.NestedAxis)6 Test (org.junit.Test)5 XPathAxis (org.sirix.service.xml.xpath.XPathAxis)4 XdmNodeReadTrx (org.sirix.api.XdmNodeReadTrx)3 AbstractAxis (org.sirix.axis.AbstractAxis)3 FollowingSiblingAxis (org.sirix.axis.FollowingSiblingAxis)3 ParentAxis (org.sirix.axis.ParentAxis)3 AncestorAxis (org.sirix.axis.AncestorAxis)2 AttributeAxis (org.sirix.axis.AttributeAxis)2 FollowingAxis (org.sirix.axis.FollowingAxis)2 LevelOrderAxis (org.sirix.axis.LevelOrderAxis)2 PostOrderAxis (org.sirix.axis.PostOrderAxis)2 PrecedingAxis (org.sirix.axis.PrecedingAxis)2 PrecedingSiblingAxis (org.sirix.axis.PrecedingSiblingAxis)2 PathKindFilter (org.sirix.axis.filter.PathKindFilter)2