Search in sources :

Example 1 with PathSummaryReader

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

the class PCRCollectorImpl method getPCRsForPaths.

@Override
public PCRValue getPCRsForPaths(Set<Path<QNm>> paths) {
    try (final PathSummaryReader reader = mRtx instanceof XdmNodeWriteTrx ? ((XdmNodeWriteTrx) mRtx).getPathSummary() : mRtx.getResourceManager().openPathSummary(mRtx.getRevisionNumber())) {
        final long maxPCR = reader.getMaxNodeKey();
        final Set<Long> pathClassRecords = reader.getPCRsForPaths(paths);
        return PCRValue.getInstance(maxPCR, pathClassRecords);
    } catch (final PathException e) {
        LOGGER.error(e.getMessage(), e);
    }
    return PCRValue.getEmptyInstance();
}
Also used : XdmNodeWriteTrx(org.sirix.api.XdmNodeWriteTrx) PathException(org.brackit.xquery.util.path.PathException) PathSummaryReader(org.sirix.index.path.summary.PathSummaryReader)

Example 2 with PathSummaryReader

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

the class GetPath method execute.

@Override
public Sequence execute(StaticContext sctx, QueryContext ctx, Sequence[] args) throws QueryException {
    final DBNode doc = ((DBNode) args[0]);
    final XdmNodeReadTrx rtx = doc.getTrx();
    if (rtx.getResourceManager().getResourceConfig().mPathSummary) {
        try (final PathSummaryReader pathSummaryReader = rtx.getResourceManager().openPathSummary(rtx.getRevisionNumber())) {
            pathSummaryReader.moveTo(rtx.getPathNodeKey());
            return new Str(pathSummaryReader.getPathNode().getPath(pathSummaryReader).toString());
        }
    }
    return null;
}
Also used : DBNode(org.sirix.xquery.node.DBNode) Str(org.brackit.xquery.atomic.Str) XdmNodeReadTrx(org.sirix.api.XdmNodeReadTrx) PathSummaryReader(org.sirix.index.path.summary.PathSummaryReader)

Example 3 with PathSummaryReader

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

the class PathSummaryTest method testSetQNmSecond.

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

Example 4 with PathSummaryReader

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

the class PathSummaryTest method testSetQNmThird.

/**
 * Test setQNm on test document (finds no corresponding path summary after rename -- after
 * references dropped to 0).
 *
 * @throws SirixException if Sirix fails
 */
@Test
public void testSetQNmThird() throws SirixException {
    wtx.moveTo(9);
    wtx.setName(new QNm("d"));
    wtx.moveTo(5);
    wtx.setName(new QNm("t"));
    PathSummaryReader pathSummary = wtx.getPathSummary();
    pathSummary.moveToDocumentRoot();
    testSetQNmThirdHelper(pathSummary);
    wtx.commit();
    wtx.close();
    pathSummary = holder.getResourceManager().openPathSummary();
    testSetQNmThirdHelper(pathSummary);
    pathSummary.close();
}
Also used : QNm(org.brackit.xquery.atomic.QNm) PathSummaryReader(org.sirix.index.path.summary.PathSummaryReader) Test(org.junit.Test)

Example 5 with PathSummaryReader

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

the class PathSummaryTest method testSetQNmFourth.

/**
 * Test setQNm on test document (finds no corresponding path summary after rename -- after
 * references dropped to 0).
 *
 * @throws SirixException if Sirix fails
 */
@Test
public void testSetQNmFourth() throws SirixException {
    wtx.moveTo(1);
    wtx.insertElementAsFirstChild(new QNm("b"));
    wtx.moveTo(5);
    wtx.setName(new QNm("d"));
    PathSummaryReader pathSummary = wtx.getPathSummary();
    pathSummary.moveToDocumentRoot();
    testSetQNmFourthHelper(pathSummary);
    wtx.commit();
    wtx.close();
    pathSummary = holder.getResourceManager().openPathSummary();
    testSetQNmFourthHelper(pathSummary);
    pathSummary.close();
}
Also used : QNm(org.brackit.xquery.atomic.QNm) 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