use of org.apache.jena.sparql.ARQInternalErrorException in project jena by apache.
the class OpExecutorTDB1 method reorder.
private static BasicPattern reorder(BasicPattern pattern, QueryIterPeek peek, ReorderTransformation transform) {
if (transform != null) {
if (!peek.hasNext())
throw new ARQInternalErrorException("Peek iterator is already empty");
BasicPattern pattern2 = Substitute.substitute(pattern, peek.peek());
// Calculate the reordering based on the substituted pattern.
ReorderProc proc = transform.reorderIndexes(pattern2);
// Then reorder original patten
pattern = proc.reorder(pattern);
}
return pattern;
}
use of org.apache.jena.sparql.ARQInternalErrorException in project jena by apache.
the class ParserBase method stripSign.
protected Node stripSign(Node node) {
if (!node.isLiteral())
return node;
String lex = node.getLiteralLexicalForm();
String lang = node.getLiteralLanguage();
RDFDatatype dt = node.getLiteralDatatype();
if (!lex.startsWith("-") && !lex.startsWith("+"))
throw new ARQInternalErrorException("Literal does not start with a sign: " + lex);
lex = lex.substring(1);
return NodeFactory.createLiteral(lex, lang, dt);
}
use of org.apache.jena.sparql.ARQInternalErrorException in project jena by apache.
the class strjoin method exec.
@Override
public final NodeValue exec(List<NodeValue> args) {
if (args == null)
// The contract on the function interface is that this should not happen.
throw new ARQInternalErrorException(Lib.className(this) + ": Null args list");
Iterator<NodeValue> iter = args.iterator();
String sep = iter.next().asString();
List<String> x = new ArrayList<>();
iter.forEachRemaining(arg -> x.add(arg.asString()));
return NodeValue.makeString(String.join(sep, x));
}
use of org.apache.jena.sparql.ARQInternalErrorException in project jena by apache.
the class FN_Matches method exec.
@Override
public NodeValue exec(Binding binding, ExprList args, String uri, FunctionEnv env) {
if (myArgs != args)
throw new ARQInternalErrorException("matches: Arguments have changed since checking");
Expr expr = args.get(0);
E_Regex regexEval = regex;
if (regexEval == null) {
Expr e1 = args.get(1);
Expr e2 = null;
if (args.size() == 3)
e2 = args.get(2);
String pattern = e1.eval(binding, env).getString();
String flags = (e2 == null) ? null : e2.eval(binding, env).getString();
regexEval = new E_Regex(expr, pattern, flags);
// Cache if the pattern is fixed and the flags are fixed or non-existant
if (e1 instanceof NodeValue && (e2 == null || e2 instanceof NodeValue))
regex = regexEval;
}
NodeValue nv = regexEval.eval(binding, env);
return nv;
}
use of org.apache.jena.sparql.ARQInternalErrorException in project jena by apache.
the class Math_pow method exec.
@Override
public NodeValue exec(NodeValue v1, NodeValue v2) {
switch(XSDFuncOp.classifyNumeric("pow", v1, v2)) {
case OP_INTEGER:
BigInteger x = v1.getInteger();
int y = v2.getInteger().intValue();
if (y >= 0)
return NodeValue.makeInteger(x.pow(y));
// Anything else -> double
case OP_DECIMAL:
case OP_FLOAT:
case OP_DOUBLE:
double d1 = v1.getDouble();
double d2 = v2.getDouble();
if (d1 == 1 && d2 == Double.POSITIVE_INFINITY) {
if (v1.isInteger())
return NodeValue.nvONE;
else
return NodeValue.makeDouble(1);
}
return NodeValue.makeDouble(Math.pow(v1.getDouble(), v2.getDouble()));
default:
throw new ARQInternalErrorException("Unrecognized numeric operation : " + v1);
}
}
Aggregations