use of org.brackit.xquery.atomic.Int32 in project sirix by sirixdb.
the class FindCASIndex 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();
final IndexController controller = rtx.getResourceManager().getRtxIndexController(rtx.getRevisionNumber());
if (controller == null) {
throw new QueryException(new QNm("Document not found: " + ((Str) args[1]).stringValue()));
}
final QNm name = new QNm(Namespaces.XS_NSURI, ((Str) args[1]).stringValue());
final Type type = sctx.getTypes().resolveAtomicType(name);
final Path<QNm> path = Path.parse(((Str) args[2]).stringValue());
final Optional<IndexDef> indexDef = controller.getIndexes().findCASIndex(path, type);
if (indexDef.isPresent())
return new Int32(indexDef.get().getID());
return new Int32(-1);
}
use of org.brackit.xquery.atomic.Int32 in project sirix by sirixdb.
the class FindPathIndex 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();
final IndexController controller = rtx.getResourceManager().getRtxIndexController(rtx.getRevisionNumber());
if (controller == null) {
throw new QueryException(new QNm("Document not found: " + ((Str) args[1]).stringValue()));
}
final Path<QNm> path = Path.parse(((Str) args[1]).stringValue());
final Optional<IndexDef> indexDef = controller.getIndexes().findPathIndex(path);
if (indexDef.isPresent())
return new Int32(indexDef.get().getID());
return new Int32(-1);
}
use of org.brackit.xquery.atomic.Int32 in project sirix by sirixdb.
the class FindNameIndex 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();
final IndexController controller = rtx.getResourceManager().getRtxIndexController(rtx.getRevisionNumber());
if (controller == null) {
throw new QueryException(new QNm("Document not found: " + ((Str) args[1]).stringValue()));
}
final QNm qnm = (QNm) Cast.cast(sctx, (Atomic) args[1], Type.QNM, false);
final Optional<IndexDef> indexDef = controller.getIndexes().findNameIndex(qnm);
if (indexDef.isPresent())
return new Int32(indexDef.get().getID());
return new Int32(-1);
}
Aggregations