use of org.apache.jena.sparql.ARQException in project jena by apache.
the class QueryTransformOps method transformVarExprList.
private static VarExprList transformVarExprList(VarExprList varExprList, ExprTransform exprTransform) {
VarExprList varExprList2 = new VarExprList();
boolean changed = false;
for (Var v : varExprList.getVars()) {
Expr e = varExprList.getExpr(v);
// Transform variable.
ExprVar ev = new ExprVar(v);
Expr ev2 = exprTransform.transform(ev);
if (ev != ev2)
changed = true;
if (e == null) {
// Variable only.
if (ev2.isConstant()) {
// Skip or old var, assign so it become (?old AS substitute)
// Skip .
// Require transform to add back substitutions "for the record";
varExprList2.remove(v);
varExprList2.add(v, ev2);
} else if (ev2.isVariable()) {
varExprList2.add(ev2.asVar());
} else {
throw new ARQException("Can't substitute " + v + " because it's not a simple value: " + ev2);
}
continue;
}
// There was an expression.
Expr e2 = ExprTransformer.transform(exprTransform, e);
if (e2 != e)
changed = true;
if (!ev2.isVariable())
throw new ARQException("Can't substitute (" + v + ", " + e + ") as (" + ev2 + ", " + e2 + ")");
varExprList2.add(ev.asVar(), e2);
}
return varExprList2;
}
use of org.apache.jena.sparql.ARQException in project jena by apache.
the class AssemblerUtils method readAssemblerFile.
public static Model readAssemblerFile(String assemblerFile) {
Model spec = null;
try {
spec = RDFDataMgr.loadModel(assemblerFile);
} catch (Exception ex) {
throw new ARQException("Failed reading assembler description: " + ex.getMessage());
}
addRegistered(spec);
return spec;
}
use of org.apache.jena.sparql.ARQException in project jena by apache.
the class ReorderProcIndexes method reorder.
/**
* Return a new basic pattern with the same triples as the input,
* but ordered as per the index list of this reorder processor.
*/
@Override
public BasicPattern reorder(BasicPattern bgp) {
if (indexes.length != bgp.size()) {
String str = String.format("Expected size = %d : actual basic pattern size = %d", indexes.length, bgp.size());
Log.error(this, str);
throw new ARQException(str);
}
BasicPattern bgp2 = new BasicPattern();
for (int idx : indexes) {
Triple t = bgp.get(idx);
bgp2.add(t);
}
return bgp2;
}
use of org.apache.jena.sparql.ARQException in project jena by apache.
the class ReorderTransformationSubstitution method reorder.
protected ReorderProc reorder(List<Triple> triples, List<PatternTriple> components) {
int N = components.size();
// Maybe choose 4, say, and copy over the rest.
int numReorder = N;
int[] indexes = new int[N];
if (DEBUG)
log.debug("Reorder: " + formatted(components));
int idx = 0;
for (; idx < numReorder; idx++) {
int j = chooseNext(components);
if (j < 0)
break;
Triple triple = triples.get(j);
indexes[idx] = j;
update(triple, components);
components.set(j, null);
}
// Copy over the remainder (if any)
for (int i = 0; i < components.size(); i++) {
if (components.get(i) != null)
indexes[idx++] = i;
}
if (triples.size() != idx)
throw new ARQException(String.format("Inconsistency: number of triples (%d) does not equal to number of indexes processed (%d)", triples.size(), idx));
ReorderProc proc = new ReorderProcIndexes(indexes);
return proc;
}
use of org.apache.jena.sparql.ARQException in project jena by apache.
the class StatsMatcher method init.
private void init(Item stats) {
if (!stats.isTagged(STATS))
throw new ARQException("Not a tagged '" + STATS + "'");
// Skip tag
ItemList list = stats.getList().cdr();
if (list.car().isTagged(META)) {
// Process the meta tag.
Item elt1 = list.car();
// Move list on
list = list.cdr();
// Get count.
Item x = Item.find(elt1.getList(), COUNT);
if (x != null)
count = x.getList().get(1).asInteger();
}
while (!list.isEmpty()) {
Item elt = list.car();
list = list.cdr();
onePattern(elt);
}
}
Aggregations