use of org.apache.jena.atlas.lib.InternalErrorException in project jena by apache.
the class NodeTransformExpr method transform.
/**
* Transform node then create a {@link ExprVar} or {@link NodeValue}.
*/
private Expr transform(Node input) {
Node n = transform.apply(input);
if (n == null)
throw new InternalErrorException("NodeTransform creates a null");
if (!Var.isVar(n))
return NodeValue.makeNode(n);
String name = Var.alloc(n).getVarName();
return new ExprVar(n.getName());
}
use of org.apache.jena.atlas.lib.InternalErrorException in project jena by apache.
the class RefEval method evalGraph.
static Table evalGraph(OpGraph opGraph, Evaluator evaluator) {
ExecutionContext execCxt = evaluator.getExecContext();
if (!Var.isVar(opGraph.getNode())) {
DatasetGraph dsg = execCxt.getDataset();
Node graphNode = opGraph.getNode();
if (!dsg.containsGraph(graphNode))
return new TableEmpty();
Graph graph = execCxt.getDataset().getGraph(opGraph.getNode());
if (// But contains was true?!!
graph == null)
throw new InternalErrorException("Graph was present, now it's not");
ExecutionContext execCxt2 = new ExecutionContext(execCxt, graph);
Evaluator e2 = EvaluatorFactory.create(execCxt2);
return eval(e2, opGraph.getSubOp());
}
// Graph node is a variable.
Var gVar = Var.alloc(opGraph.getNode());
Table current = null;
for (Iterator<Node> iter = execCxt.getDataset().listGraphNodes(); iter.hasNext(); ) {
Node gn = iter.next();
Graph graph = execCxt.getDataset().getGraph(gn);
ExecutionContext execCxt2 = new ExecutionContext(execCxt, graph);
Evaluator e2 = EvaluatorFactory.create(execCxt2);
Table tableVarURI = TableFactory.create(gVar, gn);
// Evaluate the pattern, join with this graph node possibility.
// XXX If Var.ANON then no-opt.
Table patternTable = eval(e2, opGraph.getSubOp());
Table stepResult = evaluator.join(patternTable, tableVarURI);
if (current == null)
current = stepResult;
else
current = evaluator.union(current, stepResult);
}
if (current == null)
// Nothing to loop over
return new TableEmpty();
return current;
}
use of org.apache.jena.atlas.lib.InternalErrorException in project jena by apache.
the class JsonLDReader method createNode.
private Node createNode(Map<String, Object> map) {
String type = (String) map.get("type");
String lex = (String) map.get("value");
if (type.equals(IRI))
return createURI(lex);
else if (type.equals(BLANK_NODE))
return createBlankNode(lex);
else if (type.equals(LITERAL)) {
String lang = (String) map.get("language");
String datatype = (String) map.get("datatype");
if (Objects.equals(xsdString, datatype))
// In RDF 1.1, simple literals and xsd:string are the same.
// During migration, we prefer simple literals to xsd:strings.
datatype = null;
if (lang == null && datatype == null)
return profile.createStringLiteral(lex, -1, -1);
if (lang != null)
return profile.createLangLiteral(lex, lang, -1, -1);
RDFDatatype dt = NodeFactory.getType(datatype);
return profile.createTypedLiteral(lex, dt, -1, -1);
} else
throw new InternalErrorException("Node is not a IRI, bNode or a literal: " + type);
}
use of org.apache.jena.atlas.lib.InternalErrorException in project jena by apache.
the class BPTreeRangeIteratorMapper method loadStack.
private BPTreeRecords loadStack(BPTreeNode node) {
AccessPath path = new AccessPath(null);
node.bpTree.startReadBlkMgr();
if (minRecord == null)
node.internalMinRecord(path);
else
node.internalSearch(path, minRecord);
List<AccessStep> steps = path.getPath();
for (AccessStep step : steps) {
BPTreeNode n = step.node;
Iterator<BPTreePage> it = n.iterator(minRecord, maxRecord);
if (it == null || !it.hasNext())
continue;
BPTreePage p = it.next();
stack.push(it);
}
BPTreePage p = steps.get(steps.size() - 1).page;
if (!(p instanceof BPTreeRecords))
throw new InternalErrorException("Last path step not to a records block");
node.bpTree.finishReadBlkMgr();
return (BPTreeRecords) p;
}
use of org.apache.jena.atlas.lib.InternalErrorException in project jena by apache.
the class BPTreeRangeIteratorMapper method next.
@Override
public X next() {
if (!hasNext())
throw new NoSuchElementException();
X r = slot;
if (r == null)
throw new InternalErrorException("Null slot after hasNext is true");
slot = null;
return r;
}
Aggregations