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


Java Algebra.exec方法代码示例

本文整理汇总了Java中com.hp.hpl.jena.sparql.algebra.Algebra.exec方法的典型用法代码示例。如果您正苦于以下问题:Java Algebra.exec方法的具体用法?Java Algebra.exec怎么用?Java Algebra.exec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.hp.hpl.jena.sparql.algebra.Algebra的用法示例。


在下文中一共展示了Algebra.exec方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import com.hp.hpl.jena.sparql.algebra.Algebra; //导入方法依赖的package包/类
public static void main(String []args)
{
    // Parse
    //Query query = QueryFactory.read("file:C:\\SVN\\PigSPARQL_main\\queries\\q8.sparql") ;
    Query query = QueryFactory.read("file:queries/SP2Bench/q8mod.sparql") ;
    //System.out.println(query) ;
    
    // Generate algebra
    Op op = Algebra.compile(query) ;
    op = Algebra.optimize(op) ;
    //System.out.println(op) ;

    // Print Algebra Using SSE
    //PrintUtils.printOp(query, true);
    //System.out.println();

    String dftGraphURI = "file:datasets/SP2BEnch/dblp25M.n3" ;
    //String dftGraphURI = "file:D:\\ZerProf\\Uni\\Master\\Masterarbeit\\sp2b\\bin\\dblp50K.n3" ;
    Dataset dataset = DatasetFactory.create(dftGraphURI);
    
    // Execute it.
    QueryIterator qIter = Algebra.exec(op, dataset) ;
    
    // Results
    int results = 0;
    for ( ; qIter.hasNext() ; )
    {
        Binding b = qIter.nextBinding() ;
        results++;
        System.out.println(b) ;
    }
    qIter.close() ;
    System.out.println("# solution mappings: "+results);
}
 
开发者ID:aschaetzle,项目名称:PigSPARQL,代码行数:35,代码来源:QueryEvaluator.java

示例2: execute

import com.hp.hpl.jena.sparql.algebra.Algebra; //导入方法依赖的package包/类
@Override
	/*
	 * (non-Javadoc)
	 * @see backtype.storm.task.IBolt#execute(backtype.storm.tuple.Tuple)
	 * We assume that each tuple here is a set of graphs, result of the windowing bolt.
	 */
	public void execute(Tuple input) {
		ArrayList<Graph> graphList = (ArrayList<Graph>) input.getValue(0);
		//Graph graph = (Graph) input.getValue(0);
		QueryIterator queryIter = null;
		for (Graph g : graphList) {
			queryIter = Algebra.exec(this.opBGP, g); 
			while (queryIter.hasNext()) {
				Binding binding = queryIter.nextBinding();
				Values values = new Values();
				for (String str : this.outputFields) {
					Var aux = Var.alloc(str);
//					Var obsValue = Var.alloc("obsValue");
//					Var time = Var.alloc("time");
//					Var location = Var.alloc("location");
					Node auxNode = binding.get(aux);
//					Node obsValueNode = binding.get(obsValue);
//					Node timeNode = binding.get(time);
//					Node locationNode = binding.get(location);
	//				System.out.println(obsId + ": " + FmtUtils.stringForNode(obsIdNode) + ", " + 
	//						obsValue + ": " + FmtUtils.stringForNode(obsValueNode) + ", " + time + ": " + FmtUtils.stringForNode(timeNode)
	//						+ ", " + location + ": " + FmtUtils.stringForNode(locationNode));
					values.add(FmtUtils.stringForNode(auxNode));
				}	
				collector.emit(values);
//				collector.emit(new Values(FmtUtils.stringForNode(obsIdNode), FmtUtils.stringForNode(obsValueNode), 
//							FmtUtils.stringForNode(timeNode), FmtUtils.stringForNode(locationNode)));
			}
		}
		collector.ack(input);
	}
 
开发者ID:allaves,项目名称:storm-query-operators,代码行数:37,代码来源:OpBGPBolt.java

示例3: runLocalOp

import com.hp.hpl.jena.sparql.algebra.Algebra; //导入方法依赖的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

示例4: loadGraphPattern

import com.hp.hpl.jena.sparql.algebra.Algebra; //导入方法依赖的package包/类
public QueryIterator loadGraphPattern(Op op, Model model){
    return Algebra.exec(op, model);
}
 
开发者ID:KMax,项目名称:cqels,代码行数:4,代码来源:ExecContext.java

示例5: exec

import com.hp.hpl.jena.sparql.algebra.Algebra; //导入方法依赖的package包/类
private ResultSetRewindable exec(DatasetGraph ds, Op op) {
    QueryIterator qIter = Algebra.exec(op, ds) ;
    List<String> vars = Var.varNames(OpVars.visibleVars(op)) ;
    ResultSetRewindable rs = ResultSetFactory.makeRewindable(new ResultSetStream(vars, null, qIter)) ;
    return rs ; 
}
 
开发者ID:afs,项目名称:quack,代码行数:7,代码来源:TestEngine.java


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