/** Remove adjacent duplicates */ public static <T> Iterator<T> distinctAdjacent(Iterable<T> iter) { return distinctAdjacent(iter.iterator()) ; }
/** Remove adjacent duplicates. This operation does not need * working memory to remember the all elements already seen, * just a slot for the last element seen. */ public Iter<T> distinctAdjacent() { return iter(distinctAdjacent(iterator)) ; }
/** Remove adjacent duplicates. This operation does not need * working memory to remember the all elements already seen, * just a slot for the last element seen. */ public Iter<T> distinctAdjacent() { return iter(distinctAdjacent(iterator)) ; }
public static Iterator<Tuple<NodeId>> unionGraph(NodeTupleTable ntt) { Iterator<Tuple<NodeId>> iter = ntt.find((NodeId)null, null, null, null) ; iter = Iter.map(iter, quadsToAnyTriples) ; //iterMatches = Iter.distinct(iterMatches) ; // This depends on the way indexes are choose and // the indexing pattern. It assumes that the index // chosen ends in G so same triples are adjacent // in a union query. /// See TupleTable.scanAllIndex that ensures this. iter = Iter.distinctAdjacent(iter) ; return iter ; }
public static Iterator<Tuple<NodeId>> unionGraph(NodeTupleTable ntt) { Iterator<Tuple<NodeId>> iter = ntt.find((NodeId)null, null, null, null) ; iter = Iter.map(iter, quadsToAnyTriples) ; //iterMatches = Iter.distinct(iterMatches) ; // This depends on the way indexes are choose and // the indexing pattern. It assumes that the index // chosen ends in G so same triples are adjacent // in a union query. /// See TupleTable.scanAllIndex that ensures this. iter = Iter.distinctAdjacent(iter) ; return iter ; }
public Iter<T> distinctAdjacent() { return new Iter<T>(distinctAdjacent(iterator())) ; }
@Test public void distinct_02() { List<String> x = Arrays.asList("a", "b", "a"); Iterator<String> iter = Iter.distinctAdjacent(x.iterator()); test(iter, "a", "b", "a"); }
@Test public void distinct_04() { List<String> x = Arrays.asList("a", "a", "b", "b", "b", "a", "a"); Iterator<String> iter = Iter.distinctAdjacent(x.iterator()); test(iter, "a", "b", "a"); }
@Override protected ExtendedIterator<Triple> graphUnionFind(Node s, Node p, Node o) { Node g = Quad.unionGraph ; Iterator<Quad> iterQuads = getDSG().find(g, s, p, o) ; Iterator<Triple> iter = GLib.quads2triples(iterQuads) ; // Suppress duplicates after projecting to triples. // TDB guarantees that duplicates are adjacent. // See SolverLib. iter = Iter.distinctAdjacent(iter) ; return WrappedIterator.createNoRemove(iter) ; }
@Override protected ExtendedIterator<Triple> graphUnionFind(Node s, Node p, Node o) { Iterator<Quad> iterQuads = getDatasetGraphTDB().find(Quad.unionGraph, s, p, o) ; Iterator<Triple> iter = GLib.quads2triples(iterQuads) ; // Suppress duplicates after projecting to triples. // TDB guarantees that duplicates are adjacent. // See SolverLib. iter = Iter.distinctAdjacent(iter) ; return WrappedIterator.createNoRemove(iter) ; }
@Override protected final int graphBaseSize() { if ( isDefaultGraph() ) return (int)getNodeTupleTable().size() ; Node gn = getGraphName() ; boolean unionGraph = isUnionGraph(gn) ; gn = unionGraph ? Node.ANY : gn ; Iterator<Tuple<NodeId>> iter = getDSG().getQuadTable().getNodeTupleTable().findAsNodeIds(gn, null, null, null) ; if ( unionGraph ) { iter = Iter.map(iter, project4TupleTo3Tuple) ; iter = Iter.distinctAdjacent(iter) ; } return (int)Iter.count(iter) ; }
@Override protected final int graphBaseSize() { if ( isDefaultGraph() ) return (int)getNodeTupleTable().size() ; Node gn = getGraphName() ; boolean unionGraph = isUnionGraph(gn) ; gn = unionGraph ? Node.ANY : gn ; QuadTable quadTable = getDatasetGraphTDB().getQuadTable() ; Iterator<Tuple<NodeId>> iter = quadTable.getNodeTupleTable().findAsNodeIds(gn, null, null, null) ; if ( unionGraph ) { iter = Iter.map(iter, project4TupleTo3Tuple) ; iter = Iter.distinctAdjacent(iter) ; } return (int)Iter.count(iter) ; }
if ( ! isPropertyFunction(link.getNode(), execCxt.getContext()) ) { Iterator<Triple> sIter = graph.find(null, link.getNode(), null) ; return Iter.iter(sIter).distinctAdjacent().map(Triple::getSubject).distinct() ; if ( ! isPropertyFunction(link.getNode(), execCxt.getContext()) ) { Iterator<Triple> sIter = graph.find(null, link.getNode(), null) ; return Iter.iter(sIter).distinctAdjacent().map(Triple::getObject).distinct() ;
iterMatches = Iter.distinctAdjacent(iterMatches) ;
iterMatches = Iter.distinctAdjacent(iterMatches) ;