• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Iter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: nextSlice

import org.apache.jena.atlas.iterator.Iter; //导入依赖的package包/类
private Iterator<X> nextSlice() {
     if ( slicingFinished )
         return null ;
     Iterator<X> iter = sliceGenerator.apply(nextStart, finish);
     List<X> elts = Iter.take(iter, sliceSize);
     if ( elts.size() < sliceSize ) {
         // Not the only way to finish.
         // Still may end exactly on a slice
         slicingFinished = true;
     } else {
         if ( iter.hasNext() ) {
             // Look one beyond the slice. 
             nextStart = iter.next();
         } else {
             slicingFinished = true;
         }
     }
     return elts.iterator();
}
 
开发者ID:afs,项目名称:tdb3,代码行数:20,代码来源:BatchingIterator.java


示例2: change_2

import org.apache.jena.atlas.iterator.Iter; //导入依赖的package包/类
@Test
public void change_2() {
    String NAME = "change_2";
    DeltaClient dClient = createRegister(NAME);
    try(DeltaConnection dConn = dClient.get(NAME)) {
        Id dsRef = dConn.getDataSourceId();
        long version = dConn.getRemoteVersionLatest();

        DatasetGraph dsg = dConn.getDatasetGraph();
        Txn.executeWrite(dsg, ()->{
            Quad q = SSE.parseQuad("(_ :s1 :p1 :o1)");
            dsg.add(q);
        });
        // Rebuild directly.
        DatasetGraph dsg2 = DatasetGraphFactory.createTxnMem();
        long ver = dConn.getRemoteVersionLatest();
        RDFPatch patch1 = dConn.getLink().fetch(dsRef, ver) ;
        RDFPatchOps.applyChange(dsg2, patch1);

        Set<Quad> set1 = Txn.calculateRead(dsg, ()->Iter.toSet(dsg.find()));
        Set<Quad> set2 = Txn.calculateRead(dsg2, ()->Iter.toSet(dsg2.find()));
        assertEquals(set1, set2);
    }
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:25,代码来源:AbstractTestDeltaConnection.java


示例3: update_3

import org.apache.jena.atlas.iterator.Iter; //导入依赖的package包/类
@Test
public void update_3() {
    // Create on the Delta link then setup DeltaClient
    DeltaLink dLink = getLink();
    String DS_NAME = "12345";
    
    Id dsRef = dLink.newDataSource(DS_NAME, "http://example/datasource_update_3");
    DeltaClient dClient = createDeltaClient();
    dClient.register(dsRef, LocalStorageType.MEM, TxnSyncPolicy.NONE);
    DeltaConnection dConn = dClient.get(DS_NAME);
    Quad quad = SSE.parseQuad("(_ :s :p :o)");
    DatasetGraph dsg = dConn.getDatasetGraph();

    long x0 = Txn.calculateRead(dsg, ()->Iter.count(dsg.find()) );
    assertEquals(0, x0);
    
    dsg.begin(ReadWrite.WRITE);
    dsg.add(quad);
    dsg.abort();
    
    long x1 = Txn.calculateRead(dsg, ()->Iter.count(dsg.find()) );
    assertEquals(0, x1);
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:24,代码来源:AbstractTestDeltaClient.java


示例4: evalOne

import org.apache.jena.atlas.iterator.Iter; //导入依赖的package包/类
private static void evalOne(RelStore data, RelStore acc, Rule rule) {
    RelStore data2 = RelStoreFactory.combine(data, acc);
    List<Rel> body = rule.getBody();
    if ( body.isEmpty() ) {
        // Assert head.
        emit(acc, rule.getHead(), data);
        return;
    }
    Iterator<Solution> chain = Iter.singleton(new Solution());
    for(Rel rel: body) {
        chain = step(data2, rel, chain);
    }
    
    chain.forEachRemaining(soln->{
        Rel x = substitute(soln, rule.getHead());
        emit(acc, x, data);
    });
}
 
开发者ID:afs,项目名称:jena-inf-engine,代码行数:19,代码来源:RuleEngineNaive.java


示例5: chooseGraph

import org.apache.jena.atlas.iterator.Iter; //导入依赖的package包/类
/** Choose a graph from a DatasetGraph.
 * If it's the union, provide a union graph (not always the best way to deal with union).
 * @param dataset
 * @param graphNode
 * @return Graph
 */
protected static Graph chooseGraph(DatasetGraph dataset, Node graphNode) {
    if ( graphNode == null ) 
        return dataset.getDefaultGraph() ;
    else if ( Var.isVar(graphNode) )
        throw new NotImplemented("Choosing a graph OpExecutorStage.executeBlockFilter[Variable]") ;
    else if ( graphNode == Node.ANY )
        throw new NotImplemented("OpExecutorMain.executeBlockFilter[Node.ANY]") ;
    else if ( Quad.isUnionGraph(graphNode) ) {
        // TODO Check this!  Work needed here to consolidate union graph handling.
        List<Node> graphs = Iter.toList(dataset.listGraphNodes()) ;
        return new GraphUnionRead(dataset, graphs) ;
    }
    else
        return dataset.getGraph(graphNode) ;
}
 
开发者ID:afs,项目名称:quack,代码行数:22,代码来源:OpExecutorStage.java


示例6: if

import org.apache.jena.atlas.iterator.Iter; //导入依赖的package包/类
private QueryIterator executePlan$(PhysicalPlan<NodeId> plan, Binding input) {
    if ( plan.executesToNothing() ) {
        executePlanToNothing(plan) ;
        return QueryIterNullIterator.create(execCxt) ;
    }

    RowList<NodeId> rows ;
    if ( input.isEmpty() )
        rows = RowLib.identityRowList() ;
    else {
        final RowBuilder<NodeId> builder = new RowBuilderBase<NodeId>() ; // Reuse?
        builder.reset() ;
        Row<NodeId> row = ELibTDB.convertToRow(input, accessor.getNodeTable(), builder) ;
        Set<Var> vars = Collections.emptySet() ; // Reuse?
        rows = RowLib.createRowList(vars, Iter.singleton(row)) ;
    }
    
    RowList<NodeId> results = executePlan(plan, rows) ; 
    // And include the input bindings not passed on.
    Iterator<Binding> bIter = convertToBindings(results.iterator(), input, accessor.getNodeTable()) ;
    return new QueryIterPlainWrapper(bIter, execCxt) ;
}
 
开发者ID:afs,项目名称:quack,代码行数:23,代码来源:OpExecutorQuackTDB.java


示例7: convertToBindings

import org.apache.jena.atlas.iterator.Iter; //导入依赖的package包/类
/** Convert rows to bindings for a give parent, that may, or may not,
 *  have equivalent bindings of variables in the rows */ 
private static Iterator<Binding> convertToBindings(Iterator<Row<NodeId>> iter, final Binding parent, final NodeTable nodeTable) {
    Transform<Row<NodeId>, Binding> conv = new Transform<Row<NodeId>, Binding>() {
        @Override
        public Binding convert(Row<NodeId> row) {
            if ( parent.isEmpty() )
                return new BindingRow(row, nodeTable) ;
            
            // Temporary fix.  Proper fix is to change BindingBase to allow multiple occurrences in a controlled way. 
            BindingMap b = BindingFactory.create() ;
            if ( ! parent.isEmpty() ) {
                for ( Iterator<Var> vars = parent.vars() ; vars.hasNext() ; ) {
                    Var v = vars.next() ;
                    if ( ! row.contains(v) )
                        b.add(v, parent.get(v)) ;
                }
            }
            return new BindingRow(b, row, nodeTable) ;
        }
    } ;
    return Iter.map(iter, conv) ;
}
 
开发者ID:afs,项目名称:quack,代码行数:24,代码来源:OpExecutorQuackTDB.java


示例8: getCandidates

import org.apache.jena.atlas.iterator.Iter; //导入依赖的package包/类
public Iterator<Row<X>> getCandidates(Row<X> row) {
    Iterator<Row<X>> iter = null ;
    Object longHash = PipelineHashJoin.hash(hasher, joinKey, row) ;
    if ( longHash == PipelineHashJoin.noKeyHash )
        iter = buckets.flatten() ;
    else {
        Collection<Row<X>> x = buckets.get(longHash) ;
        if ( x != null ) {
            s_maxMatchGroup = Math.max(s_maxMatchGroup, x.size()) ;
            iter = x.iterator() ;
        }
    }
    // And the rows with no common hash key
    if ( noKeyBucket != null )
        iter = Iter.concat(iter, noKeyBucket.iterator()) ;
    return iter ;
}
 
开发者ID:afs,项目名称:quack,代码行数:18,代码来源:HashProbeTable.java


示例9: makeNextStage

import org.apache.jena.atlas.iterator.Iter; //导入依赖的package包/类
@Override
protected Iterator<Row<X>> makeNextStage(final Row<X> row) {
    s_countLHS ++ ;
    Tuple<Slot<X>> subst = EngLib.substitute(pattern, row) ;
    Iterator<Row<X>> iter1 = accessor.accessRows(subst) ;
    Transform<Row<X>, Row<X>> addIncoming = new Transform<Row<X>, Row<X>>(){
        @Override
        public Row<X> convert(Row<X> item) {
            Row<X> r = Join.merge(item, row, builder) ;
            if ( r != null )
                s_countResults ++ ;
            return r ;
        }
    } ;
    Iterator<Row<X>> iter2 = Iter.map(iter1, addIncoming) ;
    return iter2 ;
}
 
开发者ID:afs,项目名称:quack,代码行数:18,代码来源:SubstitutionJoin.java


示例10: equal

import org.apache.jena.atlas.iterator.Iter; //导入依赖的package包/类
public static <X> boolean equal(List<Row<X>> rowList1, List<Row<X>> rowList2) {
    List<Row<X>> rows1 = rowList1 ; //Iter.toList(rowList1.iterator()) ;
    List<Row<X>> rows2 = Iter.toList(rowList2.iterator()) ; //Mutated

    if ( rows1.size() != rows2.size() )
        return false ;
    
    for ( int i = 0; i < rows1.size(); i++) {
        Row<X> r1 = rows1.get(i) ;
        for ( int j = 0; j < rows2.size(); j++) {
            Row<X> r2 = rows2.get(j) ;
            if ( equal(r1, r2) ) {
                //rows1.remove(i) ;
                rows2.remove(j) ;
                break ;
            }
        }
    }
    return rows2.size() == 0 ;
}
 
开发者ID:afs,项目名称:quack,代码行数:21,代码来源:QJT.java


示例11: find

import org.apache.jena.atlas.iterator.Iter; //导入依赖的package包/类
@Override
public Iterator<Quad> find(Node g, Node s, Node p, Node o) {
    // Original, without deletes
    Iterator<Quad> iter1 = Iter.filter(get().find(g, s, p, o), (q)->!deleteQuads.contains(q) ) ;
    // plus adds (which do not contain deletes)
    Iterator<Quad> iter2 = addQuads.stream().filter(q->Match.match(q, g, s, p, o)).iterator() ;
    return Iter.concat(iter1,iter2);
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:9,代码来源:DatasetGraphBuffering.java


示例12: check

import org.apache.jena.atlas.iterator.Iter; //导入依赖的package包/类
private static void check(Graph graph, Triple...quads) {
    if ( quads.length == 0 ) {
        assertTrue(graph.isEmpty());
        return;
    }
    List<Triple> listExpected = Arrays.asList(quads); 
    List<Triple> listActual = Iter.toList(graph.find());
    assertEquals(listActual.size(), listExpected.size());
    assertTrue(ListUtils.equalsUnordered(listExpected, listActual));
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:11,代码来源:TestRDFChangesGraph.java


示例13: check

import org.apache.jena.atlas.iterator.Iter; //导入依赖的package包/类
private static void check(DatasetGraph dsg, Quad...quads) {
    if ( quads.length == 0 ) {
        assertTrue(dsg.isEmpty());
        return;
    }
    
    List<Quad> listExpected = Arrays.asList(quads); 
    List<Quad> listActual = Iter.toList(dsg.find());
    assertEquals(listActual.size(), listExpected.size());
    assertTrue(ListUtils.equalsUnordered(listExpected, listActual));
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:12,代码来源:TestRDFChangesDataset.java


示例14: update_1

import org.apache.jena.atlas.iterator.Iter; //导入依赖的package包/类
@Test
public void update_1() {
    // Create on the Delta link then setup DeltaClient
    DeltaLink dLink = getLink();
    String DS_NAME = "123";
    
    Id dsRef = dLink.newDataSource(DS_NAME, "http://example/datasource_update_1");
    DeltaClient dClient = createDeltaClient();
    dClient.register(dsRef, LocalStorageType.MEM, TxnSyncPolicy.NONE);
    DeltaConnection dConn = dClient.get(DS_NAME);
    assertNotNull(dConn);
    assertEquals(0, dConn.getLocalVersion());
    assertEquals(0, dConn.getRemoteVersionLatest());
    
    Quad quad = SSE.parseQuad("(_ :s :p :o)");
    DatasetGraph dsg = dConn.getDatasetGraph();
    long x0 = Iter.count(dsg.find());
    assertEquals(0, x0);
    dsg.add(quad);
    
    long x1 = Iter.count(dsg.find());
    assertEquals(1, x1);
    
    long x2 = Iter.count(dConn.getStorage().find());
    assertEquals(1, x1);

}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:28,代码来源:AbstractTestDeltaClient.java


示例15: update_2

import org.apache.jena.atlas.iterator.Iter; //导入依赖的package包/类
@Test
public void update_2() {
    // Create on the Delta link then setup DeltaClient
    DeltaLink dLink = getLink();
    String DS_NAME = "1234";
    
    Id dsRef = dLink.newDataSource(DS_NAME, "http://example/datasource_update_2");
    DeltaClient dClient = createDeltaClient();
    dClient.register(dsRef, LocalStorageType.MEM, TxnSyncPolicy.NONE);
    DeltaConnection dConn = dClient.get(DS_NAME);
    assertNotNull(dConn);
    assertEquals(0, dConn.getLocalVersion());
    assertEquals(0, dConn.getRemoteVersionLatest());
    
    Quad quad = SSE.parseQuad("(_ :s :p :o)");
    DatasetGraph dsg = dConn.getDatasetGraph();

    long x0 = Txn.calculateRead(dsg, ()->Iter.count(dsg.find()) );
    assertEquals(0, x0);
    
    Txn.executeWrite(dsg, ()->dsg.add(quad));
    long x1 = Txn.calculateRead(dsg, ()->Iter.count(dsg.find()) );
    assertEquals(1, x1);
    
    long x2 = Iter.count(dConn.getStorage().find());
    assertEquals(1, x1);
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:28,代码来源:AbstractTestDeltaClient.java


示例16: test

import org.apache.jena.atlas.iterator.Iter; //导入依赖的package包/类
private static void test(Id dsRef, DeltaClient dClient, int numQuads) {
    try(DeltaConnection dConn = dClient.get(dsRef)) {
        DatasetGraph dsg  = dConn.getDatasetGraph();
        Txn.executeRead(dsg, ()->{
            assertEquals(numQuads, Iter.count(dsg.find()));
        });
    }
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:9,代码来源:TestRestart.java


示例17: find

import org.apache.jena.atlas.iterator.Iter; //导入依赖的package包/类
@Override
public Iterator<Rel> find(Rel rel) {
    // Materializing for simplicity
    if ( !store.containsKey(rel.getName()))
        return Iter.nullIterator();
    List<Rel> result = new ArrayList<>();
    Collection<Rel> x = store.get(rel.getName());
    for(Rel r : x) {
        if ( match(r,rel) )
            result.add(r);
    }
    return result.iterator();
}
 
开发者ID:afs,项目名称:jena-inf-engine,代码行数:14,代码来源:RelStoreSimple.java


示例18: step

import org.apache.jena.atlas.iterator.Iter; //导入依赖的package包/类
private static Iterator<Solution> step(RelStore data, Rel rel, Iterator<Solution> chain) {
    // XXX
    Stream<Solution> foo = Iter.asStream(chain);
    Stream<Solution> bar = foo.flatMap(soln->{
        Rel rel2 = substitute(soln, rel);
        Iterator<Solution> chain2 = eval(data, soln, rel2);
        //chain2 = Iter.debug(chain2);
        return Iter.asStream(chain2);
    });
    return bar.iterator();
}
 
开发者ID:afs,项目名称:jena-inf-engine,代码行数:12,代码来源:RuleEngineNaive.java


示例19: size

import org.apache.jena.atlas.iterator.Iter; //导入依赖的package包/类
@Override
public long size() {
    final long quads = Iter.asStream(datasetGraph.listGraphNodes())
            .map(datasetGraph::getGraph)
            .collect(Collectors.summingLong(org.apache.jena.graph.Graph::size));
    return quads + datasetGraph.getDefaultGraph().size();
}
 
开发者ID:apache,项目名称:commons-rdf,代码行数:8,代码来源:JenaDatasetImpl.java


示例20: queryToList

import org.apache.jena.atlas.iterator.Iter; //导入依赖的package包/类
static public List<QuerySolution> queryToList(Model m, String queryString, QuerySolution init) {
    Query q = QueryFactory.create(queryString) ;
    try ( QueryExecution qExec = createQueryExecution(q, m, init) ) {
        ResultSet rs = qExec.execSelect() ;
        return Iter.toList(rs) ;
    }
}
 
开发者ID:afs,项目名称:lizard,代码行数:8,代码来源:Q.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java HistoryService类代码示例发布时间:2022-05-22
下一篇:
Java RedisOperationsSessionRepository类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap