本文整理汇总了Java中org.openrdf.repository.RepositoryConnection.prepareQuery方法的典型用法代码示例。如果您正苦于以下问题:Java RepositoryConnection.prepareQuery方法的具体用法?Java RepositoryConnection.prepareQuery怎么用?Java RepositoryConnection.prepareQuery使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openrdf.repository.RepositoryConnection
的用法示例。
在下文中一共展示了RepositoryConnection.prepareQuery方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: evaluate
import org.openrdf.repository.RepositoryConnection; //导入方法依赖的package包/类
public List<List<Object>> evaluate(String queries) throws Exception {
List<List<Object>> report = new ArrayList<List<Object>>();
List<String> qnames = Arrays.asList(queries.split(" "));
for (String curQueryName : qnames)
{
List<Object> reportRow = new ArrayList<Object>();
report.add(reportRow);
String curQuery = qp.getQuery(curQueryName);
reportRow.add(curQueryName);
long startTime = System.currentTimeMillis();
//ParsedOperation pO = QueryParserUtil.parseOperation(QueryLanguage.SPARQL, curQuery, null);
RepositoryConnection repCon = this.repository.getConnection();
try {
Query tempq = repCon.prepareQuery(QueryLanguage.SPARQL, curQuery);
TupleQuery q = (TupleQuery)tempq;
SyncTupleQueryResultHandler rhandler = new SyncTupleQueryResultHandler();
q.evaluate(rhandler);
long runTime = System.currentTimeMillis() - startTime;
reportRow.add((Long)rhandler.resultCount); reportRow.add((Long)runTime);
log.info(curQueryName + ": Query exection time (msec): "+ runTime + ", Total Number of Records: " + rhandler.resultCount);
} catch (Exception e) {
reportRow.add(null); reportRow.add(null);
} finally {
repCon.close();
}
}
return report;
}