Search in sources :

Example 1 with SSE_ParseException

use of org.apache.jena.sparql.sse.SSE_ParseException in project jena by apache.

the class SerializationTest method runTestWorker.

protected void runTestWorker(Query query, Syntax syntax) {
    IndentedLineBuffer buff = new IndentedLineBuffer();
    query.serialize(buff, syntax);
    String baseURI = null;
    if (!query.explicitlySetBaseURI())
        // Not in query - use the same one (e.g. file read from) .
        baseURI = query.getBaseURI();
    try {
        QueryUtils.checkParse(query);
    } catch (RuntimeException ex) {
        System.err.println("**** Test: " + testEntry.getName());
        System.err.println("** " + ex.getMessage());
        System.err.println(query);
        throw ex;
    }
    try {
        QueryUtils.checkOp(query, true);
    } catch (SSE_ParseException ex) {
        System.err.println("**** Test: " + testEntry.getName());
        System.err.println("** Algebra error: " + ex.getMessage());
    }
}
Also used : SSE_ParseException(org.apache.jena.sparql.sse.SSE_ParseException) IndentedLineBuffer(org.apache.jena.atlas.io.IndentedLineBuffer)

Example 2 with SSE_ParseException

use of org.apache.jena.sparql.sse.SSE_ParseException in project jena by apache.

the class SSE_Parser method parse$.

private static void parse$(Reader reader, ParseHandler handler, ParserEntry parserStep) {
    SSE_ParserCore p = new SSE_ParserCore(reader);
    p.setHandler(handler);
    try {
        parserStep.entry(p);
    // EOF checking done within the parser.
    } catch (ParseException ex) {
        throw new SSE_ParseException(ex.getMessage(), ex.currentToken.beginLine, ex.currentToken.beginColumn);
    } catch (TokenMgrError tErr) {
        // Last valid token : not the same as token error message - but this should not happen
        int col = p.token.endColumn;
        int line = p.token.endLine;
        throw new SSE_ParseException(tErr.getMessage(), line, col);
    }
}
Also used : SSE_ParseException(org.apache.jena.sparql.sse.SSE_ParseException) TokenMgrError(org.apache.jena.sparql.sse.lang.parser.TokenMgrError) ParseException(org.apache.jena.sparql.sse.lang.parser.ParseException) SSE_ParseException(org.apache.jena.sparql.sse.SSE_ParseException) SSE_ParserCore(org.apache.jena.sparql.sse.lang.parser.SSE_ParserCore)

Example 3 with SSE_ParseException

use of org.apache.jena.sparql.sse.SSE_ParseException in project jena by apache.

the class TDB2StorageBuilder method chooseReorderTransformation.

public static ReorderTransformation chooseReorderTransformation(Location location) {
    if (location == null)
        return ReorderLib.identity();
    ReorderTransformation reorder = null;
    if (location.exists(Names.optStats)) {
        try {
            reorder = ReorderLib.weighted(location.getPath(Names.optStats));
            log.debug("Statistics-based BGP optimizer");
        } catch (SSE_ParseException ex) {
            log.warn("Error in stats file: " + ex.getMessage());
            reorder = null;
        }
    }
    if (reorder == null && location.exists(Names.optFixed)) {
        reorder = ReorderLib.fixed();
        log.debug("Fixed pattern BGP optimizer");
    }
    if (location.exists(Names.optNone)) {
        reorder = ReorderLib.identity();
        log.debug("Optimizer explicitly turned off");
    }
    if (reorder == null)
        reorder = SystemTDB.getDefaultReorderTransform();
    if (reorder == null && warnAboutOptimizer)
        ARQ.getExecLogger().warn("No BGP optimizer");
    return reorder;
}
Also used : SSE_ParseException(org.apache.jena.sparql.sse.SSE_ParseException) ReorderTransformation(org.apache.jena.sparql.engine.optimizer.reorder.ReorderTransformation)

Example 4 with SSE_ParseException

use of org.apache.jena.sparql.sse.SSE_ParseException in project jena by apache.

the class DatasetBuilderStd method chooseOptimizer.

public static ReorderTransformation chooseOptimizer(Location location) {
    if (location == null)
        return ReorderLib.identity();
    ReorderTransformation reorder = null;
    if (location.exists(Names.optStats)) {
        try {
            reorder = ReorderLib.weighted(location.getPath(Names.optStats));
        } catch (SSE_ParseException ex) {
            log.warn("Error in stats file: " + ex.getMessage());
            reorder = null;
        }
    }
    if (reorder == null && location.exists(Names.optFixed)) {
        // Not as good but better than nothing.
        reorder = ReorderLib.fixed();
        log.debug("Fixed pattern BGP optimizer");
    }
    if (location.exists(Names.optNone)) {
        reorder = ReorderLib.identity();
        log.debug("Optimizer explicitly turned off");
    }
    if (reorder == null)
        reorder = SystemTDB.defaultReorderTransform;
    if (reorder == null && warnAboutOptimizer)
        ARQ.getExecLogger().warn("No BGP optimizer");
    return reorder;
}
Also used : SSE_ParseException(org.apache.jena.sparql.sse.SSE_ParseException) ReorderTransformation(org.apache.jena.sparql.engine.optimizer.reorder.ReorderTransformation)

Example 5 with SSE_ParseException

use of org.apache.jena.sparql.sse.SSE_ParseException in project jena by apache.

the class NodecLib method decode.

private static /*public*/
Node decode(String s, PrefixMapping pmap) {
    if (s.startsWith("_:")) {
        s = s.substring(2);
        return NodeFactory.createBlankNode(s);
    }
    if (s.startsWith("<")) {
        s = s.substring(1, s.length() - 1);
        s = StrUtils.decodeHex(s, MarkerChar);
        return NodeFactory.createURI(s);
    }
    try {
        // SSE invocation is expensive (??).
        // Try TokenizerText?
        // Use for literals only.
        Node n = SSE.parseNode(s, pmap);
        return n;
    } catch (SSE_ParseException ex) {
        Log.error(NodeLib.class, "decode: Failed to parse: " + s);
        throw ex;
    }
}
Also used : SSE_ParseException(org.apache.jena.sparql.sse.SSE_ParseException) NodeLib(org.apache.jena.tdb.lib.NodeLib) Node(org.apache.jena.graph.Node)

Aggregations

SSE_ParseException (org.apache.jena.sparql.sse.SSE_ParseException)6 IndentedLineBuffer (org.apache.jena.atlas.io.IndentedLineBuffer)2 ReorderTransformation (org.apache.jena.sparql.engine.optimizer.reorder.ReorderTransformation)2 Node (org.apache.jena.graph.Node)1 Op (org.apache.jena.sparql.algebra.Op)1 QueryCheckException (org.apache.jena.sparql.core.QueryCheckException)1 SSE_BuildException (org.apache.jena.sparql.sse.builders.SSE_BuildException)1 ParseException (org.apache.jena.sparql.sse.lang.parser.ParseException)1 SSE_ParserCore (org.apache.jena.sparql.sse.lang.parser.SSE_ParserCore)1 TokenMgrError (org.apache.jena.sparql.sse.lang.parser.TokenMgrError)1 NodeLib (org.apache.jena.tdb.lib.NodeLib)1