本文整理汇总了Java中com.hp.hpl.jena.sparql.algebra.Algebra.compile方法的典型用法代码示例。如果您正苦于以下问题:Java Algebra.compile方法的具体用法?Java Algebra.compile怎么用?Java Algebra.compile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hp.hpl.jena.sparql.algebra.Algebra
的用法示例。
在下文中一共展示了Algebra.compile方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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");
}
示例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;
}
示例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);
}
示例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();
}
示例5: 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);
}
}