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


Java QueryIterator.close方法代码示例

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


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

示例1: main

import org.apache.jena.sparql.engine.QueryIterator; //导入方法依赖的package包/类
public static void main(String []args)
{
    String s = "SELECT DISTINCT ?s { ?s ?p ?o }";
    
    // Parse
    Query query = QueryFactory.create(s) ;
    System.out.println(query) ;
    
    // Generate algebra
    Op op = Algebra.compile(query) ;
    op = Algebra.optimize(op) ;
    System.out.println(op) ;
    
    // Execute it.
    QueryIterator qIter = Algebra.exec(op, ExQuerySelect1.createModel()) ;
    
    // Results
    for ( ; qIter.hasNext() ; )
    {
        Binding b = qIter.nextBinding() ;
        System.out.println(b) ;
    }
    qIter.close() ;
}
 
开发者ID:xcurator,项目名称:xcurator,代码行数:25,代码来源:AlgebraEx.java

示例2: testMultipleParallelIterators

import org.apache.jena.sparql.engine.QueryIterator; //导入方法依赖的package包/类
@Test
public void testMultipleParallelIterators() throws IOException {
	CSVOptions options = new CSVOptions();
	options.setColumnNamesInFirstRow(false);
	CSVTable table = new CSVTable(InputStreamSource.fromString("Alice,Smith\nBob,Cook"), options);
	List<Var> vars = vars("a", "b", "ROWNUM");
	Binding row1 = binding(vars, "\"Alice\"", "\"Smith\"", "1");
	Binding row2 = binding(vars, "\"Bob\"", "\"Cook\"", "2");
	QueryIterator it1 = table.iterator(null);
	assertEquals(row1, it1.next());
	QueryIterator it2 = table.iterator(null);
	QueryIterator it3 = table.iterator(null);
	assertEquals(row1, it2.next());
	assertEquals(row2, it1.next());
	it2.close();
	assertEquals(row1, it3.next());
	assertEquals(row2, it3.next());
}
 
开发者ID:tarql,项目名称:tarql,代码行数:19,代码来源:CSVTableTest.java

示例3: main

import org.apache.jena.sparql.engine.QueryIterator; //导入方法依赖的package包/类
public static void main (String[] argv)
{
    String BASE = "http://example/" ; 
    BasicPattern bp = new BasicPattern() ;
    Var var_x = Var.alloc("x") ;
    Var var_z = Var.alloc("z") ;
    
    // ---- Build expression
    bp.add(new Triple(var_x, NodeFactory.createURI(BASE+"p"), var_z)) ;
    Op op = new OpBGP(bp) ;
    //Expr expr = ExprUtils.parse("?z < 2 ") ;
    Expr expr = new E_LessThan(new ExprVar(var_z), NodeValue.makeNodeInteger(2)) ;
    op = OpFilter.filter(expr, op) ;

    // ---- Example setup
    Model m = makeModel() ;
    m.write(System.out, "TTL") ;
    System.out.println("--------------") ;
    System.out.print(op) ;
    System.out.println("--------------") ;

    // ---- Execute expression
    QueryIterator qIter = Algebra.exec(op, m.getGraph()) ;
    
    // -------- Either read the query iterator directly ...
    if ( false )
    {
        for ( ; qIter.hasNext() ; )
        {
            Binding b = qIter.nextBinding() ;
            Node n = b.get(var_x) ;
            System.out.println(NodeFmtLib.displayStr(n)) ;
            System.out.println(b) ; 
        }
        qIter.close() ;
    }
    else
    {
        // -------- Or make ResultSet from it (but not both - reading an
        //          iterator consumes the current solution)
        List<String> varNames = new ArrayList<String>() ;
        varNames.add("x") ;
        varNames.add("z") ;
        ResultSet rs = new ResultSetStream(varNames, m, qIter);
        ResultSetFormatter.out(rs) ;
        qIter.close() ;
    }
    System.exit(0) ;
}
 
开发者ID:xcurator,项目名称:xcurator,代码行数:50,代码来源:AlgebraExec.java


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