Search in sources :

Example 1 with BuildException

use of org.apache.jena.sparql.sse.builders.BuildException in project jena by apache.

the class QueryUtils method checkOp.

public static void checkOp(Query query, boolean optimizeAlgebra) {
    IndentedLineBuffer buff = new IndentedLineBuffer();
    Op op = Algebra.compile(query);
    if (optimizeAlgebra)
        op = Algebra.optimize(op);
    WriterSSE.out(buff, op, query);
    String str = buff.toString();
    try {
        Op op2 = SSE.parseOp(str);
        if (op.hashCode() != op2.hashCode()) {
            op.hashCode();
            op2.hashCode();
            dump(op, op2);
            throw new QueryCheckException("reparsed algebra expression hashCode does not equal algebra from query");
        }
        if (!op.equals(op2)) {
            dump(op, op2);
            throw new QueryCheckException("reparsed algebra expression does not equal query algebra");
        }
    } catch (SSEParseException | BuildException ex) {
        System.err.println(str);
        throw ex;
    }
// Breakpoint
}
Also used : Op(org.apache.jena.sparql.algebra.Op) SSEParseException(org.apache.jena.sparql.sse.SSEParseException) QueryCheckException(org.apache.jena.sparql.core.QueryCheckException) BuildException(org.apache.jena.sparql.sse.builders.BuildException) IndentedLineBuffer(org.apache.jena.atlas.io.IndentedLineBuffer)

Aggregations

IndentedLineBuffer (org.apache.jena.atlas.io.IndentedLineBuffer)1 Op (org.apache.jena.sparql.algebra.Op)1 QueryCheckException (org.apache.jena.sparql.core.QueryCheckException)1 SSEParseException (org.apache.jena.sparql.sse.SSEParseException)1 BuildException (org.apache.jena.sparql.sse.builders.BuildException)1