本文整理汇总了Java中com.hp.hpl.jena.sparql.algebra.OpAsQuery类的典型用法代码示例。如果您正苦于以下问题:Java OpAsQuery类的具体用法?Java OpAsQuery怎么用?Java OpAsQuery使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OpAsQuery类属于com.hp.hpl.jena.sparql.algebra包,在下文中一共展示了OpAsQuery类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runLocalOp
import com.hp.hpl.jena.sparql.algebra.OpAsQuery; //导入依赖的package包/类
public ResultSetRewindable runLocalOp(Op op) {
long startTime = System.currentTimeMillis();
Query q = OpAsQuery.asQuery(op);
logger.debug("Running query on the local dataset" + ":"
// + "\n\nORIGINAL OP:\n"
// + op.toString()
// + "\n\nOPTIMIZED OP\n"
// + Algebra.optimize(op)
+ "\n\nSPARQL QUERY\n" + q.toString(Syntax.syntaxARQ));
try {
Integer key = op.toString().hashCode();
if (cache.containsKey(key)) {
logger.debug("The query was cached.");
return cache.get(key);
}
ds.begin(ReadWrite.READ);
QueryIterator qIter = Algebra.exec(op, this.ds);
List<String> vars = new LinkedList<String>();
for (Var var : OpAsQuery.asQuery(op).getProjectVars()) {
vars.add(var.getVarName());
}
ResultSetRewindable results = ResultSetFactory
.copyResults(ResultSetFactory.create(qIter, vars));
long endTime = System.currentTimeMillis();
String timeString = new SimpleDateFormat("mm:ss:SSS")
.format(new Date(endTime - startTime));
// cache disabled
// cache.put(op.toString().hashCode(), results);
logger.info("The query returned after " + timeString + " with "
+ results.size() + " results");
return results;
} finally {
ds.end();
}
}
示例2: runExternalOp
import com.hp.hpl.jena.sparql.algebra.OpAsQuery; //导入依赖的package包/类
public ResultSetRewindable runExternalOp(Op op) {
long startTime = System.currentTimeMillis();
Query q = OpAsQuery.asQuery(op);
logger.info("Running query on the external dataset:\n\n"
+ "SPARQL QUERY\n" + q.toString(Syntax.syntaxARQ));
QueryExecution qexec = QueryExecutionFactory.sparqlService(
Constants.getSparqlService(), q);
ResultSetRewindable results = ResultSetFactory.copyResults(qexec
.execSelect());
long endTime = System.currentTimeMillis();
String timeString = new SimpleDateFormat("mm:ss:SSS").format(new Date(
endTime - startTime));
logger.info("The query returned after " + timeString + " with "
+ results.size() + " results");
qexec.close();
return results;
}
示例3: getRewrittenQuery
import com.hp.hpl.jena.sparql.algebra.OpAsQuery; //导入依赖的package包/类
public Query getRewrittenQuery() {
return OpAsQuery.asQuery(rewrittenOperations);
}