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


Java Algebra类代码示例

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


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

示例1: executeQuery

import com.hp.hpl.jena.sparql.algebra.Algebra; //导入依赖的package包/类
public String executeQuery() {

		Query query = QueryFactory.create(this.getQuery(), Syntax.syntaxARQ);

		Op op = Algebra.compile(query);

		try {
			
			if(new String("internal").equals(this.service)) {
				this.results = jenaService.runLocalOp(op);
			} else if (new String("external").equals(this.service)) {
				this.results = jenaService.runExternalOp(op);
			}

		} catch (Exception e) {
			e.printStackTrace();
		} finally {
		}
		return ("success");
	}
 
开发者ID:christoff-buerger,项目名称:reneviz,代码行数:21,代码来源:SparqlController.java

示例2: translateQuery

import com.hp.hpl.jena.sparql.algebra.Algebra; //导入依赖的package包/类
public JoinTree translateQuery(){
	
	// parse the query and extract prefixes
    Query query = QueryFactory.read("file:"+inputFile);
    prefixes = query.getPrefixMapping();
    
    logger.info("** SPARQL QUERY **\n" + query +"\n****************"  );
    
    // extract variables, list of triples and filter
    Op opQuery = Algebra.compile(query);
    QueryVisitor queryVisitor = new QueryVisitor();
    OpWalker.walk(opQuery, queryVisitor);
    triples = queryVisitor.getTriple_patterns();
    variables  = queryVisitor.getVariables();
    
    
    // build the tree
    Node root_node = buildTree();
    JoinTree tree = new JoinTree(root_node, inputFile);
    
    // TODO: set the filter when is ready
    //tree.setFilter(queryVisitor.getFilter());
    
    // if distinct keyword is present
    tree.setDistinct(query.isDistinct());
    
    logger.info("** Spark JoinTree **\n" + tree +"\n****************" );
    
    return tree;
}
 
开发者ID:tf-dbis-uni-freiburg,项目名称:PRoST,代码行数:31,代码来源:Translator.java

示例3: 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

示例4: run

import com.hp.hpl.jena.sparql.algebra.Algebra; //导入依赖的package包/类
@Override
public void run() {
    dataset.begin(ReadWrite.READ);
    System.out.println("------------------");
    System.out.println(query);
    Op op = Algebra.compile(query);
    op = Algebra.optimize(op);
    System.out.println(op);
    System.out.println("------------------");
    System.out.println(query);
    long time = System.currentTimeMillis();
    try (QueryExecution qe = QueryExecutionFactory.create(query, dataset)) {
        ResultSet results = qe.execSelect();
        if(pretty){
            System.out.println("Output as pretty printed text");
            ResultSetFormatter.out(stream, results, query);
            
        }else{
            System.out.println("Output as CSV");
            ResultSetFormatter.outputAsCSV(stream, results);

        }
    }catch (Exception e){
        JOptionPane.showMessageDialog(null, "Writting to textarea failed!");
        e.printStackTrace();
    }
    time = System.currentTimeMillis() - time;
    String timeString = "\n Performed query in: "+time+"ms";
    try {
        stream.write(timeString.getBytes());
        stream.showText();
    } catch (IOException ex) {
        JOptionPane.showMessageDialog(null, "Writting to textarea failed!");
    }
    System.out.println(time);
    System.out.println("Finished query");
    dataset.end();
}
 
开发者ID:MarcelH91,项目名称:WikiOnto,代码行数:39,代码来源:QueryProcessor.java

示例5: modifyOp

import com.hp.hpl.jena.sparql.algebra.Algebra; //导入依赖的package包/类
@Override
protected Op modifyOp(Op op)
{ 
    op = super.modifyOp(op) ;
    op = Algebra.toQuadForm(op) ;
    return op ;
}
 
开发者ID:peterjohnlawrence,项目名称:com.inova8.remediator,代码行数:8,代码来源:QueryEngineRemediatorQuad.java

示例6: minusWorker

import com.hp.hpl.jena.sparql.algebra.Algebra; //导入依赖的package包/类
private Table minusWorker(Table tableLeft, Table tableRight)
{
    // Minus(Ω1, Ω2) = { μ | μ in Ω1 such that for all μ' in Ω2, either μ and μ' are not compatible or dom(μ) and dom(μ') are disjoint }
    
    TableN results = new TableN() ;
    QueryIterator iterLeft = tableLeft.iterator(execCxt) ;
    for ( ; iterLeft.hasNext() ; )
    {
        Binding bindingLeft = iterLeft.nextBinding() ;
        boolean includeThisRow = true ;
        // Find a reason not to include the row.
        // That's is not disjoint and not compatible.
        
        QueryIterator iterRight = tableRight.iterator(execCxt) ;
        for ( ; iterRight.hasNext() ; )
        {
            Binding bindingRight = iterRight.nextBinding() ;
            if ( Algebra.disjoint(bindingLeft, bindingRight) )
                // Disjoint - not a reason to exclude
                continue ;
            
            if ( ! Algebra.compatible(bindingLeft, bindingRight) )
                // Compatible - not a reason to exclude.
                continue ;
            
            includeThisRow = false ;
            break ;
            
        }
        iterRight.close();
        if ( includeThisRow )
            results.addBinding(bindingLeft) ;
    } 

    iterLeft.close();
    return results ;
}
 
开发者ID:peterjohnlawrence,项目名称:com.inova8.remediator,代码行数:38,代码来源:EvaluatorSimple.java

示例7: RemediatorQuery

import com.hp.hpl.jena.sparql.algebra.Algebra; //导入依赖的package包/类
public RemediatorQuery(String queryString) {
	super();
	this.queryString = queryString;
	this.originalQuery = QueryFactory.create(this.queryString);
	this.originalOperations = Algebra.compile(this.originalQuery);
	queryVars = new QueryVars(
			OpVars.mentionedVars(this.originalOperations));
	Simplifier  simplifier = new Simplifier();
	this.simplifiedOperations = Transformer.transform(simplifier, this.originalOperations);
	//Create lookup for simplified operations
	for(Triple triple:((OpBGP)this.simplifiedOperations).getPattern().getList()){
		//TODO Should only put in relevant operations for this dataset.
		simplifiedTriples.put(triple.hashCode(), triple);
	}
}
 
开发者ID:peterjohnlawrence,项目名称:com.inova8.remediator,代码行数:16,代码来源:RemediatorQuery.java

示例8: 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

示例9: modifyOp

import com.hp.hpl.jena.sparql.algebra.Algebra; //导入依赖的package包/类
@Override
protected Op modifyOp(Op op)
{ 
    if ( context.isFalse(ARQ.optimization) )
        return minimalModifyOp(op) ;
    return Algebra.optimize(op, super.context) ;
}
 
开发者ID:afs,项目名称:quack,代码行数:8,代码来源:QueryEngineMain2.java

示例10: 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

示例11: 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

示例12: 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类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。