Search in sources :

Example 6 with PathSummaryReader

use of org.sirix.index.path.summary.PathSummaryReader in project sirix by sirixdb.

the class PathSummaryTest method testFirstMoveToFirstChild.

@Test
public void testFirstMoveToFirstChild() throws SirixException {
    wtx.moveTo(5);
    wtx.moveSubtreeToFirstChild(9);
    PathSummaryReader pathSummary = wtx.getPathSummary();
    pathSummary.moveToDocumentRoot();
    wtx.commit();
    wtx.close();
    final XdmNodeReadTrx rtx = holder.getResourceManager().beginNodeReadTrx();
    rtx.close();
}
Also used : XdmNodeReadTrx(org.sirix.api.XdmNodeReadTrx) PathSummaryReader(org.sirix.index.path.summary.PathSummaryReader) Test(org.junit.Test)

Example 7 with PathSummaryReader

use of org.sirix.index.path.summary.PathSummaryReader in project sirix by sirixdb.

the class PathSummaryTest method testDelete.

/**
 * Test delete on test document.
 *
 * @throws SirixException if Sirix fails
 */
@Test
public void testDelete() throws SirixException {
    PathSummaryReader pathSummary = wtx.getPathSummary();
    pathSummary.moveToDocumentRoot();
    testInsertHelper(pathSummary);
    wtx.commit();
    wtx.moveTo(9);
    wtx.remove();
    pathSummary = wtx.getPathSummary();
    pathSummary.moveToDocumentRoot();
    testDeleteHelper(pathSummary);
    wtx.commit();
    wtx.close();
    pathSummary = holder.getResourceManager().openPathSummary();
    testDeleteHelper(pathSummary);
    pathSummary.close();
}
Also used : PathSummaryReader(org.sirix.index.path.summary.PathSummaryReader) Test(org.junit.Test)

Example 8 with PathSummaryReader

use of org.sirix.index.path.summary.PathSummaryReader in project sirix by sirixdb.

the class PathSummaryTest method testSetQNmFourthHelper.

private void testSetQNmFourthHelper(final PathSummaryReader pSummary) throws SirixException {
    final Axis axis = new DescendantAxis(pSummary);
    PathSummaryReader summary = next(axis);
    assertTrue(summary != null);
    assertEquals(Kind.ELEMENT, summary.getPathKind());
    assertEquals(1L, summary.getNodeKey());
    assertEquals(7L, summary.getFirstChildKey());
    assertEquals(-1L, summary.getLeftSiblingKey());
    assertEquals(-1L, summary.getRightSiblingKey());
    assertEquals(new QNm("ns", "p", "a"), axis.getTrx().getName());
    assertEquals(1, summary.getLevel());
    assertEquals(4, summary.getChildCount());
    assertEquals(1, summary.getReferences());
    summary = next(axis);
    assertTrue(summary != null);
    assertEquals(Kind.ELEMENT, summary.getPathKind());
    assertEquals(7L, summary.getNodeKey());
    assertEquals(8L, summary.getFirstChildKey());
    assertEquals(-1L, summary.getLeftSiblingKey());
    assertEquals(4L, summary.getRightSiblingKey());
    assertEquals(new QNm("d"), axis.getTrx().getName());
    assertEquals(2, summary.getLevel());
    assertEquals(1, summary.getChildCount());
    assertEquals(1, summary.getReferences());
    summary = next(axis);
    assertTrue(summary != null);
    assertEquals(Kind.ELEMENT, summary.getPathKind());
    assertEquals(8L, summary.getNodeKey());
    assertEquals(-1L, summary.getFirstChildKey());
    assertEquals(-1L, summary.getLeftSiblingKey());
    assertEquals(-1L, summary.getRightSiblingKey());
    assertEquals(new QNm("c"), axis.getTrx().getName());
    assertEquals(3, summary.getLevel());
    assertEquals(0, summary.getChildCount());
    assertEquals(1, summary.getReferences());
    summary = next(axis);
    assertTrue(summary != null);
    assertEquals(Kind.ELEMENT, summary.getPathKind());
    assertEquals(4L, summary.getNodeKey());
    assertEquals(7L, summary.getLeftSiblingKey());
    assertEquals(3L, summary.getRightSiblingKey());
    assertEquals(6L, summary.getFirstChildKey());
    assertEquals(new QNm("b"), axis.getTrx().getName());
    assertEquals(2, summary.getLevel());
    assertEquals(2, summary.getChildCount());
    assertEquals(2, summary.getReferences());
    summary = next(axis);
    assertTrue(summary != null);
    assertEquals(Kind.ATTRIBUTE, summary.getPathKind());
    assertEquals(6L, summary.getNodeKey());
    assertEquals(-1L, summary.getLeftSiblingKey());
    assertEquals(5L, summary.getRightSiblingKey());
    assertEquals(-1L, summary.getFirstChildKey());
    assertEquals(new QNm("ns", "", "x"), axis.getTrx().getName());
    assertEquals(3, summary.getLevel());
    assertEquals(0, summary.getChildCount());
    assertEquals(1, summary.getReferences());
    summary = next(axis);
    assertTrue(summary != null);
    assertEquals(Kind.ELEMENT, summary.getPathKind());
    assertEquals(5L, summary.getNodeKey());
    assertEquals(6L, summary.getLeftSiblingKey());
    assertEquals(-1L, summary.getRightSiblingKey());
    assertEquals(-1L, summary.getFirstChildKey());
    assertEquals(new QNm("c"), axis.getTrx().getName());
    assertEquals(3, summary.getLevel());
    assertEquals(0, summary.getChildCount());
    assertEquals(1, summary.getReferences());
    summary = next(axis);
    assertTrue(summary != null);
    assertEquals(Kind.ATTRIBUTE, summary.getPathKind());
    assertEquals(3L, summary.getNodeKey());
    assertEquals(4L, summary.getLeftSiblingKey());
    assertEquals(2L, summary.getRightSiblingKey());
    assertEquals(-1L, summary.getFirstChildKey());
    assertEquals(new QNm("i"), axis.getTrx().getName());
    assertEquals(2, summary.getLevel());
    assertEquals(0, summary.getChildCount());
    assertEquals(1, summary.getReferences());
    summary = next(axis);
    assertTrue(summary != null);
    assertEquals(Kind.NAMESPACE, summary.getPathKind());
    assertEquals(2L, summary.getNodeKey());
    assertEquals(3L, summary.getLeftSiblingKey());
    assertEquals(-1L, summary.getRightSiblingKey());
    assertEquals(-1L, summary.getFirstChildKey());
    assertEquals(new QNm("ns", "p", ""), axis.getTrx().getName());
    assertEquals(2, summary.getLevel());
    assertEquals(0, summary.getChildCount());
    assertEquals(1, summary.getReferences());
    summary = next(axis);
    assertTrue(summary == null);
}
Also used : QNm(org.brackit.xquery.atomic.QNm) PathSummaryReader(org.sirix.index.path.summary.PathSummaryReader) DescendantAxis(org.sirix.axis.DescendantAxis) Axis(org.sirix.api.Axis) DescendantAxis(org.sirix.axis.DescendantAxis)

Example 9 with PathSummaryReader

use of org.sirix.index.path.summary.PathSummaryReader in project sirix by sirixdb.

the class PathSummaryTest method testSetQNmFirst.

/**
 * Test setQNm on test document (does not find a corresponding path summary after rename).
 *
 * @throws SirixException if Sirix fails
 */
@Test
public void testSetQNmFirst() throws SirixException {
    wtx.moveTo(9);
    wtx.setName(new QNm("foo"));
    PathSummaryReader pathSummary = wtx.getPathSummary();
    pathSummary.moveToDocumentRoot();
    testSetQNmFirstHelper(pathSummary);
    wtx.commit();
    wtx.close();
    pathSummary = holder.getResourceManager().openPathSummary();
    testSetQNmFirstHelper(pathSummary);
    pathSummary.close();
}
Also used : QNm(org.brackit.xquery.atomic.QNm) PathSummaryReader(org.sirix.index.path.summary.PathSummaryReader) Test(org.junit.Test)

Example 10 with PathSummaryReader

use of org.sirix.index.path.summary.PathSummaryReader in project sirix by sirixdb.

the class PathSummaryTest method testSecondMoveToFirstChild.

@Test
public void testSecondMoveToFirstChild() throws SirixException {
    wtx.moveTo(9);
    wtx.insertElementAsFirstChild(new QNm("foo"));
    wtx.insertElementAsFirstChild(new QNm("bar"));
    PathSummaryReader pathSummary = wtx.getPathSummary();
    pathSummary.moveToDocumentRoot();
    wtx.moveTo(5);
    wtx.moveSubtreeToRightSibling(9);
    pathSummary = wtx.getPathSummary();
    pathSummary.moveToDocumentRoot();
    wtx.commit();
    wtx.close();
    final XdmNodeReadTrx rtx = holder.getResourceManager().beginNodeReadTrx();
    rtx.close();
}
Also used : QNm(org.brackit.xquery.atomic.QNm) XdmNodeReadTrx(org.sirix.api.XdmNodeReadTrx) PathSummaryReader(org.sirix.index.path.summary.PathSummaryReader) Test(org.junit.Test)

Aggregations

PathSummaryReader (org.sirix.index.path.summary.PathSummaryReader)16 QNm (org.brackit.xquery.atomic.QNm)11 Test (org.junit.Test)8 Axis (org.sirix.api.Axis)6 DescendantAxis (org.sirix.axis.DescendantAxis)6 XdmNodeReadTrx (org.sirix.api.XdmNodeReadTrx)3 Str (org.brackit.xquery.atomic.Str)1 PathException (org.brackit.xquery.util.path.PathException)1 XdmNodeWriteTrx (org.sirix.api.XdmNodeWriteTrx)1 DBNode (org.sirix.xquery.node.DBNode)1