+ cmd.getArg(timeoutArg).getValue() + "'", D2RQException.MUST_BE_NUMERIC);
}
}
loader.setFastMode(true);
ModelD2RQ d2rqModel = loader.getModelD2RQ();
String prefixes = "";
for (String prefix: d2rqModel.getNsPrefixMap().keySet()) {
prefixes += "PREFIX " + prefix + ": <" + d2rqModel.getNsPrefixURI(prefix) + ">\n";
}
query = prefixes + query;
log.info("Query:\n" + query);
try {
QueryEngineD2RQ.register();
Query q = QueryFactory.create(query, loader.getResourceBaseURI());
QueryExecution qe = QueryExecutionFactory.create(q, d2rqModel);
if (timeout > 0) {
qe.setTimeout(Math.round(timeout * 1000));
}
QueryExecUtils.executeQuery(q, qe, ResultsFormat.lookup(format));
} catch(QueryCancelledException ex) {
throw new D2RQException("Query timeout", ex, D2RQException.QUERY_TIMEOUT);
} finally {
d2rqModel.close();
}
}