当前位置: 首页>>代码示例>>Java>>正文


Java OpAsQuery类代码示例

本文整理汇总了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();
	}
}
 
开发者ID:christoff-buerger,项目名称:reneviz,代码行数:44,代码来源:JenaService.java

示例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;
	}
 
开发者ID:christoff-buerger,项目名称:reneviz,代码行数:26,代码来源:JenaService.java

示例3: getRewrittenQuery

import com.hp.hpl.jena.sparql.algebra.OpAsQuery; //导入依赖的package包/类
public Query getRewrittenQuery() {
	
	return OpAsQuery.asQuery(rewrittenOperations);
}
 
开发者ID:peterjohnlawrence,项目名称:com.inova8.remediator,代码行数:5,代码来源:RemediatorFederatedQuery.java


注:本文中的com.hp.hpl.jena.sparql.algebra.OpAsQuery类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。