@Override
protected IScalarEvaluator createEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args)
throws AlgebricksException {
final ArrayBackedValueStorage abvs = new ArrayBackedValueStorage();
final DataOutput dOut = abvs.getDataOutput();
final NodeTreePointable ntp = (NodeTreePointable) NodeTreePointable.FACTORY.createPointable();
final TypedPointables tp = new TypedPointables();
return new AbstractTaggedValueArgumentScalarEvaluator(args) {
@Override
protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException {
TaggedValuePointable tvp1 = args[0];
// Only accept node trees as input.
try {
int localNodeId = FunctionHelper.getLocalNodeId(tvp1, tp);
if (localNodeId == -1) {
XDMConstants.setEmptySequence(result);
} else {
tvp1.getValue(ntp);
abvs.reset();
dOut.write(ValueTag.XS_LONG_TAG);
dOut.writeInt(ntp.getRootNodeId());
dOut.writeInt(localNodeId);
result.set(abvs);
}
} catch (Exception e) {
throw new SystemException(ErrorCode.SYSE0001, e);