use of org.apache.jena.sparql.sse.SSEParseException 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));
log.debug("Statistics-based BGP optimizer");
} catch (SSEParseException 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;
}
use of org.apache.jena.sparql.sse.SSEParseException 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 (SSEParseException ex) {
Log.error(NodeLib.class, "decode: Failed to parse: " + s);
throw ex;
}
}
use of org.apache.jena.sparql.sse.SSEParseException 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
}
use of org.apache.jena.sparql.sse.SSEParseException in project jena by apache.
the class SSE_Parser method term.
public static void term(Reader reader, ParseHandler handler) {
SSE_ParserCore p = new SSE_ParserCore(reader);
p.setHandler(handler);
try {
p.term();
// Checks for EOF
// //<EOF> test : EOF is always token 0.
// if ( p.token_source.getNextToken().kind != 0 )
// throw new SSEParseException("Trailing characters after "+item, item.getLine(), item.getColumn()) ;
} catch (ParseException ex) {
throw new SSEParseException(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 SSEParseException(tErr.getMessage(), line, col);
}
//catch (JenaException ex) { throw new TurtleParseException(ex.getMessage(), ex) ; }
}
use of org.apache.jena.sparql.sse.SSEParseException in project jena by apache.
the class SSE_Parser method parse.
public static void parse(Reader reader, ParseHandler handler) {
SSE_ParserCore p = new SSE_ParserCore(reader);
p.setHandler(handler);
try {
p.parse();
} catch (ParseException ex) {
throw new SSEParseException(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 SSEParseException(tErr.getMessage(), line, col);
}
//catch (JenaException ex) { throw new TurtleParseException(ex.getMessage(), ex) ; }
}
Aggregations