Search in sources :

Example 1 with SSE_BuildException

use of org.apache.jena.sparql.sse.builders.SSE_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 (SSE_ParseException | SSE_BuildException ex) {
        throw ex;
    }
}
Also used : Op(org.apache.jena.sparql.algebra.Op) SSE_ParseException(org.apache.jena.sparql.sse.SSE_ParseException) QueryCheckException(org.apache.jena.sparql.core.QueryCheckException) SSE_BuildException(org.apache.jena.sparql.sse.builders.SSE_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 SSE_ParseException (org.apache.jena.sparql.sse.SSE_ParseException)1 SSE_BuildException (org.apache.jena.sparql.sse.builders.SSE_BuildException)1