use of org.brackit.xquery.util.path.PathException in project sirix by sirixdb.
the class CASIndexBuilder method process.
private VisitResult process(final ImmutableNode node) {
try {
if (node.getKind() == Kind.TEXT) {
mRtx.moveTo(node.getParentKey());
}
final long PCR = mRtx.isDocumentRoot() ? 0 : mRtx.getNameNode().getPathNodeKey();
if (mPaths.isEmpty() || mPathSummaryReader.getPCRsForPaths(mPaths).contains(PCR)) {
final Str strValue = new Str(((ImmutableValueNode) node).getValue());
boolean isOfType = false;
try {
if (mType != Type.STR)
AtomicUtil.toType(strValue, mType);
isOfType = true;
} catch (final SirixRuntimeException e) {
}
if (isOfType) {
final CASValue value = new CASValue(strValue, mType, PCR);
final Optional<NodeReferences> textReferences = mAVLTreeWriter.get(value, SearchMode.EQUAL);
if (textReferences.isPresent()) {
setNodeReferences(node, textReferences.get(), value);
} else {
setNodeReferences(node, new NodeReferences(), value);
}
}
}
mRtx.moveTo(node.getNodeKey());
} catch (final PathException | SirixIOException e) {
LOGGER.error(e.getMessage(), e);
}
return VisitResultType.CONTINUE;
}
use of org.brackit.xquery.util.path.PathException in project sirix by sirixdb.
the class CASIndexListener method listen.
@Override
public void listen(final ChangeType type, final ImmutableNode node, final long pathNodeKey) throws SirixIOException {
if (node instanceof ValueNode) {
final ValueNode valueNode = ((ValueNode) node);
mPathSummaryReader.moveTo(pathNodeKey);
try {
switch(type) {
case INSERT:
if (mPathSummaryReader.getPCRsForPaths(mPaths).contains(pathNodeKey)) {
insert(valueNode, pathNodeKey);
}
break;
case DELETE:
if (mPathSummaryReader.getPCRsForPaths(mPaths).contains(pathNodeKey)) {
mAVLTreeWriter.remove(new CASValue(new Str(valueNode.getValue()), mType, pathNodeKey), node.getNodeKey());
}
break;
default:
}
} catch (final PathException e) {
throw new SirixIOException(e);
}
}
}
use of org.brackit.xquery.util.path.PathException 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();
}
Aggregations