Search in sources :

Example 46 with XdmNodeReadTrx

use of org.sirix.api.XdmNodeReadTrx in project sirix by sirixdb.

the class DiffTestHelper method setUpSeventh.

static void setUpSeventh(final Holder holder) throws SirixException, IOException, XMLStreamException {
    final XdmNodeWriteTrx wtx = holder.getWriter();
    DocumentCreater.create(wtx);
    wtx.commit();
    final XdmNodeReadTrx rtx = holder.getResourceManager().beginNodeReadTrx(1);
    rtx.moveTo(1);
    wtx.moveTo(5);
    wtx.replaceNode(rtx);
    wtx.commit();
    rtx.close();
}
Also used : XdmNodeWriteTrx(org.sirix.api.XdmNodeWriteTrx) XdmNodeReadTrx(org.sirix.api.XdmNodeReadTrx)

Example 47 with XdmNodeReadTrx

use of org.sirix.api.XdmNodeReadTrx 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);
}
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 48 with XdmNodeReadTrx

use of org.sirix.api.XdmNodeReadTrx 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 49 with XdmNodeReadTrx

use of org.sirix.api.XdmNodeReadTrx in project sirix by sirixdb.

the class CommentFilterTest method testFilterConvetions.

@Test
public void testFilterConvetions() throws SirixException {
    final XdmNodeReadTrx wtx = holder.getReader();
    wtx.moveTo(9L);
    FilterTest.testFilterConventions(new CommentFilter(wtx), false);
    wtx.moveTo(4L);
    FilterTest.testFilterConventions(new CommentFilter(wtx), false);
    wtx.moveTo(1L);
    wtx.moveToAttribute(0);
    FilterTest.testFilterConventions(new CommentFilter(wtx), false);
    wtx.moveTo(9L);
    wtx.moveToAttribute(0);
    FilterTest.testFilterConventions(new CommentFilter(wtx), false);
}
Also used : XdmNodeReadTrx(org.sirix.api.XdmNodeReadTrx) Test(org.junit.Test)

Example 50 with XdmNodeReadTrx

use of org.sirix.api.XdmNodeReadTrx in project sirix by sirixdb.

the class DocumentRootNodeFilterTest method testFilterConvetions.

@Test
public void testFilterConvetions() throws SirixException {
    final XdmNodeReadTrx rtx = holder.getReader();
    rtx.moveTo(0L);
    FilterTest.testFilterConventions(new DocumentRootNodeFilter(rtx), true);
    rtx.moveTo(1L);
    FilterTest.testFilterConventions(new DocumentRootNodeFilter(rtx), false);
    rtx.moveTo(1L);
    rtx.moveToAttribute(0);
    FilterTest.testFilterConventions(new DocumentRootNodeFilter(rtx), false);
    rtx.moveTo(3L);
    FilterTest.testFilterConventions(new DocumentRootNodeFilter(rtx), false);
    rtx.moveTo(4L);
    FilterTest.testFilterConventions(new DocumentRootNodeFilter(rtx), false);
    rtx.moveTo(5L);
    FilterTest.testFilterConventions(new DocumentRootNodeFilter(rtx), false);
    rtx.moveTo(9L);
    FilterTest.testFilterConventions(new DocumentRootNodeFilter(rtx), false);
    rtx.moveTo(9L);
    rtx.moveToAttribute(0);
    FilterTest.testFilterConventions(new DocumentRootNodeFilter(rtx), false);
    rtx.moveTo(12L);
    FilterTest.testFilterConventions(new DocumentRootNodeFilter(rtx), false);
    rtx.moveTo(13L);
    rtx.moveToDocumentRoot();
    FilterTest.testFilterConventions(new DocumentRootNodeFilter(rtx), true);
}
Also used : XdmNodeReadTrx(org.sirix.api.XdmNodeReadTrx) Test(org.junit.Test)

Aggregations

XdmNodeReadTrx (org.sirix.api.XdmNodeReadTrx)150 Test (org.junit.Test)93 XdmNodeWriteTrx (org.sirix.api.XdmNodeWriteTrx)48 QNm (org.brackit.xquery.atomic.QNm)20 DescendantAxis (org.sirix.axis.DescendantAxis)17 Iterator (java.util.Iterator)16 ResourceManager (org.sirix.api.ResourceManager)14 Axis (org.sirix.api.Axis)13 DBNode (org.sirix.xquery.node.DBNode)12 QueryException (org.brackit.xquery.QueryException)11 FilterAxis (org.sirix.axis.filter.FilterAxis)11 IndexController (org.sirix.access.IndexController)10 IndexDef (org.sirix.index.IndexDef)10 Item (org.brackit.xquery.xdm.Item)7 Database (org.sirix.api.Database)7 SirixException (org.sirix.exception.SirixException)6 NonStructuralWrapperAxis (org.sirix.axis.NonStructuralWrapperAxis)5 SirixDeweyID (org.sirix.node.SirixDeweyID)5 Path (java.nio.file.Path)4 AbsAxisTest (org.sirix.axis.AbsAxisTest)4