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();
}
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;
}
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();
}
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();
}
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();
}
Aggregations