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